Commit b3d84c0cfd4505f025f00944349cfee528210726
1 parent
21316947
Exists in
master
and in
29 other branches
Fixed tolerance_time tests
Showing
4 changed files
with
19 additions
and
13 deletions
Show diff stats
plugins/tolerance_time/db/migrate/20141119204010_add_timestamps_to_tolerance.rb
0 → 100644
plugins/tolerance_time/test/unit/comment_test.rb
... | ... | @@ -3,8 +3,8 @@ require File.dirname(__FILE__) + '/../../../../test/test_helper' |
3 | 3 | class CommentTest < ActiveSupport::TestCase |
4 | 4 | should 'create a publication after posting a comment' do |
5 | 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 | 8 | comment.save! |
9 | 9 | end |
10 | 10 | assert_not_nil ToleranceTimePlugin::Publication.find_by_target(comment) |
... | ... | @@ -13,7 +13,7 @@ class CommentTest < ActiveSupport::TestCase |
13 | 13 | should 'destroy publication if the comment is destroyed' do |
14 | 14 | profile = fast_create(Profile) |
15 | 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 | 17 | comment_publication = ToleranceTimePlugin::Publication.create!(:target => comment) |
18 | 18 | comment.destroy |
19 | 19 | assert_raise ActiveRecord::RecordNotFound do | ... | ... |
plugins/tolerance_time/test/unit/tolerance_time_plugin/publication_test.rb
... | ... | @@ -4,13 +4,14 @@ class ToleranceTimePlugin::PublicationTest < ActiveSupport::TestCase |
4 | 4 | should 'validate presence of target' do |
5 | 5 | publication = ToleranceTimePlugin::Publication.new |
6 | 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 | 10 | publication.target = fast_create(Article) |
11 | 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 | 15 | end |
15 | 16 | |
16 | 17 | should 'validate uniqueness of target' do |
... | ... | @@ -19,7 +20,7 @@ class ToleranceTimePlugin::PublicationTest < ActiveSupport::TestCase |
19 | 20 | p2 = ToleranceTimePlugin::Publication.new(:target => target) |
20 | 21 | p2.valid? |
21 | 22 | |
22 | - assert p2.errors.invalid?(:target_id) | |
23 | + assert p2.errors[:target_id].present? | |
23 | 24 | end |
24 | 25 | |
25 | 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 < ActiveSupport::TestCase |
4 | 4 | should 'validate presence of profile' do |
5 | 5 | tolerance = ToleranceTimePlugin::Tolerance.new |
6 | 6 | tolerance.valid? |
7 | - assert tolerance.errors.invalid?(:profile_id) | |
7 | + assert tolerance.errors[:profile_id].present? | |
8 | 8 | |
9 | 9 | tolerance.profile = fast_create(Profile) |
10 | 10 | tolerance.valid? |
11 | - assert !tolerance.errors.invalid?(:profile_id) | |
11 | + assert !tolerance.errors[:profile_id].present? | |
12 | 12 | end |
13 | 13 | |
14 | 14 | should 'validate uniqueness of profile' do |
... | ... | @@ -17,7 +17,7 @@ class ToleranceTimePlugin::ToleranceTest < ActiveSupport::TestCase |
17 | 17 | t2 = ToleranceTimePlugin::Tolerance.new(:profile => profile) |
18 | 18 | t2.valid? |
19 | 19 | |
20 | - assert t2.errors.invalid?(:profile_id) | |
20 | + assert t2.errors[:profile_id].present? | |
21 | 21 | end |
22 | 22 | |
23 | 23 | should 'validate integer format for comment and content tolerance' do |
... | ... | @@ -27,8 +27,8 @@ class ToleranceTimePlugin::ToleranceTest < ActiveSupport::TestCase |
27 | 27 | tolerance.comment_tolerance = 'sdfa' |
28 | 28 | tolerance.content_tolerance = 4.5 |
29 | 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 | 33 | tolerance.comment_tolerance = 3 |
34 | 34 | tolerance.content_tolerance = 6 | ... | ... |