diff --git a/lib/acts_as_having_posts.rb b/lib/acts_as_having_posts.rb index 1dff587..4635df4 100644 --- a/lib/acts_as_having_posts.rb +++ b/lib/acts_as_having_posts.rb @@ -28,7 +28,9 @@ module ActsAsHavingPosts def feed=(attrs) if attrs if self.feed - self.feed.update_attributes(attrs) + attrs.each do |key, value| + self.feed.send(key.to_s+'=', value) + end else self.feed_attrs = attrs end diff --git a/test/unit/forum_test.rb b/test/unit/forum_test.rb index 496801f..372c63c 100644 --- a/test/unit/forum_test.rb +++ b/test/unit/forum_test.rb @@ -34,14 +34,14 @@ class ForumTest < ActiveSupport::TestCase should 'save feed options' do p = create_user('testuser').person - p.articles << forum = Forum.new(:profile => p, :name => 'forum_feed_test', :body => 'Forum test') + p.articles << forum = build(Forum, :profile => p, :name => 'forum_feed_test', :body => 'Forum test') p.forum.feed = { :limit => 7 } assert_equal 7, Forum.find(forum.id).feed.limit end should 'save feed options after create forum' do p = create_user('testuser').person - p.articles << forum = Forum.new(:profile => p, :name => 'forum_feed_test', :body => 'Forum test', :feed => { :limit => 7 }) + p.articles << forum = build(Forum, :profile => p, :name => 'forum_feed_test', :body => 'Forum test', :feed => { :limit => 7 }) assert_equal 7, Forum.find(forum.id).feed.limit end @@ -52,7 +52,7 @@ class ForumTest < ActiveSupport::TestCase should 'update posts per page setting' do p = create_user('testuser').person - p.articles << forum = Forum.new(:profile => p, :name => 'Forum test', :body => 'Forum test') + p.articles << forum = build(Forum, :profile => p, :name => 'Forum test', :body => 'Forum test') forum.posts_per_page = 7 assert forum.save! assert_equal 7, Forum.find(forum.id).posts_per_page @@ -60,7 +60,7 @@ class ForumTest < ActiveSupport::TestCase should 'has posts' do p = create_user('testuser').person - p.articles << forum = Forum.new(:profile => p, :name => 'Forum test', :body => 'Forum test') + p.articles << forum = build(Forum, :profile => p, :name => 'Forum test', :body => 'Forum test') post = fast_create(TextileArticle, :name => 'First post', :profile_id => p.id, :parent_id => forum.id) forum.children << post assert_includes forum.posts, post @@ -88,13 +88,13 @@ class ForumTest < ActiveSupport::TestCase p = create_user('testuser').person fast_create(Forum, :name => 'Forum test', :profile_id => p.id) assert_nothing_raised ActiveRecord::RecordInvalid do - Forum.create!(:name => 'Another Forum', :profile => p, :body => 'Forum test') + create(Forum, :name => 'Another Forum', :profile => p, :body => 'Forum test') end end should 'not update slug from name for existing forum' do p = create_user('testuser').person - forum = Forum.create(:name => 'Forum test', :profile_id => p.id, :body => 'Forum') + forum = create(Forum, :name => 'Forum test', :profile_id => p.id, :body => 'Forum') assert_equal 'forum-test', forum.slug forum.name = 'Changed name' assert_not_equal 'changed-name', forum.slug -- libgit2 0.21.2