diff --git a/app/models/artist.rb b/app/models/artist.rb index 403d7bfc6..2b50d0598 100644 --- a/app/models/artist.rb +++ b/app/models/artist.rb @@ -145,7 +145,8 @@ class Artist < ActiveRecord::Base :is_active => is_active, :is_banned => is_banned, :other_names => other_names, - :group_name => group_name + :group_name => group_name, + :version => versions.where("id <> ?", prev.id).maximum(:version) || 1 ) end diff --git a/app/models/note.rb b/app/models/note.rb index 530a13b64..11d3d1c83 100644 --- a/app/models/note.rb +++ b/app/models/note.rb @@ -195,7 +195,7 @@ class Note < ActiveRecord::Base :height => height, :is_active => is_active, :body => body, - :version => version + :version => versions.where("id <> ?", prev.id).maximum(:version) || 1 ) end diff --git a/test/unit/note_test.rb b/test/unit/note_test.rb index 007fea20a..d2a392162 100644 --- a/test/unit/note_test.rb +++ b/test/unit/note_test.rb @@ -14,6 +14,19 @@ class NoteTest < ActiveSupport::TestCase CurrentUser.ip_addr = nil end + context "#merge_version" do + setup do + @post = FactoryGirl.create(:post) + @note = FactoryGirl.create(:note, :post => @post) + end + + should "not increment version" do + @note.update_attributes(:x => 100) + assert_equal(1, @note.versions.count) + assert_equal(1, @note.versions.first.version) + end + end + context "for a post that already has a note" do setup do @post = FactoryGirl.create(:post)