All Files (98.58% covered at 1.25 hits/line)
26 files in total.
212 relevant lines.
209 lines covered and
3 lines missed
-
1
class ApplicationController < ActionController::Base
-
# Prevent CSRF attacks by raising an exception.
-
# For APIs, you may want to use :null_session instead.
-
1
protect_from_forgery with: :exception
-
-
1
add_flash_types :error, :alert
-
-
1
before_filter :configure_permitted_parameters, if: :devise_controller?
-
-
1
protected
-
-
# We don't have how too test this unless we have the Devise controllers.
-
# Since creating the controllers looks wronger than not testing this two
-
# lines. I think we can live without 100% of coverage
-
1
def configure_permitted_parameters
-
devise_parameter_sanitizer.for(:sign_up) << :name
-
devise_parameter_sanitizer.for(:account_update) << :name
-
end
-
-
end
-
1
class CompetenceMatricesController < ApplicationController
-
1
before_action :set_competence_matrix, only: [:show, :edit, :update, :destroy]
-
1
before_action :authenticate_user!
-
1
before_action :authenticate_admin_user
-
-
1
def index
-
1
@competence_matrices = CompetenceMatrix.all
-
end
-
-
1
def show
-
end
-
-
1
def new
-
1
@competence_matrix = CompetenceMatrix.new
-
1
@competence_matrix.abilities.build
-
1
@competence_matrix.knowledge_areas.build
-
1
@competence_matrix.values.build
-
end
-
-
1
def edit
-
1
@competence_matrix.abilities.build
-
1
@competence_matrix.knowledge_areas.build
-
1
@competence_matrix.values.build
-
end
-
-
1
def create
-
5
@competence_matrix = CompetenceMatrix.new(competence_matrix_params)
-
5
if @competence_matrix.save
-
3
redirect_to competence_matrix_path(@competence_matrix)
-
else
-
2
render "new"
-
end
-
end
-
-
1
def update
-
4
if @competence_matrix.update(competence_matrix_params)
-
2
redirect_to competence_matrix_path(@competence_matrix)
-
else
-
2
render "edit"
-
end
-
end
-
-
1
def destroy
-
2
@competence_matrix.destroy
-
2
redirect_to competence_matrices_path
-
end
-
-
1
private
-
1
def set_competence_matrix
-
8
@competence_matrix = CompetenceMatrix.find(params[:id])
-
end
-
-
1
def competence_matrix_params
-
9
params.require(:competence_matrix).permit(:name,
-
abilities_attributes: [:id, :name, :_destroy],
-
knowledge_areas_attributes: [:id, :name, :_destroy],
-
values_attributes: [:id, :value, :rank, :_destroy])
-
end
-
-
1
def authenticate_admin_user
-
15
if !user_signed_in? || !current_user.admin?
-
redirect_to welcome_index_path
-
end
-
end
-
end
-
1
class WelcomeController < ApplicationController
-
1
def index
-
end
-
end
-
1
class KnowledgeArea < ActiveRecord::Base
-
1
validates :name, presence: true, length: { minimum: 1 },
-
uniqueness: { scope: :competence_matrix }
-
1
belongs_to :competence_matrix
-
end
-
1
class Value < ActiveRecord::Base
-
1
validates :value, presence: true,
-
length: { minimum: 1 },
-
uniqueness: { scope: :competence_matrix }
-
1
validates :rank, presence: true,
-
numericality: { only_integer: true, greater_than_or_equal_to: 1 },
-
uniqueness: { scope: :competence_matrix }
-
-
1
belongs_to :competence_matrix
-
1
belongs_to :ability
-
end
-
# encoding: UTF-8
-
# This file is auto-generated from the current state of the database. Instead
-
# of editing this file, please use the migrations feature of Active Record to
-
# incrementally modify your database, and then regenerate this schema definition.
-
#
-
# Note that this schema.rb definition is the authoritative source for your
-
# database schema. If you need to create the application database on another
-
# system, you should be using db:schema:load, not running all the migrations
-
# from scratch. The latter is a flawed and unsustainable approach (the more migrations
-
# you'll amass, the slower it'll run and the greater likelihood for issues).
-
#
-
# It's strongly recommended that you check this file into your version control system.
-
-
1
ActiveRecord::Schema.define(version: 20141111141439) do
-
-
1
create_table "abilities", force: true do |t|
-
1
t.string "name"
-
1
t.integer "competence_matrix_id"
-
1
t.datetime "created_at"
-
1
t.datetime "updated_at"
-
end
-
-
1
create_table "competence_matrices", force: true do |t|
-
1
t.string "name"
-
1
t.datetime "created_at"
-
1
t.datetime "updated_at"
-
end
-
-
1
create_table "knowledge_areas", force: true do |t|
-
1
t.string "name"
-
1
t.integer "competence_matrix_id"
-
1
t.datetime "created_at"
-
1
t.datetime "updated_at"
-
end
-
-
1
add_index "knowledge_areas", ["competence_matrix_id"], name: "index_knowledge_areas_on_competence_matrix_id"
-
-
1
create_table "users", force: true do |t|
-
1
t.string "email", default: "", null: false
-
1
t.string "encrypted_password", default: "", null: false
-
1
t.string "reset_password_token"
-
1
t.datetime "reset_password_sent_at"
-
1
t.datetime "remember_created_at"
-
1
t.integer "sign_in_count", default: 0, null: false
-
1
t.datetime "current_sign_in_at"
-
1
t.datetime "last_sign_in_at"
-
1
t.string "current_sign_in_ip"
-
1
t.string "last_sign_in_ip"
-
1
t.datetime "created_at"
-
1
t.datetime "updated_at"
-
1
t.string "name"
-
1
t.boolean "admin"
-
end
-
-
1
add_index "users", ["email"], name: "index_users_on_email", unique: true
-
1
add_index "users", ["reset_password_token"], name: "index_users_on_reset_password_token", unique: true
-
-
1
create_table "values", force: true do |t|
-
1
t.string "value"
-
1
t.integer "rank"
-
1
t.integer "competence_matrix_id"
-
1
t.datetime "created_at"
-
1
t.datetime "updated_at"
-
1
t.integer "ability_id"
-
end
-
-
1
add_index "values", ["ability_id"], name: "index_values_on_ability_id"
-
1
add_index "values", ["competence_matrix_id"], name: "index_values_on_competence_matrix_id"
-
-
end
-
1
require 'rails_helper'
-
-
1
RSpec.describe WelcomeController, :type => :controller do
-
-
1
describe "GET 'index'" do
-
1
it "returns http success" do
-
1
get 'index'
-
1
expect(response).to be_success
-
1
expect(response).to have_http_status(200)
-
end
-
end
-
end
-
1
require 'rails_helper'
-
-
# Specs in this file have access to a helper object that includes
-
# the CompetenceMatricesHelper. For example:
-
#
-
# describe CompetenceMatricesHelper do
-
# describe "string concat" do
-
# it "concats two strings with spaces" do
-
# expect(helper.concat_strings("this","that")).to eq("this that")
-
# end
-
# end
-
# end
-
1
RSpec.describe CompetenceMatricesHelper, :type => :helper do
-
# No tests for now
-
end
-
1
require 'spec_helper'
-
-
# Specs in this file have access to a helper object that includes
-
# the WelcomeHelper. For example:
-
#
-
# describe WelcomeHelper do
-
# describe "string concat" do
-
# it "concats two strings with spaces" do
-
# expect(helper.concat_strings("this","that")).to eq("this that")
-
# end
-
# end
-
# end
-
1
describe WelcomeHelper do
-
end
-
1
require 'rails_helper'
-
-
1
RSpec.describe Ability, :type => :model do
-
1
let(:ability) { create :ability }
-
-
2
it { should respond_to(:name) }
-
end
-
1
require 'rails_helper'
-
-
1
RSpec.describe CompetenceMatrix, :type => :model do
-
-
3
let(:competence_matrix) { FactoryGirl.create :competence_matrix }
-
-
1
describe "Ability Name and abilities" do
-
2
it { should respond_to(:name) }
-
2
it { should respond_to(:abilities) }
-
end
-
-
1
describe "Ability contage" do
-
1
it "should have no ability" do
-
1
expect(competence_matrix.abilities).to eq([])
-
end
-
-
1
it "should have an ability" do
-
1
ability = FactoryGirl.build :ability
-
1
ability.competence_matrix = competence_matrix
-
1
ability.save
-
1
competence_matrix.reload
-
1
expect(competence_matrix.abilities).to eq([ability])
-
end
-
end
-
-
end
-
1
require 'rails_helper'
-
-
1
RSpec.describe KnowledgeArea, :type => :model do
-
1
pending "add some examples to (or delete) #{__FILE__}"
-
end
-
1
require 'rails_helper'
-
-
1
RSpec.describe User, :type => :model do
-
1
let(:user) { create :user }
-
-
2
it { should respond_to(:email) }
-
2
it { should respond_to(:password) }
-
2
it { should respond_to(:name) }
-
end
-
1
require 'rails_helper'
-
-
1
RSpec.describe Value, :type => :model do
-
1
pending "add some examples to (or delete) #{__FILE__}"
-
end
-
1
require 'rails_helper'
-
-
1
RSpec.describe "CompetenceMatrices", :type => :request do
-
1
describe "GET /competence_matrices" do
-
1
it "Fails to access without login" do
-
1
get competence_matrices_path
-
1
expect(response).to have_http_status(302)
-
end
-
end
-
end
-
1
require "rails_helper"
-
-
1
RSpec.describe CompetenceMatricesController, :type => :routing do
-
1
describe "routing" do
-
-
1
it "routes to #index" do
-
1
expect(:get => "/competence_matrices").to route_to("competence_matrices#index")
-
end
-
-
1
it "routes to #new" do
-
1
expect(:get => "/competence_matrices/new").to route_to("competence_matrices#new")
-
end
-
-
1
it "routes to #show" do
-
1
expect(:get => "/competence_matrices/1").to route_to("competence_matrices#show", :id => "1")
-
end
-
-
1
it "routes to #edit" do
-
1
expect(:get => "/competence_matrices/1/edit").to route_to("competence_matrices#edit", :id => "1")
-
end
-
-
1
it "routes to #create" do
-
1
expect(:post => "/competence_matrices").to route_to("competence_matrices#create")
-
end
-
-
1
it "routes to #update" do
-
1
expect(:put => "/competence_matrices/1").to route_to("competence_matrices#update", :id => "1")
-
end
-
-
1
it "routes to #destroy" do
-
1
expect(:delete => "/competence_matrices/1").to route_to("competence_matrices#destroy", :id => "1")
-
end
-
-
end
-
end
-
1
require 'rails_helper'
-
-
1
RSpec.describe "abilities/create.html.erb", :type => :view do
-
1
pending "add some examples to (or delete) #{__FILE__}"
-
end
-
1
require 'rails_helper'
-
-
1
RSpec.describe "abilities/destroy.html.erb", :type => :view do
-
1
pending "add some examples to (or delete) #{__FILE__}"
-
end
-
1
require 'rails_helper'
-
-
1
RSpec.describe "abilities/edit.html.erb", :type => :view do
-
1
pending "add some examples to (or delete) #{__FILE__}"
-
end
-
1
require 'rails_helper'
-
-
1
RSpec.describe "abilities/new.html.erb", :type => :view do
-
1
pending "add some examples to (or delete) #{__FILE__}"
-
end
-
1
require 'rails_helper'
-
-
1
RSpec.describe "abilities/update.html.erb", :type => :view do
-
1
pending "add some examples to (or delete) #{__FILE__}"
-
end
-
1
require 'rails_helper'
-
-
1
RSpec.describe "competence_matrices/edit", :type => :view do
-
1
before(:each) do
-
1
@competence_matrix = assign(:competence_matrix, FactoryGirl.create(:competence_matrix))
-
end
-
-
1
it "renders the edit competence_matrix form" do
-
1
render
-
-
1
assert_select "form[action=?][method=?]", competence_matrix_path(@competence_matrix), "post" do
-
-
1
assert_select "input#competence_matrix_name[name=?]", "competence_matrix[name]"
-
end
-
end
-
end
-
1
require 'rails_helper'
-
-
1
RSpec.describe "competence_matrices/index", :type => :view do
-
1
before(:each) do
-
1
assign(:competence_matrices, [
-
FactoryGirl.create(:competence_matrix),
-
FactoryGirl.create(:another_competence_matrix)
-
])
-
end
-
-
1
it "renders a list of competence_matrices" do
-
1
render
-
1
assert_select "tr>td", :text => FactoryGirl.build(:competence_matrix).name.to_s, :count => 1
-
1
assert_select "tr>td", :text => FactoryGirl.build(:another_competence_matrix).name.to_s, :count => 1
-
end
-
end
-
1
require 'rails_helper'
-
-
1
RSpec.describe "competence_matrices/new", :type => :view do
-
1
before(:each) do
-
1
assign(:competence_matrix, FactoryGirl.build(:competence_matrix))
-
end
-
-
1
it "renders new competence_matrix form" do
-
1
render
-
1
assert_select "form[action=?][method=?]", competence_matrices_path, "post" do
-
1
assert_select "input#competence_matrix_name[name=?]", "competence_matrix[name]"
-
end
-
end
-
end
-
1
require 'rails_helper'
-
-
1
RSpec.describe "competence_matrices/show", :type => :view do
-
1
before(:each) do
-
1
@competence_matrix = assign(:competence_matrix, FactoryGirl.create(:competence_matrix))
-
end
-
-
1
it "renders attributes in <p>" do
-
1
render
-
1
expect(rendered).to match(/Name/)
-
end
-
end
-
1
require 'rails_helper'
-
-
1
RSpec.describe "welcome/index", :type => :view do
-
1
it "should render page" do
-
1
render
-
1
expect(rendered).to match("Welcome to SYSCOMA")
-
end
-
end