Skip to content

Commit

Permalink
final pass on specs [#152641470]
Browse files Browse the repository at this point in the history
  • Loading branch information
Stuart-Johnson committed Nov 8, 2017
1 parent 6f15d59 commit 3b3a4e3
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions spec/models/protocol/valid?_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,6 @@
build_study_type_questions()
build_study_type_answers()

before :each do
Setting.find_by_key("use_indirect_cost").update_attribute(:value, true)
end

describe 'should validate funding source for projects' do
it 'should raise an exception if funding source is nil' do
project = Project.create(attributes_for(:protocol))
Expand All @@ -42,6 +38,19 @@
end
end

it { is_expected.to validate_numericality_of(:indirect_cost_rate).is_greater_than_or_equal_to(1) }
it { is_expected.to validate_numericality_of(:indirect_cost_rate).is_less_than_or_equal_to(1000) }
context 'indirect cost is turned off' do
it 'should not validate indirect cost' do
is_expected.not_to validate_numericality_of(:indirect_cost_rate).is_greater_than_or_equal_to(1)
is_expected.not_to validate_numericality_of(:indirect_cost_rate).is_less_than_or_equal_to(1000)
end
end

context 'indirect cost is turned on' do
stub_config("use_indirect_cost", true)

it 'should validate indirect cost' do
is_expected.to validate_numericality_of(:indirect_cost_rate).is_greater_than_or_equal_to(1)
is_expected.to validate_numericality_of(:indirect_cost_rate).is_less_than_or_equal_to(1000)
end
end
end

0 comments on commit 3b3a4e3

Please sign in to comment.