Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
beginning of citation & citation_topic code
- Loading branch information
eef
committed
Nov 3, 2013
1 parent
8ec14d8
commit ec38f8f
Showing
3 changed files
with
47 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |