Skip to content

Commit

Permalink
added rspec for Classification#save
Browse files Browse the repository at this point in the history
  • Loading branch information
yrudman committed Jan 22, 2019
1 parent 6b83dfb commit fccb683
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions spec/models/classification_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -571,6 +571,31 @@
end
end

describe '#save' do
let(:new_name) { "new_tag_name" }

context "editing existing tag" do
it "updates record in Tag table which linked to this classification" do
classification = FactoryBot.create(:classification_tag, :name => "some_tag_name")
tag = classification.tag
classification.name = new_name
classification.save
expect(tag.id).to eq classification.tag.id
expect(classification.tag.name).to eq(Classification.name2tag(new_name))
end
end

context "saving new tag" do
it "creates new record in Tag table and links it to this classification" do
classification = Classification.new
classification.description = "some description"
classification.name = new_name
classification.save
expect(classification.tag).to eq(Tag.last)
end
end
end

def all_tagged_with(target, all, category = nil)
tagged_with(target, :all => all, :cat => category)
end
Expand Down

0 comments on commit fccb683

Please sign in to comment.