Commit c97dfe8327e32fe3ef511d07420d866797ecf7e9

Authored by Daniela Feitosa
1 parent 76c36e2f

Fixing tests

test/unit/article_test.rb
@@ -1518,26 +1518,6 @@ assert_equal 'bla', profile.articles.map(&:comments_count) @@ -1518,26 +1518,6 @@ assert_equal 'bla', profile.articles.map(&:comments_count)
1518 assert_equal [c1,c2,c5], Article.text_articles 1518 assert_equal [c1,c2,c5], Article.text_articles
1519 end 1519 end
1520 1520
1521 - should 'filter articles by date of creation' do  
1522 - from = Date.today - 2.days  
1523 - to = Date.today - 1.day  
1524 - article1 = fast_create(Article, :created_at => from - 1.day)  
1525 - article2 = fast_create(Article, :created_at => from + 6.hours)  
1526 - article3 = fast_create(Article, :created_at => to + 1.day)  
1527 -  
1528 - assert_not_includes Article.created_between(from, nil), article1  
1529 - assert_includes Article.created_between(from, nil), article2  
1530 - assert_includes Article.created_between(from, nil), article3  
1531 -  
1532 - assert_includes Article.created_between(nil, to), article1  
1533 - assert_includes Article.created_between(nil, to), article2  
1534 - assert_not_includes Article.created_between(nil, to), article3  
1535 -  
1536 - assert_not_includes Article.created_between(from, to), article1  
1537 - assert_includes Article.created_between(from, to), article2  
1538 - assert_not_includes Article.created_between(from, to), article3  
1539 - end  
1540 -  
1541 should 'get first image from lead' do 1521 should 'get first image from lead' do
1542 a = fast_create(Article, :body => '<p>Foo</p><p><img src="bar.png" />Bar<img src="foo.png" /></p>', 1522 a = fast_create(Article, :body => '<p>Foo</p><p><img src="bar.png" />Bar<img src="foo.png" /></p>',
1543 :abstract => '<p>Lead</p><p><img src="leadbar.png" />Bar<img src="leadfoo.png" /></p>') 1523 :abstract => '<p>Lead</p><p><img src="leadbar.png" />Bar<img src="leadfoo.png" /></p>')
test/unit/forum_test.rb
@@ -28,21 +28,21 @@ class ForumTest &lt; ActiveSupport::TestCase @@ -28,21 +28,21 @@ class ForumTest &lt; ActiveSupport::TestCase
28 28
29 should 'create rss feed automatically' do 29 should 'create rss feed automatically' do
30 p = create_user('testuser').person 30 p = create_user('testuser').person
31 - b = create(Forum, :profile_id => p.id, :name => 'forum_feed_test') 31 + b = create(Forum, :profile_id => p.id, :name => 'forum_feed_test', :body => 'Forum')
32 assert_kind_of RssFeed, b.feed 32 assert_kind_of RssFeed, b.feed
33 end 33 end
34 34
35 should 'save feed options' do 35 should 'save feed options' do
36 p = create_user('testuser').person 36 p = create_user('testuser').person
37 - p.articles << Forum.new(:profile => p, :name => 'forum_feed_test') 37 + p.articles << forum = Forum.new(:profile => p, :name => 'forum_feed_test', :body => 'Forum test')
38 p.forum.feed = { :limit => 7 } 38 p.forum.feed = { :limit => 7 }
39 - assert_equal 7, p.forum.feed.limit 39 + assert_equal 7, Forum.find(forum.id).feed.limit
40 end 40 end
41 41
42 should 'save feed options after create forum' do 42 should 'save feed options after create forum' do
43 p = create_user('testuser').person 43 p = create_user('testuser').person
44 - p.articles << Forum.new(:profile => p, :name => 'forum_feed_test', :feed => { :limit => 7 })  
45 - assert_equal 7, p.forum.feed.limit 44 + p.articles << forum = Forum.new(:profile => p, :name => 'forum_feed_test', :body => 'Forum test', :feed => { :limit => 7 })
  45 + assert_equal 7, Forum.find(forum.id).feed.limit
