Commit b3d84c0cfd4505f025f00944349cfee528210726

Authored by Daniela Feitosa
1 parent 21316947

Fixed tolerance_time tests

plugins/tolerance_time/db/migrate/20141119204010_add_timestamps_to_tolerance.rb 0 → 100644
@@ -0,0 +1,5 @@ @@ -0,0 +1,5 @@
  1 +class AddTimestampsToTolerance < ActiveRecord::Migration
  2 + def change
  3 + add_timestamps :tolerance_time_plugin_tolerances
  4 + end
  5 +end
plugins/tolerance_time/test/unit/comment_test.rb
@@ -3,8 +3,8 @@ require File.dirname(__FILE__) + &#39;/../../../../test/test_helper&#39; @@ -3,8 +3,8 @@ require File.dirname(__FILE__) + &#39;/../../../../test/test_helper&#39;
3 class CommentTest < ActiveSupport::TestCase 3 class CommentTest < ActiveSupport::TestCase
4 should 'create a publication after posting a comment' do 4 should 'create a publication after posting a comment' do
5 article = fast_create(Article, :profile_id => fast_create(Person).id) 5 article = fast_create(Article, :profile_id => fast_create(Person).id)
6 - comment = Comment.new(:author_id => fast_create(Person).id, :body => 'Hello There!', :source_id => article.id)  
7 - assert_difference ToleranceTimePlugin::Publication, :count do 6 + comment = Comment.new(:author => fast_create(Person), :body => 'Hello There!', :source => article)
  7 + assert_difference 'ToleranceTimePlugin::Publication.count', 1 do
8 comment.save! 8 comment.save!
9 end 9 end
10 assert_not_nil ToleranceTimePlugin::Publication.find_by_target(comment) 10 assert_not_nil ToleranceTimePlugin::Publication.find_by_target(comment)
@@ -13,7 +13,7 @@ class CommentTest &lt; ActiveSupport::TestCase @@ -13,7 +13,7 @@ class CommentTest &lt; ActiveSupport::TestCase
13 should 'destroy publication if the comment is destroyed' do 13 should 'destroy publication if the comment is destroyed' do
14 profile = fast_create(Profile) 14 profile = fast_create(Profile)
15 article = fast_create(Article, :profile_id => profile.id) 15 article = fast_create(Article, :profile_id => profile.id)
16 - comment = fast_create(Comment, :source_id => article.id) 16 + comment = fast_create(Comment, :source_id => article)
17 comment_publication = ToleranceTimePlugin::Publication.create!(:target => comment) 17 comment_publication = ToleranceTimePlugin::Publication.create!(:target => comment)
18 comment.destroy 18 comment.destroy
19 assert_raise ActiveRecord::RecordNotFound do 19 assert_raise ActiveRecord::RecordNotFound do
plugins/tolerance_time/test/unit/tolerance_time_plugin/publication_test.rb
@@ -4,13 +4,14 @@ class ToleranceTimePlugin::PublicationTest &lt; ActiveSupport::TestCase @@ -4,13 +4,14 @@ class ToleranceTimePlugin::PublicationTest &lt; ActiveSupport::TestCase
4 should 'validate presence of target' do 4 should 'validate presence of target' do
5 publication = ToleranceTimePlugin::Publication.new 5 publication = ToleranceTimePlugin::Publication.new
6 publication.valid? 6 publication.valid?
7 - assert publication.errors.invalid?(:target_id)  
8 - assert publication.errors.invalid?(:target_type) 7 + assert publication.errors[:target_id].present?
  8 + assert publication.errors[:target_type].present?
9 9
10 publication.target = fast_create(Article) 10 publication.target = fast_create(Article)
11 publication.valid? 11 publication.valid?
12 - assert !publication.errors.invalid?(:target_id)  
13 - assert !publication.errors.invalid?(:target_type) 12 +
  13 + assert !publication.errors[:target_id].present?
  14 + assert !publication.errors[:target_type].present?
14 end 15 end
15 16
16 should 'validate uniqueness of target' do 17 should 'validate uniqueness of target' do
@@ -19,7 +20,7 @@ class ToleranceTimePlugin::PublicationTest &lt; ActiveSupport::TestCase @@ -19,7 +20,7 @@ class ToleranceTimePlugin::PublicationTest &lt; ActiveSupport::TestCase
19 p2 = ToleranceTimePlugin::Publication.new(:target => target) 20 p2 = ToleranceTimePlugin::Publication.new(:target => target)
20 p2.valid? 21 p2.valid?
21 22
22 - assert p2.errors.invalid?(:target_id) 23 + assert p2.errors[:target_id].present?
23 end 24 end
24 25
25 should 'be able to find publication by target' do 26 should 'be able to find publication by target' do
plugins/tolerance_time/test/unit/tolerance_time_plugin/tolerance_test.rb
@@ -4,11 +4,11 @@ class ToleranceTimePlugin::ToleranceTest &lt; ActiveSupport::TestCase @@ -4,11 +4,11 @@ class ToleranceTimePlugin::ToleranceTest &lt; ActiveSupport::TestCase
4 should 'validate presence of profile' do 4 should 'validate presence of profile' do
5 tolerance = ToleranceTimePlugin::Tolerance.new 5 tolerance = ToleranceTimePlugin::Tolerance.new
6 tolerance.valid? 6 tolerance.valid?
7 - assert tolerance.errors.invalid?(:profile_id) 7 + assert tolerance.errors[:profile_id].present?
8 8
9 tolerance.profile = fast_create(Profile) 9 tolerance.profile = fast_create(Profile)
10 tolerance.valid? 10 tolerance.valid?
11 - assert !tolerance.errors.invalid?(:profile_id) 11 + assert !tolerance.errors[:profile_id].present?
12 end 12 end
13 13
14 should 'validate uniqueness of profile' do 14 should 'validate uniqueness of profile' do
@@ -17,7 +17,7 @@ class ToleranceTimePlugin::ToleranceTest &lt; ActiveSupport::TestCase @@ -17,7 +17,7 @@ class ToleranceTimePlugin::ToleranceTest &lt; ActiveSupport::TestCase
17 t2 = ToleranceTimePlugin::Tolerance.new(:profile => profile) 17 t2 = ToleranceTimePlugin::Tolerance.new(:profile => profile)
18 t2.valid? 18 t2.valid?
19 19
20 - assert t2.errors.invalid?(:profile_id) 20 + assert t2.errors[:profile_id].present?
21 end 21 end
22 22
23 should 'validate integer format for comment and content tolerance' do 23 should 'validate integer format for comment and content tolerance' do
@@ -27,8 +27,8 @@ class ToleranceTimePlugin::ToleranceTest &lt; ActiveSupport::TestCase @@ -27,8 +27,8 @@ class ToleranceTimePlugin::ToleranceTest &lt; ActiveSupport::TestCase
27 tolerance.comment_tolerance = 'sdfa' 27 tolerance.comment_tolerance = 'sdfa'
28 tolerance.content_tolerance = 4.5 28 tolerance.content_tolerance = 4.5
29 tolerance.valid? 29 tolerance.valid?
30 - assert tolerance.errors.invalid?(:comment_tolerance)  
31 - assert tolerance.errors.invalid?(:content_tolerance) 30 + assert tolerance.errors[:comment_tolerance].present?
  31 + assert tolerance.errors[:content_tolerance].present?
32 32
33 tolerance.comment_tolerance = 3 33 tolerance.comment_tolerance = 3
34 tolerance.content_tolerance = 6 34 tolerance.content_tolerance = 6