Skip to content

Commit

Permalink
beginning of citation & citation_topic code
Browse files Browse the repository at this point in the history
  • Loading branch information
eef committed Nov 3, 2013
1 parent 8ec14d8 commit ec38f8f
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 0 deletions.
11 changes: 11 additions & 0 deletions app/models/citation_topic.rb
@@ -1,4 +1,15 @@
class CitationTopic < ActiveRecord::Base
belongs_to :topic
belongs_to :citation

validates_presence_of :topic_id, :citation_id
validates_uniqueness_of :topic_id, :citation_id

before_save :trim_pages

protected

def trim_pages # pages should have content or be empty
self.pages = self.pages.to_str.strip
end
end
8 changes: 8 additions & 0 deletions spec/models/citation_spec.rb
Expand Up @@ -19,4 +19,12 @@
specify 'isolate and create concern citable (see identifiable concern)'
end

context 'Beth' do
context 'create a citation' do
# create a citation linking a specimen (collection_object?) to a source
# create a citation linking a nomenclatural act (what object represents this?) to a source.
end

end

end
28 changes: 28 additions & 0 deletions spec/models/citation_topic_spec.rb
@@ -1,5 +1,33 @@
require 'spec_helper'

describe CitationTopic do
let(:citationtopic) { CitationTopic.new }

pending "add some examples to (or delete) #{__FILE__}"

context 'Beth' do
context 'validation' do
before do
citationtopic.valid?
end

context 'required fields' do
specify 'citation_id' do
expect(citationtopic.errors.include?(:citation_id)).to be_true
end

specify 'topic_id' do
expect(citationtopic.errors.include?(:topic_id)).to be_true
end
end

context 'no duplicates' do
# create citation
# create topic
# create cite_topic
# save & reload
# try to save again - maybe with added pages
end
end
end
end

0 comments on commit ec38f8f

Please sign in to comment.