Skip to content

Commit

Permalink
TW-144 constructing spec tests for Citation. Validation non-blankness…
Browse files Browse the repository at this point in the history
… of all required fields (citation_object_id, citation_object_type, source_id).
  • Loading branch information
TuckerJD committed Feb 25, 2015
1 parent f4c00d8 commit b0d9ba0
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion spec/models/citation_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,22 @@
let(:s) { FactoryGirl.create(:valid_source) }
let(:c1) { FactoryGirl.create(:valid_citation, {citation_object: o, source: s}) }
let(:c2) { FactoryGirl.build(:valid_citation, citation_object: o, source: s) }
let(:c3) { FactoryGirl.build(:citation) }

specify 'uniqueness' do
expect(c1.valid?).to be_truthy
expect(c2.valid?).to be_falsey
expect(c2.errors.messages[:source_id][0]).to eq('has already been taken')
end
pending ' for all required fields (:citation_object_id, :citation_object_type, :source_id).'

specify 'for all required fields (:citation_object_id, :citation_object_type, :source_id).' do
expect(c3.valid?).to be_falsey
messages = c3.errors.messages
expect(messages[:citation_object_id][0]).to eq('can\'t be blank')
expect(messages[:citation_object_type][0]).to eq('can\'t be blank')
expect(messages[:source_id][0]).to eq('can\'t be blank')
end

end

end

0 comments on commit b0d9ba0

Please sign in to comment.