46 end 46 end
47 47
48 should 'list 5 posts per page by default' do 48 should 'list 5 posts per page by default' do
@@ -52,16 +52,15 @@ class ForumTest &lt; ActiveSupport::TestCase @@ -52,16 +52,15 @@ class ForumTest &lt; ActiveSupport::TestCase
52 52
53 should 'update posts per page setting' do 53 should 'update posts per page setting' do
54 p = create_user('testuser').person 54 p = create_user('testuser').person
55 - p.articles << Forum.new(:profile => p, :name => 'Forum test')  
56 - forum = p.forum 55 + p.articles << forum = Forum.new(:profile => p, :name => 'Forum test', :body => 'Forum test')
57 forum.posts_per_page = 7 56 forum.posts_per_page = 7
58 assert forum.save! 57 assert forum.save!
59 - assert_equal 7, p.forum.posts_per_page 58 + assert_equal 7, Forum.find(forum.id).posts_per_page
60 end 59 end
61 60
62 should 'has posts' do 61 should 'has posts' do
63 p = create_user('testuser').person 62 p = create_user('testuser').person
64 - forum = fast_create(Forum, :profile_id => p.id, :name => 'Forum test') 63 + p.articles << forum = Forum.new(:profile => p, :name => 'Forum test', :body => 'Forum test')
65 post = fast_create(TextileArticle, :name => 'First post', :profile_id => p.id, :parent_id => forum.id) 64 post = fast_create(TextileArticle, :name => 'First post', :profile_id => p.id, :parent_id => forum.id)
66 forum.children << post 65 forum.children << post
67 assert_includes forum.posts, post 66 assert_includes forum.posts, post
@@ -69,7 +68,7 @@ class ForumTest &lt; ActiveSupport::TestCase @@ -69,7 +68,7 @@ class ForumTest &lt; ActiveSupport::TestCase
69 68
70 should 'not includes rss feed in posts' do 69 should 'not includes rss feed in posts' do
71 p = create_user('testuser').person 70 p = create_user('testuser').person
72 - forum = create(Forum, :profile_id => p.id, :name => 'Forum test') 71 + forum = create(Forum, :profile_id => p.id, :name => 'Forum test', :body => 'Forum')
73 assert_includes forum.children, forum.feed 72 assert_includes forum.children, forum.feed
74 assert_not_includes forum.posts, forum.feed 73 assert_not_includes forum.posts, forum.feed
75 end 74 end
@@ -89,13 +88,13 @@ class ForumTest &lt; ActiveSupport::TestCase @@ -89,13 +88,13 @@ class ForumTest &lt; ActiveSupport::TestCase
89 p = create_user('testuser').person 88 p = create_user('testuser').person
90 fast_create(Forum, :name => 'Forum test', :profile_id => p.id) 89 fast_create(Forum, :name => 'Forum test', :profile_id => p.id)
91 assert_nothing_raised ActiveRecord::RecordInvalid do 90 assert_nothing_raised ActiveRecord::RecordInvalid do
92 - Forum.create!(:name => 'Another Forum', :profile => p) 91 + Forum.create!(:name => 'Another Forum', :profile => p, :body => 'Forum test')
93 end 92 end
94 end 93 end
95 94
96 should 'not update slug from name for existing forum' do 95 should 'not update slug from name for existing forum' do
97 p = create_user('testuser').person 96 p = create_user('testuser').person
98 - forum = Forum.create!(:name => 'Forum test', :profile => p) 97 + forum = Forum.create(:name => 'Forum test', :profile_id => p.id, :body => 'Forum')
99 assert_equal 'forum-test', forum.slug 98 assert_equal 'forum-test', forum.slug
100 forum.name = 'Changed name' 99 forum.name = 'Changed name'
101 assert_not_equal 'changed-name', forum.slug 100 assert_not_equal 'changed-name', forum.slug
test/unit/person_test.rb
@@ -1201,7 +1201,7 @@ class PersonTest &lt; ActiveSupport::TestCase @@ -1201,7 +1201,7 @@ class PersonTest &lt; ActiveSupport::TestCase
1201 UserStampSweeper.any_instance.expects(:current_user).returns(person).at_least_once 1201 UserStampSweeper.any_instance.expects(:current_user).returns(person).at_least_once
1202 article = TinyMceArticle.create!(:profile => person, :name => 'An article about free software') 1202 article = TinyMceArticle.create!(:profile => person, :name => 'An article about free software')
1203 1203
1204 - assert_equal [scrap,article.activity], person.activities.map { |a| a.klass.constantize.find(a.id) } 1204 + assert_equivalent [scrap,article.activity], person.activities.map { |a| a.klass.constantize.find(a.id) }
1205 end 1205 end
1206 1206
1207 should 'not return tracked_actions and scraps from others as activities' do 1207 should 'not return tracked_actions and scraps from others as activities' do
test/unit/profile_test.rb
@@ -1623,7 +1623,7 @@ class ProfileTest &lt; ActiveSupport::TestCase @@ -1623,7 +1623,7 @@ class ProfileTest &lt; ActiveSupport::TestCase
1623 1623
1624 should 'have forum' do 1624 should 'have forum' do
1625 p = fast_create(Profile) 1625 p = fast_create(Profile)
1626 - p.articles << Forum.new(:profile => p, :name => 'forum_feed_test') 1626 + p.articles << Forum.new(:profile => p, :name => 'forum_feed_test', :body => 'Forum test')
1627 assert p.has_forum? 1627 assert p.has_forum?
1628 end 1628 end
1629 1629
@@ -1639,9 +1639,9 @@ class ProfileTest &lt; ActiveSupport::TestCase @@ -1639,9 +1639,9 @@ class ProfileTest &lt; ActiveSupport::TestCase
1639 1639
1640 should 'get first forum when has multiple forums' do 1640 should 'get first forum when has multiple forums' do
1641 p = fast_create(Profile) 1641 p = fast_create(Profile)
1642 - p.forums << Forum.new(:profile => p, :name => 'Forum one')  
1643 - p.forums << Forum.new(:profile => p, :name => 'Forum two')  
1644 - p.forums << Forum.new(:profile => p, :name => 'Forum three') 1642 + p.forums << Forum.new(:profile => p, :name => 'Forum one', :body => 'Forum test')
  1643 + p.forums << Forum.new(:profile => p, :name => 'Forum two', :body => 'Forum test')
  1644 + p.forums << Forum.new(:profile => p, :name => 'Forum three', :body => 'Forum test')
1645 assert_equal 'Forum one', p.forum.name 1645 assert_equal 'Forum one', p.forum.name
1646 assert_equal 3, p.forums.count 1646 assert_equal 3, p.forums.count
1647 end 1647 end