Files
nairobi/spec/models/abilities/valuator_spec.rb
Bertocq 1441de5107 Enable RSpec/HookArgument cop and fix issues
To be consistent about before/after arguments, as `:each` or `:example`
 are same and default scopes, best not to send an argument in those
 scenarios.

Read about cop at http://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/HookArgument
2018-01-07 02:07:19 +01:00

31 lines
1.1 KiB
Ruby

require 'rails_helper'
require 'cancan/matchers'
describe Abilities::Valuator do
subject(:ability) { Ability.new(user) }
let(:user) { valuator.user }
let(:valuator) { create(:valuator) }
let(:non_assigned_investment) { create(:budget_investment) }
let(:assigned_investment) { create(:budget_investment, budget: create(:budget, phase: 'valuating')) }
before { assigned_investment.valuators << valuator }
let(:finished_assigned_investment) { create(:budget_investment, budget: create(:budget, phase: 'finished')) }
before { finished_assigned_investment.valuators << valuator }
it { should be_able_to(:read, SpendingProposal) }
it { should be_able_to(:update, SpendingProposal) }
it { should be_able_to(:valuate, SpendingProposal) }
it { should_not be_able_to(:update, non_assigned_investment) }
it { should_not be_able_to(:valuate, non_assigned_investment) }
it { should be_able_to(:update, assigned_investment) }
it { should be_able_to(:valuate, assigned_investment) }
it { should_not be_able_to(:update, finished_assigned_investment) }
it { should_not be_able_to(:valuate, finished_assigned_investment) }
end