diff --git a/test/unit/article_test.rb b/test/unit/article_test.rb index 13a5a38..b205c67 100644 --- a/test/unit/article_test.rb +++ b/test/unit/article_test.rb @@ -1518,26 +1518,6 @@ assert_equal 'bla', profile.articles.map(&:comments_count) assert_equal [c1,c2,c5], Article.text_articles end - should 'filter articles by date of creation' do - from = Date.today - 2.days - to = Date.today - 1.day - article1 = fast_create(Article, :created_at => from - 1.day) - article2 = fast_create(Article, :created_at => from + 6.hours) - article3 = fast_create(Article, :created_at => to + 1.day) - - assert_not_includes Article.created_between(from, nil), article1 - assert_includes Article.created_between(from, nil), article2 - assert_includes Article.created_between(from, nil), article3 - - assert_includes Article.created_between(nil, to), article1 - assert_includes Article.created_between(nil, to), article2 - assert_not_includes Article.created_between(nil, to), article3 - - assert_not_includes Article.created_between(from, to), article1 - assert_includes Article.created_between(from, to), article2 - assert_not_includes Article.created_between(from, to), article3 - end - should 'get first image from lead' do a = fast_create(Article, :body => '

Foo

Bar

', :abstract => '

Lead

Bar

') diff --git a/test/unit/forum_test.rb b/test/unit/forum_test.rb index b784b55..fed6053 100644 --- a/test/unit/forum_test.rb +++ b/test/unit/forum_test.rb @@ -28,21 +28,21 @@ class ForumTest < ActiveSupport::TestCase should 'create rss feed automatically' do p = create_user('testuser').person - b = create(Forum, :profile_id => p.id, :name => 'forum_feed_test') + b = create(Forum, :profile_id => p.id, :name => 'forum_feed_test', :body => 'Forum') assert_kind_of RssFeed, b.feed end should 'save feed options' do p = create_user('testuser').person - p.articles << Forum.new(:profile => p, :name => 'forum_feed_test') + p.articles << forum = Forum.new(:profile => p, :name => 'forum_feed_test', :body => 'Forum test') p.forum.feed = { :limit => 7 } - assert_equal 7, p.forum.feed.limit + 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.new(:profile => p, :name => 'forum_feed_test', :feed => { :limit => 7 }) - assert_equal 7, p.forum.feed.limit + p.articles << forum = Forum.new(:profile => p, :name => 'forum_feed_test', :body => 'Forum test', :feed => { :limit => 7 }) + assert_equal 7, Forum.find(forum.id).feed.limit end should 'list 5 posts per page by default' do @@ -52,16 +52,15 @@ class ForumTest < ActiveSupport::TestCase should 'update posts per page setting' do p = create_user('testuser').person - p.articles << Forum.new(:profile => p, :name => 'Forum test') - forum = p.forum + p.articles << forum = Forum.new(:profile => p, :name => 'Forum test', :body => 'Forum test') forum.posts_per_page = 7 assert forum.save! - assert_equal 7, p.forum.posts_per_page + assert_equal 7, Forum.find(forum.id).posts_per_page end should 'has posts' do p = create_user('testuser').person - forum = fast_create(Forum, :profile_id => p.id, :name => 'Forum test') + p.articles << forum = Forum.new(: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 @@ -69,7 +68,7 @@ class ForumTest < ActiveSupport::TestCase should 'not includes rss feed in posts' do p = create_user('testuser').person - forum = create(Forum, :profile_id => p.id, :name => 'Forum test') + forum = create(Forum, :profile_id => p.id, :name => 'Forum test', :body => 'Forum') assert_includes forum.children, forum.feed assert_not_includes forum.posts, forum.feed end @@ -89,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) + Forum.create!(: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 => p) + forum = Forum.create(: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 diff --git a/test/unit/person_test.rb b/test/unit/person_test.rb index 3dfd59e..9679541 100644 --- a/test/unit/person_test.rb +++ b/test/unit/person_test.rb @@ -1201,7 +1201,7 @@ class PersonTest < ActiveSupport::TestCase UserStampSweeper.any_instance.expects(:current_user).returns(person).at_least_once article = TinyMceArticle.create!(:profile => person, :name => 'An article about free software') - assert_equal [scrap,article.activity], person.activities.map { |a| a.klass.constantize.find(a.id) } + assert_equivalent [scrap,article.activity], person.activities.map { |a| a.klass.constantize.find(a.id) } end should 'not return tracked_actions and scraps from others as activities' do diff --git a/test/unit/profile_test.rb b/test/unit/profile_test.rb index e98491f..2ef447a 100644 --- a/test/unit/profile_test.rb +++ b/test/unit/profile_test.rb @@ -1623,7 +1623,7 @@ class ProfileTest < ActiveSupport::TestCase should 'have forum' do p = fast_create(Profile) - p.articles << Forum.new(:profile => p, :name => 'forum_feed_test') + p.articles << Forum.new(:profile => p, :name => 'forum_feed_test', :body => 'Forum test') assert p.has_forum? end @@ -1639,9 +1639,9 @@ class ProfileTest < ActiveSupport::TestCase should 'get first forum when has multiple forums' do p = fast_create(Profile) - p.forums << Forum.new(:profile => p, :name => 'Forum one') - p.forums << Forum.new(:profile => p, :name => 'Forum two') - p.forums << Forum.new(:profile => p, :name => 'Forum three') + p.forums << Forum.new(:profile => p, :name => 'Forum one', :body => 'Forum test') + p.forums << Forum.new(:profile => p, :name => 'Forum two', :body => 'Forum test') + p.forums << Forum.new(:profile => p, :name => 'Forum three', :body => 'Forum test') assert_equal 'Forum one', p.forum.name assert_equal 3, p.forums.count end -- libgit2 0.21.2