diff --git a/lib/authenticated_test_helper.rb b/lib/authenticated_test_helper.rb index 3cb9fb2..a269b19 100644 --- a/lib/authenticated_test_helper.rb +++ b/lib/authenticated_test_helper.rb @@ -28,25 +28,6 @@ module AuthenticatedTestHelper end end - # http://project.ioni.st/post/217#post-217 - # - # def test_new_publication - # assert_difference(Publication, :count) do - # post :create, :publication => {...} - # # ... - # end - # end - # - def assert_difference(object, method = nil, difference = 1) - initial_value = object.send(method) - yield - assert_equal initial_value + difference, object.send(method), "#{object}##{method}" - end - - def assert_no_difference(object, method, &block) - assert_difference object, method, 0, &block - end - # Assert the block redirects to the login # # assert_requires_login(:bob) { |c| c.get :edit, :id => 1 } diff --git a/test/functional/account_controller_test.rb b/test/functional/account_controller_test.rb index af994aa..5a39da0 100644 --- a/test/functional/account_controller_test.rb +++ b/test/functional/account_controller_test.rb @@ -57,7 +57,7 @@ class AccountControllerTest < ActionController::TestCase end def test_should_allow_signup - assert_difference User, :count do + assert_difference 'User.count' do new_user assert_response :success assert_not_nil assigns(:register_pending) @@ -65,7 +65,7 @@ class AccountControllerTest < ActionController::TestCase end def test_should_require_login_on_signup - assert_no_difference User, :count do + assert_no_difference 'User.count' do new_user(:login => nil) assert assigns(:user).errors.on(:login) assert_response :success @@ -74,7 +74,7 @@ class AccountControllerTest < ActionController::TestCase end def test_should_require_password_on_signup - assert_no_difference User, :count do + assert_no_difference 'User.count' do new_user(:password => nil) assert assigns(:user).errors.on(:password) assert_response :success @@ -83,7 +83,7 @@ class AccountControllerTest < ActionController::TestCase end def test_should_require_password_confirmation_on_signup - assert_no_difference User, :count do + assert_no_difference 'User.count' do new_user(:password_confirmation => nil) assert assigns(:user).errors.on(:password_confirmation) assert_response :success @@ -92,7 +92,7 @@ class AccountControllerTest < ActionController::TestCase end def test_should_require_email_on_signup - assert_no_difference User, :count do + assert_no_difference 'User.count' do new_user(:email => nil) assert assigns(:user).errors.on(:email) assert_response :success @@ -101,7 +101,7 @@ class AccountControllerTest < ActionController::TestCase end def test_shoud_not_save_without_acceptance_of_terms_of_use_on_signup - assert_no_difference User, :count do + assert_no_difference 'User.count' do Environment.default.update_attributes(:terms_of_use => 'some terms ...') new_user assert_response :success @@ -110,7 +110,7 @@ class AccountControllerTest < ActionController::TestCase end def test_shoud_save_with_acceptance_of_terms_of_use_on_signup - assert_difference User, :count do + assert_difference 'User.count' do Environment.default.update_attributes(:terms_of_use => 'some terms ...') new_user(:terms_accepted => '1') assert_response :success @@ -295,7 +295,7 @@ class AccountControllerTest < ActionController::TestCase end should 'restrict multiple users with the same e-mail' do - assert_difference User, :count do + assert_difference 'User.count' do new_user(:login => 'user1', :email => 'user@example.com') assert assigns(:user).valid? @controller.stubs(:logged_in?).returns(false) @@ -622,7 +622,7 @@ class AccountControllerTest < ActionController::TestCase should 'signup filling in mandatory person fields' do Person.any_instance.stubs(:required_fields).returns(['organization']) - assert_difference User, :count do + assert_difference 'User.count' do post :signup, :user => { :login => 'testuser', :password => '123456', :password_confirmation => '123456', :email => 'testuser@example.com' }, :profile_data => { :organization => 'example.com' } assert_response :success end @@ -910,7 +910,7 @@ class AccountControllerTest < ActionController::TestCase should 'not sign in if the honeypot field is filled' do Person.any_instance.stubs(:required_fields).returns(['organization']) - assert_no_difference User, :count do + assert_no_difference 'User.count' do post :signup, :user => { :login => 'testuser', :password => '123456', :password_confirmation => '123456', :email => 'testuser@example.com' }, :profile_data => { :organization => 'example.com' }, :honeypot => 'something' end assert @response.body.blank? diff --git a/test/functional/categories_controller_test.rb b/test/functional/categories_controller_test.rb index 724a772..765f0aa 100644 --- a/test/functional/categories_controller_test.rb +++ b/test/functional/categories_controller_test.rb @@ -67,7 +67,7 @@ class CategoriesControllerTest < ActionController::TestCase end def test_new_save - assert_difference Category, :count do + assert_difference 'Category.count' do post :new, :category => { :name => 'a new category' } assert_redirected_to :action => 'index' end @@ -83,7 +83,7 @@ class CategoriesControllerTest < ActionController::TestCase end should 'be able to upload a file' do - assert_difference Category, :count do + assert_difference 'Category.count' do post :new, :category => { :name => 'new category', :image_builder => { :uploaded_data => fixture_file_upload('/files/rails.png', 'image/png') } } assert_equal assigns(:category).image.filename, 'rails.png' end diff --git a/test/functional/cms_controller_test.rb b/test/functional/cms_controller_test.rb index 0acac68..58a86e5 100644 --- a/test/functional/cms_controller_test.rb +++ b/test/functional/cms_controller_test.rb @@ -80,7 +80,7 @@ class CmsControllerTest < ActionController::TestCase end should 'be able to save a document' do - assert_difference Article, :count do + assert_difference 'Article.count' do post :new, :type => 'TinyMceArticle', :profile => profile.identifier, :article => { :name => 'a test article', :body => 'the text of the article ...' } end end @@ -245,7 +245,7 @@ class CmsControllerTest < ActionController::TestCase should 'be able to remove article' do a = profile.articles.build(:name => 'my-article') a.save! - assert_difference Article, :count, -1 do + assert_difference 'Article.count', -1 do post :destroy, :profile => profile.identifier, :id => a.id end end @@ -276,7 +276,7 @@ class CmsControllerTest < ActionController::TestCase should 'be able to create a RSS feed' do login_as(profile.identifier) - assert_difference RssFeed, :count do + assert_difference 'RssFeed.count' do post :new, :type => RssFeed.name, :profile => profile.identifier, :article => { :name => 'new-feed', :limit => 15, :include => 'all' } assert_response :redirect end @@ -294,7 +294,7 @@ class CmsControllerTest < ActionController::TestCase end should 'be able to upload a file' do - assert_difference UploadedFile, :count do + assert_difference 'UploadedFile.count' do post :new, :type => UploadedFile.name, :profile => profile.identifier, :article => { :uploaded_data => fixture_file_upload('/files/test.txt', 'text/plain')} end assert_not_nil profile.articles.find_by_path('test.txt') @@ -313,13 +313,13 @@ class CmsControllerTest < ActionController::TestCase end should 'be able to upload an image' do - assert_difference UploadedFile, :count do + assert_difference 'UploadedFile.count' do post :new, :type => UploadedFile.name, :profile => profile.identifier, :article => { :uploaded_data => fixture_file_upload('/files/rails.png', 'image/png')} end end should 'be able to upload more than one file at once' do - assert_difference UploadedFile, :count, 2 do + assert_difference 'UploadedFile.count', 2 do post :upload_files, :profile => profile.identifier, :uploaded_files => [fixture_file_upload('/files/test.txt', 'text/plain'), fixture_file_upload('/files/rails.png', 'text/plain')] end assert_not_nil profile.articles.find_by_path('test.txt') @@ -439,7 +439,7 @@ class CmsControllerTest < ActionController::TestCase article.profile = profile article.save! - assert_no_difference UploadedFile, :count do + assert_no_difference 'UploadedFile.count' do assert_raise ArgumentError do post :new, :type => UploadedFile.name, :parent_id => article.id, :profile => profile.identifier, :article => { :uploaded_data => fixture_file_upload('/files/test.txt', 'text/plain')} end @@ -760,7 +760,7 @@ class CmsControllerTest < ActionController::TestCase c.affiliate(profile, Profile::Roles.all_roles(c.environment.id)) article = profile.articles.create!(:name => 'something intresting', :body => 'ruby on rails') - assert_difference article.class, :count do + assert_difference 'article.class.count' do post :publish, :profile => profile.identifier, :id => article.id, :marked_groups => {c.id.to_s => {:name => 'bli', :group_id => c.id.to_s}} assert_equal [{'group' => c, 'name' => 'bli'}], assigns(:marked_groups) end @@ -771,7 +771,7 @@ class CmsControllerTest < ActionController::TestCase c.affiliate(profile, Profile::Roles.all_roles(c.environment.id)) a = Event.create!(:name => "Some event", :profile => profile, :start_date => Date.today) - assert_difference Event, :count do + assert_difference 'Event.count' do post :publish, :profile => profile.identifier, :id => a.id, :marked_groups => {c.id.to_s => {:name => 'bli', :group_id => c.id.to_s}} end end @@ -791,7 +791,7 @@ class CmsControllerTest < ActionController::TestCase Environment.any_instance.stubs(:portal_community).returns(portal_community) article = profile.articles.create!(:name => 'something intresting', :body => 'ruby on rails') - assert_difference article.class, :count do + assert_difference 'article.class.count' do post :publish_on_portal_community, :profile => profile.identifier, :id => article.id, :name => article.name end end @@ -801,9 +801,9 @@ class CmsControllerTest < ActionController::TestCase c.affiliate(profile, Profile::Roles.all_roles(c.environment.id)) a = profile.articles.create!(:name => 'something intresting', :body => 'ruby on rails') - assert_no_difference a.class, :count do - assert_difference ApproveArticle, :count do - assert_difference c.tasks, :count do + assert_no_difference 'a.class.count' do + assert_difference 'ApproveArticle.count' do + assert_difference 'c.tasks.count' do post :publish, :profile => profile.identifier, :id => a.id, :marked_groups => {c.id.to_s => {:name => 'bli', :group_id => c.id.to_s}} assert_equal [{'group' => c, 'name' => 'bli'}], assigns(:marked_groups) end @@ -818,9 +818,9 @@ class CmsControllerTest < ActionController::TestCase Environment.any_instance.stubs(:portal_community).returns(portal_community) article = profile.articles.create!(:name => 'something intresting', :body => 'ruby on rails') - assert_no_difference article.class, :count do - assert_difference ApproveArticle, :count do - assert_difference portal_community.tasks, :count do + assert_no_difference 'article.class.count' do + assert_difference 'ApproveArticle.count' do + assert_difference 'portal_community.tasks.count' do post :publish_on_portal_community, :profile => profile.identifier, :id => article.id, :name => article.name end end @@ -961,7 +961,7 @@ class CmsControllerTest < ActionController::TestCase end should 'go to blog after create it' do - assert_difference Blog, :count do + assert_difference 'Blog.count' do post :new, :type => Blog.name, :profile => profile.identifier, :article => { :name => 'my-blog' }, :back_to => 'control_panel' end assert_redirected_to @profile.articles.find_by_name('my-blog').view_url @@ -1317,7 +1317,7 @@ class CmsControllerTest < ActionController::TestCase end should 'go to forum after create it' do - assert_difference Forum, :count do + assert_difference 'Forum.count' do post :new, :type => Forum.name, :profile => profile.identifier, :article => { :name => 'my-forum' }, :back_to => 'control_panel' end assert_redirected_to @profile.articles.find_by_name('my-forum').view_url @@ -1369,7 +1369,7 @@ class CmsControllerTest < ActionController::TestCase should 'create a task suggest task to a profile' do c = Community.create!(:name => 'test comm', :identifier => 'test_comm', :moderated_articles => true) - assert_difference SuggestArticle, :count do + assert_difference 'SuggestArticle.count' do post :suggest_an_article, :profile => c.identifier, :back_to => 'action_view', :task => {:article_name => 'some name', :article_body => 'some body', :email => 'some@localhost.com', :name => 'some name'} end end @@ -1404,7 +1404,7 @@ class CmsControllerTest < ActionController::TestCase should 'add translation to an article' do textile = fast_create(TextileArticle, :profile_id => @profile.id, :path => 'textile', :language => 'ru') - assert_difference Article, :count do + assert_difference 'Article.count' do post :new, :profile => @profile.identifier, :type => 'TextileArticle', :article => { :name => 'english translation', :translation_of_id => textile.id, :language => 'en' } end end diff --git a/test/functional/comment_controller_test.rb b/test/functional/comment_controller_test.rb index b408030..a5cdf8a 100644 --- a/test/functional/comment_controller_test.rb +++ b/test/functional/comment_controller_test.rb @@ -26,7 +26,7 @@ class CommentControllerTest < ActionController::TestCase comment = fast_create(Comment, :source_id => article, :title => 'a comment', :body => 'lalala') login_as 'normaluser' # normaluser cannot remove other people's comments - assert_no_difference Comment, :count do + assert_no_difference 'Comment.count' do post :destroy, :profile => profile.identifier, :id => comment.id end end @@ -41,7 +41,7 @@ class CommentControllerTest < ActionController::TestCase comment = fast_create(Comment, :source_id => article, :author_id => commenter, :title => 'a comment', :body => 'lalala') login_as 'normaluser' # normaluser cannot remove other people's comments - assert_no_difference Comment, :count do + assert_no_difference 'Comment.count' do xhr :post, :destroy, :profile => profile.identifier, :id => comment.id assert_response :success end @@ -57,7 +57,7 @@ class CommentControllerTest < ActionController::TestCase comment = fast_create(Comment, :source_id => article, :author_id => commenter, :title => 'a comment', :body => 'lalala') login_as 'testuser' # testuser must be able to remove comments in his articles - assert_difference Comment, :count, -1 do + assert_difference 'Comment.count', -1 do xhr :post, :destroy, :profile => profile.identifier, :id => comment.id assert_response :success end @@ -74,7 +74,7 @@ class CommentControllerTest < ActionController::TestCase comment = fast_create(Comment, :source_id => image, :author_id => commenter, :title => 'a comment', :body => 'lalala') login_as 'testuser' # testuser must be able to remove comments in his articles - assert_difference Comment, :count, -1 do + assert_difference 'Comment.count', -1 do xhr :post, :destroy, :profile => profile.identifier, :id => comment.id assert_response :success end @@ -87,7 +87,7 @@ class CommentControllerTest < ActionController::TestCase comment = fast_create(Comment, :source_id => article, :author_id => commenter, :title => 'a comment', :body => 'lalala') community.add_moderator(profile) login_as profile.identifier - assert_difference Comment, :count, -1 do + assert_difference 'Comment.count', -1 do xhr :post, :destroy, :profile => community.identifier, :id => comment.id assert_response :success end @@ -101,7 +101,7 @@ class CommentControllerTest < ActionController::TestCase comment = fast_create(Comment, :source_id => article, :author_id => profile, :title => 'a comment', :body => 'lalala') login_as 'testuser' - assert_difference Comment, :count, -1 do + assert_difference 'Comment.count', -1 do xhr :post, :destroy, :profile => profile.identifier, :id => comment.id assert_response :success end @@ -113,7 +113,7 @@ class CommentControllerTest < ActionController::TestCase other_person = create_user('otheruser').person other_page = other_person.articles.create!(:name => 'myarticle', :body => 'the body of the text') - assert_no_difference Comment, :count do + assert_no_difference 'Comment.count' do xhr :post, :create, :profile => profile.identifier, :id => other_page.id, :comment => { :title => 'crap!', :body => 'I think that this article is crap' } end assert_match /not found/, @response.body @@ -122,7 +122,7 @@ class CommentControllerTest < ActionController::TestCase should 'not be able to post comment if article do not accept it' do page = profile.articles.create!(:name => 'myarticle', :body => 'the body of the text', :accept_comments => false) - assert_no_difference Comment, :count do + assert_no_difference 'Comment.count' do xhr :post, :create, :profile => profile.identifier, :id => page.id, :comment => { :title => 'crap!', :body => 'I think that this article is crap' } end assert_match /Comment not allowed in this article/, @response.body @@ -162,7 +162,7 @@ class CommentControllerTest < ActionController::TestCase end Noosfero::Plugin::Manager.any_instance.stubs(:enabled_plugins).returns([TestFilterPlugin.new]) page = profile.articles.create!(:name => 'myarticle', :body => 'the body of the text') - assert_no_difference Comment, :count do + assert_no_difference 'Comment.count' do xhr :post, :create, :profile => profile.identifier, :id => page.id, :comment => { :title => 'title', :body => 'body', :name => "Spammer", :email => 'damn@spammer.com' }, :confirm => 'true' end end @@ -175,7 +175,7 @@ class CommentControllerTest < ActionController::TestCase end Noosfero::Plugin::Manager.any_instance.stubs(:enabled_plugins).returns([TestFilterPlugin.new]) page = profile.articles.create!(:name => 'myarticle', :body => 'the body of the text') - assert_no_difference Comment, :count do + assert_no_difference 'Comment.count' do xhr :post, :create, :profile => profile.identifier, :id => page.id, :comment => { :title => 'title', :body => 'body', :name => "Spammer", :email => 'damn@spammer.com' }, :confirm => 'true' end @@ -199,7 +199,7 @@ class CommentControllerTest < ActionController::TestCase article.save! login_as('testinguser') - assert_no_difference Comment, :count do + assert_no_difference 'Comment.count' do xhr :post, :create, :profile => profile.identifier, :id =>article.id, :comment => {:body => ""}, :confirm => 'true' end assert_match /post_comment_box opened/, @response.body @@ -224,14 +224,14 @@ class CommentControllerTest < ActionController::TestCase login_as('testinguser') @controller.stubs(:verify_recaptcha).returns(false) - assert_difference Comment, :count, 1 do + assert_difference 'Comment.count', 1 do xhr :post, :create, :profile => profile.identifier, :id => article.id, :comment => {:body => "Some comment...", :author => profile}, :confirm => 'true' end environment.enable('captcha_for_logged_users') environment.save! - assert_no_difference Comment, :count do + assert_no_difference 'Comment.count' do xhr :post, :create, :profile => profile.identifier, :id =>article.id, :comment => {:body => "Some comment...", :author => profile}, :confirm => 'true' end assert_not_nil assigns(:comment) @@ -242,12 +242,12 @@ class CommentControllerTest < ActionController::TestCase article.save! @controller.stubs(:verify_recaptcha).returns(false) - assert_no_difference Comment, :count do + assert_no_difference 'Comment.count' do xhr :post, :create, :profile => profile.identifier, :id => article.id, :comment => {:body => "Some comment...", :author => profile}, :confirm => 'true' end @controller.stubs(:verify_recaptcha).returns(true) - assert_difference Comment, :count, 1 do + assert_difference 'Comment.count', 1 do xhr :post, :create, :profile => profile.identifier, :id => article.id, :comment => {:body => "Some comment...", :author => profile}, :confirm => 'true' end end @@ -258,7 +258,7 @@ class CommentControllerTest < ActionController::TestCase page = community.articles.create!(:name => 'myarticle', :moderate_comments => true) commenter = create_user('otheruser').person - assert_difference ApproveComment, :count, 1 do + assert_difference 'ApproveComment.count', 1 do xhr :post, :create, :profile => community.identifier, :id => page.id, :comment => {:body => 'Some comment...', :author => commenter}, :confirm => 'true' end end @@ -269,7 +269,7 @@ class CommentControllerTest < ActionController::TestCase page = community.articles.create!(:name => 'myarticle', :moderate_comments => true, :last_changed_by => @profile) community.add_moderator(@profile) - assert_no_difference ApproveComment, :count do + assert_no_difference 'ApproveComment.count' do xhr :post, :create, :profile => profile.identifier, :id => page.id, :comment => {:body => 'Some comment...'}, :confirm => 'true' end end @@ -279,7 +279,7 @@ class CommentControllerTest < ActionController::TestCase page = community.articles.create!(:name => 'myarticle', :moderate_comments => true) commenter = create_user('otheruser').person - assert_difference ApproveComment, :count, 1 do + assert_difference 'ApproveComment.count', 1 do xhr :post, :create, :profile => community.identifier, :id => page.id, :comment => {:body => 'Some comment...', :author => commenter}, :confirm => 'true' end task = Task.last @@ -293,7 +293,7 @@ class CommentControllerTest < ActionController::TestCase page = community.articles.create!(:name => 'myarticle', :moderate_comments => true) commenter = create_user('otheruser').person - assert_difference ApproveComment, :count, 1 do + assert_difference 'ApproveComment.count', 1 do xhr :post, :create, :profile => community.identifier, :id => page.id, :comment => {:body => 'Some comment...', :author => commenter}, :confirm => 'true' end task = Task.last diff --git a/test/functional/favorite_enterprises_controller_test.rb b/test/functional/favorite_enterprises_controller_test.rb index a0246cf..0d51347 100644 --- a/test/functional/favorite_enterprises_controller_test.rb +++ b/test/functional/favorite_enterprises_controller_test.rb @@ -44,7 +44,7 @@ class FavoriteEnterprisesControllerTest < ActionController::TestCase end should 'actually add favorite_enterprise' do - assert_difference profile.favorite_enterprises, :count do + assert_difference 'profile.favorite_enterprises.count' do post :add, :id => favorite_enterprise.id, :confirmation => '1' assert_response :redirect @@ -64,7 +64,7 @@ class FavoriteEnterprisesControllerTest < ActionController::TestCase should 'actually remove favorite_enterprise' do profile.favorite_enterprises << favorite_enterprise - assert_difference profile.favorite_enterprises, :count, -1 do + assert_difference 'profile.favorite_enterprises.count', -1 do post :remove, :id => favorite_enterprise.id, :confirmation => '1' assert_redirected_to :action => 'index' diff --git a/test/functional/friends_controller_test.rb b/test/functional/friends_controller_test.rb index 7284321..2553303 100644 --- a/test/functional/friends_controller_test.rb +++ b/test/functional/friends_controller_test.rb @@ -45,7 +45,7 @@ class FriendsControllerTest < ActionController::TestCase should 'actually remove friend' do profile.add_friend(friend) - assert_difference Friendship, :count, -1 do + assert_difference 'Friendship.count', -1 do post :remove, :id => friend.id, :confirmation => '1' assert_redirected_to :action => 'index' end diff --git a/test/functional/invite_controller_test.rb b/test/functional/invite_controller_test.rb index 41104bd..6683079 100644 --- a/test/functional/invite_controller_test.rb +++ b/test/functional/invite_controller_test.rb @@ -12,72 +12,72 @@ class InviteControllerTest < ActionController::TestCase should 'add manually invitation of an added address with friend object on a queue and process it later' do contact_list = ContactList.create - assert_difference Delayed::Job, :count, 1 do + assert_difference 'Delayed::Job.count', 1 do post :select_friends, :profile => profile.identifier, :manual_import_addresses => "#{friend.name} <#{friend.email}>", :import_from => "manual", :mail_template => "click: ", :contact_list => contact_list.id assert_redirected_to :controller => 'profile', :action => 'friends' end - assert_difference InviteFriend, :count, 1 do + assert_difference 'InviteFriend.count', 1 do process_delayed_job_queue end end should 'add manually invitation of an added address with only email on a queue and process it later' do contact_list = ContactList.create - assert_difference Delayed::Job, :count, 1 do + assert_difference 'Delayed::Job.count', 1 do post :select_friends, :profile => profile.identifier, :manual_import_addresses => "test@test.com", :import_from => "manual", :mail_template => "click: ", :contact_list => contact_list.id assert_redirected_to :controller => 'profile', :action => 'friends' end - assert_difference InviteFriend, :count, 1 do + assert_difference 'InviteFriend.count', 1 do process_delayed_job_queue end end should 'add manually invitation of an added address with email and other format on a queue and process it later' do contact_list = ContactList.create - assert_difference Delayed::Job, :count, 1 do + assert_difference 'Delayed::Job.count', 1 do post :select_friends, :profile => profile.identifier, :manual_import_addresses => "test@test.cz.com", :import_from => "manual", :mail_template => "click: ", :contact_list => contact_list.id assert_redirected_to :controller => 'profile', :action => 'friends' end - assert_difference InviteFriend, :count, 1 do + assert_difference 'InviteFriend.count', 1 do process_delayed_job_queue end end should 'add manually invitation of more than one added address on a queue and process it later' do contact_list = ContactList.create - assert_difference Delayed::Job, :count, 1 do + assert_difference 'Delayed::Job.count', 1 do post :select_friends, :profile => profile.identifier, :manual_import_addresses => "Some Friend \r\notherperson@bleble.net\r\n", :import_from => "manual", :mail_template => "click: ", :contact_list => contact_list.id assert_redirected_to :controller => 'profile', :action => 'friends' end - assert_difference InviteFriend, :count, 2 do + assert_difference 'InviteFriend.count', 2 do process_delayed_job_queue end end should 'add manually invitation of an added address with name and e-mail on a queue and process it later' do contact_list = ContactList.create - assert_difference Delayed::Job, :count, 1 do + assert_difference 'Delayed::Job.count', 1 do post :select_friends, :profile => profile.identifier, :manual_import_addresses => "Test Name ", :import_from => "manual", :mail_template => "click: ", :contact_list => contact_list.id assert_redirected_to :controller => 'profile', :action => 'friends' end - assert_difference InviteFriend, :count, 1 do + assert_difference 'InviteFriend.count', 1 do process_delayed_job_queue end end should 'add invitation of yourself on a queue and not process it later' do contact_list = ContactList.create - assert_difference Delayed::Job, :count, 1 do + assert_difference 'Delayed::Job.count', 1 do post :select_friends, :profile => profile.identifier, :manual_import_addresses => "#{profile.name} <#{profile.user.email}>", :import_from => "manual", :mail_template => "click: ", :contact_list => contact_list.id assert_redirected_to :controller => 'profile', :action => 'friends' end - assert_no_difference InviteFriend, :count do + assert_no_difference 'InviteFriend.count' do process_delayed_job_queue end end @@ -87,12 +87,12 @@ class InviteControllerTest < ActionController::TestCase friend.person.add_friend(profile) contact_list = ContactList.create - assert_difference Delayed::Job, :count, 1 do + assert_difference 'Delayed::Job.count', 1 do post :select_friends, :profile => profile.identifier, :manual_import_addresses => "#{friend.name} <#{friend.email}>", :import_from => "manual", :mail_template => "click: ", :contact_list => contact_list.id assert_redirected_to :controller => 'profile', :action => 'friends' end - assert_no_difference InviteFriend, :count do + assert_no_difference 'InviteFriend.count' do process_delayed_job_queue end end @@ -153,7 +153,7 @@ class InviteControllerTest < ActionController::TestCase should 'create a job to get emails after choose address book' do community.add_admin(profile) contact_list = ContactList.create - assert_difference Delayed::Job, :count, 1 do + assert_difference 'Delayed::Job.count', 1 do post :select_address_book, :profile => community.identifier, :contact_list => contact_list.id, :import_from => 'gmail' end end @@ -219,7 +219,7 @@ class InviteControllerTest < ActionController::TestCase should 'destroy contact_list when cancel_fetching_emails' do contact_list = ContactList.create - assert_difference ContactList, :count, -1 do + assert_difference 'ContactList.count', -1 do get :cancel_fetching_emails, :profile => profile.identifier, :contact_list => contact_list.id end assert_redirected_to :action => 'select_address_book' diff --git a/test/functional/licenses_controller_test.rb b/test/functional/licenses_controller_test.rb index 2158c11..e06c8e3 100644 --- a/test/functional/licenses_controller_test.rb +++ b/test/functional/licenses_controller_test.rb @@ -39,7 +39,7 @@ class LicensesControllerTest < ActionController::TestCase end should 'create a new license' do - assert_difference License, :count, 1 do + assert_difference 'License.count', 1 do post :create, :license => {:name => 'GPLv3'} end end diff --git a/test/functional/mailconf_controller_test.rb b/test/functional/mailconf_controller_test.rb index ae2cf9d..f22e38c 100644 --- a/test/functional/mailconf_controller_test.rb +++ b/test/functional/mailconf_controller_test.rb @@ -84,7 +84,7 @@ class MailconfControllerTest < ActionController::TestCase should 'create task to environment admin when enable email' do login_as('ze') - assert_difference EmailActivation, :count do + assert_difference 'EmailActivation.count' do post :enable, :profile => 'ze' end end diff --git a/test/functional/manage_products_controller_test.rb b/test/functional/manage_products_controller_test.rb index b6f8893..035da79 100644 --- a/test/functional/manage_products_controller_test.rb +++ b/test/functional/manage_products_controller_test.rb @@ -49,7 +49,7 @@ class ManageProductsControllerTest < ActionController::TestCase end should "create new product" do - assert_difference Product, :count do + assert_difference 'Product.count' do post 'new', :profile => @enterprise.identifier, :product => {:name => 'test product'}, :selected_category_id => @product_category.id assert assigns(:product) assert !assigns(:product).new_record? @@ -57,7 +57,7 @@ class ManageProductsControllerTest < ActionController::TestCase end should "not create invalid product" do - assert_no_difference Product, :count do + assert_no_difference 'Product.count' do post 'new', :profile => @enterprise.identifier, :product => {:name => 'test product'} assert_response :success assert assigns(:product) @@ -132,7 +132,7 @@ class ManageProductsControllerTest < ActionController::TestCase should "destroy product" do product = fast_create(Product, :name => 'test product', :enterprise_id => @enterprise.id, :product_category_id => @product_category.id) - assert_difference Product, :count, -1 do + assert_difference 'Product.count', -1 do post 'destroy', :profile => @enterprise.identifier, :id => product.id assert_response :redirect assert_redirected_to :action => 'index' @@ -144,7 +144,7 @@ class ManageProductsControllerTest < ActionController::TestCase should "fail to destroy product" do product = fast_create(Product, :name => 'test product', :enterprise_id => @enterprise.id, :product_category_id => @product_category.id) Product.any_instance.stubs(:destroy).returns(false) - assert_no_difference Product, :count do + assert_no_difference 'Product.count' do post 'destroy', :profile => @enterprise.identifier, :id => product.id assert_response :redirect assert_redirected_to :controller => "manage_products", :profile => @enterprise.identifier, :action => 'show', :id => product.id @@ -164,7 +164,7 @@ class ManageProductsControllerTest < ActionController::TestCase should "create new product categorized" do category1 = fast_create(ProductCategory, :name => 'Category 1') category2 = fast_create(ProductCategory, :name => 'Category 2', :parent_id => category1) - assert_difference Product, :count do + assert_difference 'Product.count' do post 'new', :profile => @enterprise.identifier, :product => { :name => 'test product' }, :selected_category_id => category2.id assert_equal category2, assigns(:product).product_category end @@ -248,7 +248,7 @@ class ManageProductsControllerTest < ActionController::TestCase end should 'render redirect_via_javascript template after save' do - assert_difference Product, :count do + assert_difference 'Product.count' do post :new, :profile => @enterprise.identifier, :product => { :name => 'Invalid product' }, :selected_category_id => @product_category.id assert_template 'shared/_redirect_via_javascript' end diff --git a/test/functional/memberships_controller_test.rb b/test/functional/memberships_controller_test.rb index dff587f..a5fe9c4 100644 --- a/test/functional/memberships_controller_test.rb +++ b/test/functional/memberships_controller_test.rb @@ -40,7 +40,7 @@ class MembershipsControllerTest < ActionController::TestCase end should 'be able to create a new community' do - assert_difference Community, :count do + assert_difference 'Community.count' do post :new_community, :profile => profile.identifier, :community => { :name => 'My shiny new community', :description => 'This is a community devoted to anything interesting we find in the internet '} assert_response :redirect assert_redirected_to :action => 'index' diff --git a/test/functional/profile_controller_test.rb b/test/functional/profile_controller_test.rb index a40c07a..ef3ba2a 100644 --- a/test/functional/profile_controller_test.rb +++ b/test/functional/profile_controller_test.rb @@ -90,7 +90,7 @@ class ProfileControllerTest < ActionController::TestCase should 'actually add friend' do login_as(@profile.identifier) person = fast_create(Person) - assert_difference AddFriend, :count do + assert_difference 'AddFriend.count' do post :add, :profile => person.identifier end end @@ -408,7 +408,7 @@ class ProfileControllerTest < ActionController::TestCase community.add_member(admin) login_as profile.identifier - assert_difference AddMember, :count do + assert_difference 'AddMember.count' do post :join, :profile => community.identifier end end @@ -418,7 +418,7 @@ class ProfileControllerTest < ActionController::TestCase community.update_attribute(:closed, true) login_as profile.identifier - assert_no_difference AddMember, :count do + assert_no_difference 'AddMember.count' do post :join, :profile => community.identifier end end @@ -630,7 +630,7 @@ class ProfileControllerTest < ActionController::TestCase login_as(profile.identifier) scrap = fast_create(Scrap, :sender_id => profile.id) count = Scrap - assert_difference Scrap, :count, -1 do + assert_difference 'Scrap.count', -1 do post :remove_scrap, :profile => profile.identifier, :scrap_id => scrap.id end end @@ -639,7 +639,7 @@ class ProfileControllerTest < ActionController::TestCase login_as(profile.identifier) scrap = fast_create(Scrap, :receiver_id => profile.id) count = Scrap - assert_difference Scrap, :count, -1 do + assert_difference 'Scrap.count', -1 do post :remove_scrap, :profile => profile.identifier, :scrap_id => scrap.id end end @@ -649,7 +649,7 @@ class ProfileControllerTest < ActionController::TestCase person = fast_create(Person) scrap = fast_create(Scrap, :sender_id => person.id, :receiver_id => person.id) count = Scrap - assert_difference Scrap, :count, 0 do + assert_difference 'Scrap.count', 0 do post :remove_scrap, :profile => profile.identifier, :scrap_id => scrap.id end end @@ -1023,7 +1023,7 @@ class ProfileControllerTest < ActionController::TestCase should "the owner of activity could remove it" do login_as(profile.identifier) at = fast_create(ActionTracker::Record, :user_id => profile.id) - assert_difference ActionTracker::Record, :count, -1 do + assert_difference 'ActionTracker::Record.count', -1 do post :remove_activity, :profile => profile.identifier, :activity_id => at.id end end @@ -1034,7 +1034,7 @@ class ProfileControllerTest < ActionController::TestCase at = fast_create(ActionTracker::Record, :user_id => profile.id) atn = fast_create(ActionTrackerNotification, :profile_id => person.id, :action_tracker_id => at.id) count = ActionTrackerNotification - assert_difference ActionTrackerNotification, :count, -1 do + assert_difference 'ActionTrackerNotification.count', -1 do post :remove_activity, :profile => profile.identifier, :activity_id => at.id end end @@ -1056,13 +1056,13 @@ class ProfileControllerTest < ActionController::TestCase @controller.stubs(:user).returns(user) @controller.stubs(:profile).returns(owner) - assert_no_difference ActionTracker::Record, :count do + assert_no_difference 'ActionTracker::Record.count' do post :remove_activity, :profile => owner.identifier, :activity_id => activity.id end owner.environment.add_admin(user) - assert_difference ActionTracker::Record, :count, -1 do + assert_difference 'ActionTracker::Record.count', -1 do post :remove_activity, :profile => owner.identifier, :activity_id => activity.id end end @@ -1076,13 +1076,13 @@ class ProfileControllerTest < ActionController::TestCase @controller.stubs(:user).returns(user) @controller.stubs(:profile).returns(profile) - assert_no_difference ActionTrackerNotification, :count do + assert_no_difference 'ActionTrackerNotification.count' do post :remove_notification, :profile => profile.identifier, :activity_id => activity.id end profile.environment.add_admin(user) - assert_difference ActionTrackerNotification, :count, -1 do + assert_difference 'ActionTrackerNotification.count', -1 do post :remove_activity, :profile => profile.identifier, :activity_id => activity.id end end @@ -1300,7 +1300,7 @@ class ProfileControllerTest < ActionController::TestCase login_as(profile.identifier) @controller.stubs(:verify_recaptcha).returns(true) - assert_difference AbuseReport, :count, 1 do + assert_difference 'AbuseReport.count', 1 do post :register_report, :profile => reported.identifier, :abuse_report => {:reason => 'some reason'} end end @@ -1312,7 +1312,7 @@ class ProfileControllerTest < ActionController::TestCase environment.add_admin(profile) @controller.expects(:verify_recaptcha).never - assert_difference AbuseReport, :count, 1 do + assert_difference 'AbuseReport.count', 1 do post :register_report, :profile => reported.identifier, :abuse_report => {:reason => 'some reason'} end end @@ -1432,7 +1432,7 @@ class ProfileControllerTest < ActionController::TestCase create_user_with_permission('profile_moderator_user', 'send_mail_to_members', community) login_as('profile_moderator_user') @controller.stubs(:locale).returns('pt') - assert_difference Delayed::Job, :count, 1 do + assert_difference 'Delayed::Job.count', 1 do post :send_mail, :profile => community.identifier, :mailing => {:subject => 'Hello', :body => 'We have some news'} end end diff --git a/test/functional/profile_design_controller_test.rb b/test/functional/profile_design_controller_test.rb index f0104a5..b75762b 100644 --- a/test/functional/profile_design_controller_test.rb +++ b/test/functional/profile_design_controller_test.rb @@ -163,7 +163,7 @@ class ProfileDesignControllerTest < ActionController::TestCase end def test_should_remove_block - assert_difference Block, :count, -1 do + assert_difference 'Block.count', -1 do post :remove, :profile => 'designtestuser', :id => @b2.id assert_response :redirect assert_redirected_to :action => 'index' @@ -315,14 +315,14 @@ class ProfileDesignControllerTest < ActionController::TestCase end should 'actually add a new block' do - assert_difference Block, :count do + assert_difference 'Block.count' do post :add_block, :profile => 'designtestuser', :box_id => @box1.id, :type => RecentDocumentsBlock.name assert_redirected_to :action => 'index' end end should 'not allow to create unknown types' do - assert_no_difference Block, :count do + assert_no_difference 'Block.count' do assert_raise ArgumentError do post :add_block, :profile => 'designtestuser', :box_id => @box1.id, :type => "PleaseLetMeCrackYourSite" end diff --git a/test/functional/profile_editor_controller_test.rb b/test/functional/profile_editor_controller_test.rb index e32f2dc..ccdb899 100644 --- a/test/functional/profile_editor_controller_test.rb +++ b/test/functional/profile_editor_controller_test.rb @@ -802,7 +802,7 @@ class ProfileEditorControllerTest < ActionController::TestCase should 'be able to destroy a person' do person = fast_create(Person) - assert_difference Person, :count, -1 do + assert_difference 'Person.count', -1 do post :destroy_profile, :profile => person.identifier end end @@ -813,7 +813,7 @@ class ProfileEditorControllerTest < ActionController::TestCase person = create_user('foo').person community.add_admin(person) - assert_difference Community, :count, -1 do + assert_difference 'Community.count', -1 do post :destroy_profile, :profile => community.identifier end end @@ -826,7 +826,7 @@ class ProfileEditorControllerTest < ActionController::TestCase community.add_member(person) login_as 'foo' - assert_difference Community, :count, 0 do + assert_difference 'Community.count', 0 do post :destroy_profile, :profile => community.identifier end end @@ -837,7 +837,7 @@ class ProfileEditorControllerTest < ActionController::TestCase person = create_user('foo').person enterprise.add_admin(person) - assert_difference Enterprise, :count, -1 do + assert_difference 'Enterprise.count', -1 do post :destroy_profile, :profile => enterprise.identifier end end @@ -850,7 +850,7 @@ class ProfileEditorControllerTest < ActionController::TestCase enterprise.add_member(person) login_as('foo') - assert_difference Enterprise, :count, 0 do + assert_difference 'Enterprise.count', 0 do post :destroy_profile, :profile => enterprise.identifier end end diff --git a/test/functional/role_controller_test.rb b/test/functional/role_controller_test.rb index 61730de..10bc6f7 100644 --- a/test/functional/role_controller_test.rb +++ b/test/functional/role_controller_test.rb @@ -66,14 +66,14 @@ class RoleControllerTest < ActionController::TestCase end def test_should_create_new_role - assert_difference Role, :count do + assert_difference 'Role.count' do post 'create', :role => { :name => 'Test Role', :permissions => ["test"] } end assert_redirected_to :action => 'show', :id => Role.last.id end def test_should_not_create_new_role - assert_no_difference Role, :count do + assert_no_difference 'Role.count' do post 'create', :role => { } end assert_template :new diff --git a/test/functional/tasks_controller_test.rb b/test/functional/tasks_controller_test.rb index f7eb840..145a5dc 100644 --- a/test/functional/tasks_controller_test.rb +++ b/test/functional/tasks_controller_test.rb @@ -144,7 +144,7 @@ class TasksControllerTest < ActionController::TestCase end should 'create a ticket' do - assert_difference Ticket, :count do + assert_difference 'Ticket.count' do post :new, :profile => profile.identifier, :ticket => {:name => 'test ticket'} end end @@ -244,7 +244,7 @@ class TasksControllerTest < ActionController::TestCase a = ApproveArticle.create!(:article => article, :target => c, :requestor => person) assert_includes c.tasks, a - assert_difference article.class, :count do + assert_difference 'article.class.count' do post :close, :tasks => {a.id => {:decision => 'finish', :task => {:name => "", :highlighted => "0", :article_parent_id => c_blog2.id.to_s}}} end assert p_article = article.class.find_by_reference_article_id(article.id) diff --git a/test/integration/enterprise_registration_test.rb b/test/integration/enterprise_registration_test.rb index f380193..c2c0f00 100644 --- a/test/integration/enterprise_registration_test.rb +++ b/test/integration/enterprise_registration_test.rb @@ -37,7 +37,7 @@ class EnterpriseRegistrationTest < ActionController::IntegrationTest assert_response :success assert_tag :tag => 'form', :attributes => { :action => '/enterprise_registration', :method => 'post' }, :descendant => { :tag => 'input', :attributes => { :type => 'radio', :name => 'create_enterprise[target_id]', :value => org.id } } - assert_difference CreateEnterprise, :count do + assert_difference 'CreateEnterprise.count' do post '/enterprise_registration', :create_enterprise => data.merge(:target_id => org.id) end diff --git a/test/integration/exception_notification_test.rb b/test/integration/exception_notification_test.rb index 6bac333..aa95ad2 100644 --- a/test/integration/exception_notification_test.rb +++ b/test/integration/exception_notification_test.rb @@ -16,7 +16,7 @@ begin end should 'deliver mail notification about exceptions' do - assert_difference ActionMailer::Base.deliveries, :size do + assert_difference 'ActionMailer::Base.deliveries.size' do get '/account/signup' end end diff --git a/test/integration/manage_documents_test.rb b/test/integration/manage_documents_test.rb index 65ca224..7331fbd 100644 --- a/test/integration/manage_documents_test.rb +++ b/test/integration/manage_documents_test.rb @@ -23,7 +23,7 @@ class ManageDocumentsTest < ActionController::IntegrationTest assert_response :success assert_tag :tag => 'form', :attributes => { :action => '/myprofile/myuser/cms/new', :method => /post/i } - assert_difference Article, :count do + assert_difference 'Article.count' do post '/myprofile/myuser/cms/new', :type => 'TinyMceArticle', :article => { :name => 'my article', :body => 'this is the body of ther article'} end @@ -54,7 +54,7 @@ class ManageDocumentsTest < ActionController::IntegrationTest assert_response :success assert_tag :tag => 'form', :attributes => { :action => "/myprofile/myuser/cms/edit/#{article.id}", :method => /post/i } - assert_no_difference Article, :count do + assert_no_difference 'Article.count' do post "/myprofile/myuser/cms/edit/#{article.id}", :article => { :name => 'my article', :body => 'this is the body of the article'} end diff --git a/test/integration/signup_test.rb b/test/integration/signup_test.rb index 33c85c8..254c266 100644 --- a/test/integration/signup_test.rb +++ b/test/integration/signup_test.rb @@ -8,7 +8,7 @@ class SignupTest < ActionController::IntegrationTest end def test_signup_form_submission_must_be_blocked_for_fast_bots - assert_no_difference User, :count do + assert_no_difference 'User.count' do registering_with_bot_test 5, 1 end assert_template 'signup' @@ -16,7 +16,7 @@ class SignupTest < ActionController::IntegrationTest end def test_signup_form_submission_must_not_block_after_min_signup_delay - assert_difference User, :count, 1 do + assert_difference 'User.count', 1 do registering_with_bot_test 1, 2 end end diff --git a/test/unit/add_friend_test.rb b/test/unit/add_friend_test.rb index 3b17f64..e373990 100644 --- a/test/unit/add_friend_test.rb +++ b/test/unit/add_friend_test.rb @@ -16,7 +16,7 @@ class AddFriendTest < ActiveSupport::TestCase task = fast_create(AddFriend, :requestor_id => person1.id, :target_id => person2.id, :target_type => 'Person') - assert_difference Friendship, :count, 2 do + assert_difference 'Friendship.count', 2 do task.finish end person1.friends.reload @@ -32,7 +32,7 @@ class AddFriendTest < ActiveSupport::TestCase task.group_for_friend = 'friend2' assert task.save - assert_difference Friendship, :count, 2 do + assert_difference 'Friendship.count', 2 do task.finish end diff --git a/test/unit/approve_article_test.rb b/test/unit/approve_article_test.rb index 08b9221..5900cc0 100644 --- a/test/unit/approve_article_test.rb +++ b/test/unit/approve_article_test.rb @@ -28,7 +28,7 @@ class ApproveArticleTest < ActiveSupport::TestCase should 'create an article with the same class as original when finished' do a = create(ApproveArticle, :article => article, :target => community, :requestor => profile) - assert_difference article.class, :count do + assert_difference 'article.class.count' do a.finish end end @@ -74,7 +74,7 @@ class ApproveArticleTest < ActiveSupport::TestCase should 'handle blank names' do a = create(ApproveArticle, :name => '', :article => article, :target => community, :requestor => profile) - assert_difference article.class, :count do + assert_difference 'article.class.count' do a.finish end end @@ -280,7 +280,7 @@ class ApproveArticleTest < ActiveSupport::TestCase a.finish assert_equal 2, ActionTracker::Record.count - assert_no_difference ActionTracker::Record, :count do + assert_no_difference 'ActionTracker::Record.count' do published = article1.class.last published.name = 'foo';published.save! @@ -374,18 +374,18 @@ class ApproveArticleTest < ActiveSupport::TestCase should 'approve an event' do event = fast_create(Event, :profile_id => profile.id, :name => 'Event test', :slug => 'event-test', :abstract => 'Lead of article', :body => 'This is my event') task = create(ApproveArticle, :name => 'Event test', :article => event, :target => community, :requestor => profile) - assert_difference event.class, :count do + assert_difference 'event.class.count' do task.finish end end should 'approve same article twice changing its name' do task1 = create(ApproveArticle, :article => article, :target => community, :requestor => profile) - assert_difference article.class, :count do + assert_difference 'article.class.count' do task1.finish end task2 = create(ApproveArticle, :name => article.name + ' v2', :article => article, :target => community, :requestor => profile) - assert_difference article.class, :count do + assert_difference 'article.class.count' do assert_nothing_raised ActiveRecord::RecordInvalid do task2.finish end @@ -394,11 +394,11 @@ class ApproveArticleTest < ActiveSupport::TestCase should 'not approve same article twice if not changing its name' do task1 = create(ApproveArticle, :article => article, :target => community, :requestor => profile) - assert_difference article.class, :count do + assert_difference 'article.class.count' do task1.finish end task2 = create(ApproveArticle, :article => article, :target => community, :requestor => profile) - assert_no_difference article.class, :count do + assert_no_difference 'article.class.count' do assert_raises ActiveRecord::RecordInvalid do task2.finish end diff --git a/test/unit/approve_comment_test.rb b/test/unit/approve_comment_test.rb index 4d9fab8..5d2d226 100644 --- a/test/unit/approve_comment_test.rb +++ b/test/unit/approve_comment_test.rb @@ -71,7 +71,7 @@ class ApproveCommentTest < ActiveSupport::TestCase should 'create comment when finishing task' do approve_comment = ApproveComment.create!(:target => @community, :comment_attributes => @comment.attributes.to_json, :requestor => @profile) - assert_difference @article.comments, :count, 1 do + assert_difference '@article.comments.count', 1 do approve_comment.finish end end @@ -80,7 +80,7 @@ class ApproveCommentTest < ActiveSupport::TestCase now = Time.now.in_time_zone - 10 @comment.created_at = now approve_comment = ApproveComment.create!(:target => @community, :comment_attributes => @comment.attributes.to_json, :requestor => @profile) - assert_difference @article.comments, :count, 1 do + assert_difference '@article.comments.count', 1 do approve_comment.finish end comment = Comment.last diff --git a/test/unit/article_categorization_test.rb b/test/unit/article_categorization_test.rb index f31846e..604a235 100644 --- a/test/unit/article_categorization_test.rb +++ b/test/unit/article_categorization_test.rb @@ -28,7 +28,7 @@ class ArticleCategorizationTest < ActiveSupport::TestCase p = create_user('testuser').person a = p.articles.create!(:name => 'test') - assert_difference ArticleCategorization, :count, 2 do + assert_difference 'ArticleCategorization.count(:category_id)', 2 do ArticleCategorization.add_category_to_article(c2, a) end @@ -43,7 +43,7 @@ class ArticleCategorizationTest < ActiveSupport::TestCase p = create_user('testuser').person a = p.articles.create!(:name => 'test') - assert_difference ArticleCategorization, :count, 3 do + assert_difference 'ArticleCategorization.count(:category_id)', 3 do ArticleCategorization.add_category_to_article(c2, a) ArticleCategorization.add_category_to_article(c3, a) end @@ -60,7 +60,7 @@ class ArticleCategorizationTest < ActiveSupport::TestCase ArticleCategorization.add_category_to_article(c2, a) ArticleCategorization.add_category_to_article(c3, a) - assert_difference ArticleCategorization, :count, -3 do + assert_difference 'ArticleCategorization.count(:category_id)', -3 do ArticleCategorization.remove_all_for(a) end end @@ -72,7 +72,7 @@ class ArticleCategorizationTest < ActiveSupport::TestCase p = create_user('testuser').person a = p.articles.create!(:name => 'test') - assert_difference ArticleCategorization, :count, 2 do + assert_difference 'ArticleCategorization.count(:category_id)', 2 do ArticleCategorization.add_category_to_article(c2, a) ArticleCategorization.add_category_to_article(c1, a) end diff --git a/test/unit/article_test.rb b/test/unit/article_test.rb index ae93ef7..ec02bdd 100644 --- a/test/unit/article_test.rb +++ b/test/unit/article_test.rb @@ -308,10 +308,10 @@ class ArticleTest < ActiveSupport::TestCase end should 'remove comments when removing article' do - assert_no_difference Comment, :count do + assert_no_difference 'Comment.count' do a = create(Article, :name => 'test article', :profile_id => profile.id) - assert_difference Comment, :count, 1 do + assert_difference 'Comment.count', 1 do comment = a.comments.build comment.author = profile comment.title = 'test comment' @@ -975,7 +975,7 @@ class ArticleTest < ActiveSupport::TestCase should 'destroy activity when a published article is removed' do a = create(TinyMceArticle, :profile_id => profile.id) - assert_difference ActionTracker::Record, :count, -1 do + assert_difference 'ActionTracker::Record.count', -1 do a.destroy end end @@ -1124,7 +1124,7 @@ class ArticleTest < ActiveSupport::TestCase process_delayed_job_queue assert_equal 2, ActionTrackerNotification.find_all_by_action_tracker_id(activity.id).count - assert_difference ActionTrackerNotification, :count, -2 do + assert_difference 'ActionTrackerNotification.count', -2 do article.destroy end @@ -1147,7 +1147,7 @@ class ArticleTest < ActiveSupport::TestCase process_delayed_job_queue assert_equal 3, ActionTrackerNotification.find_all_by_action_tracker_id(activity.id).count - assert_difference ActionTrackerNotification, :count, -3 do + assert_difference 'ActionTrackerNotification.count', -3 do article.destroy end @@ -1767,7 +1767,7 @@ class ArticleTest < ActiveSupport::TestCase end should 'save image on create article' do - assert_difference Article, :count do + assert_difference 'Article.count' do p = create(Article, :name => 'test', :image_builder => { :uploaded_data => fixture_file_upload('/files/rails.png', 'image/png') }, :profile_id => @profile.id) diff --git a/test/unit/blog_test.rb b/test/unit/blog_test.rb index aa5f9be..9ca5619 100644 --- a/test/unit/blog_test.rb +++ b/test/unit/blog_test.rb @@ -125,7 +125,7 @@ class BlogTest < ActiveSupport::TestCase p = create_user('testuser').person blog = create(Blog, :name => 'Blog test', :profile => p, :external_feed_builder => {:enabled => true, :address => "http://bli.org/feed"}) assert blog.external_feed - assert_difference ExternalFeed, :count, -1 do + assert_difference 'ExternalFeed.count', -1 do blog.destroy end end diff --git a/test/unit/category_test.rb b/test/unit/category_test.rb index faa23b7..281e233 100644 --- a/test/unit/category_test.rb +++ b/test/unit/category_test.rb @@ -400,7 +400,7 @@ class CategoryTest < ActiveSupport::TestCase end should 'have image' do - assert_difference Category, :count do + assert_difference 'Category.count' do c = create(Category, :name => 'test category1', :environment => Environment.default, :image_builder => { :uploaded_data => fixture_file_upload('/files/rails.png', 'image/png') }) diff --git a/test/unit/comment_notifier_test.rb b/test/unit/comment_notifier_test.rb index 128672b..157a0c9 100644 --- a/test/unit/comment_notifier_test.rb +++ b/test/unit/comment_notifier_test.rb @@ -14,7 +14,7 @@ class CommentNotifierTest < ActiveSupport::TestCase end should 'deliver mail after make an article comment' do - assert_difference ActionMailer::Base.deliveries, :size do + assert_difference 'ActionMailer::Base.deliveries.size' do create_comment_and_notify(:author => @author, :title => 'test comment', :body => 'you suck!', :source => @article ) end end @@ -40,7 +40,7 @@ class CommentNotifierTest < ActiveSupport::TestCase should 'not deliver mail if notify comments is false' do @article.update_attribute(:notify_comments, false) - assert_no_difference ActionMailer::Base.deliveries, :size do + assert_no_difference 'ActionMailer::Base.deliveries.size' do create_comment_and_notify(:author => @author, :title => 'test comment', :body => 'you suck!', :source => @article) end end @@ -61,7 +61,7 @@ class CommentNotifierTest < ActiveSupport::TestCase community = fast_create(Community) assert_equal [], community.notification_emails article = fast_create(Article, :name => 'Article test', :profile_id => community.id, :notify_comments => true) - assert_no_difference ActionMailer::Base.deliveries, :size do + assert_no_difference 'ActionMailer::Base.deliveries.size' do create_comment_and_notify(:author => @author, :title => 'test comment', :body => 'there is no addresses to send notification', :source => article) end end diff --git a/test/unit/community_test.rb b/test/unit/community_test.rb index 553c77d..1e4b71c 100644 --- a/test/unit/community_test.rb +++ b/test/unit/community_test.rb @@ -170,11 +170,11 @@ class CommunityTest < ActiveSupport::TestCase env.enable('admin_must_approve_new_communities') person.stubs(:notification_emails).returns(['sample@example.org']) - assert_difference CreateCommunity, :count do + assert_difference 'CreateCommunity.count' do Community.create_after_moderation(person, {:environment => env, :name => 'Example'}) end - assert_no_difference Community, :count do + assert_no_difference 'Community.count' do Community.create_after_moderation(person, {:environment => env, :name => 'Example'}) end end @@ -183,11 +183,11 @@ class CommunityTest < ActiveSupport::TestCase env = Environment.default env.disable('admin_must_approve_new_communities') - assert_difference Community, :count do + assert_difference 'Community.count' do Community.create_after_moderation(person, {:environment => env, :name => 'Example 1'}) end - assert_no_difference CreateCommunity, :count do + assert_no_difference 'CreateCommunity.count' do Community.create_after_moderation(person, {:environment => env, :name => 'Example 2'}) end end @@ -197,7 +197,7 @@ class CommunityTest < ActiveSupport::TestCase community.closed = true community.save - assert_no_difference AddMember, :count do + assert_no_difference 'AddMember.count' do community.add_member(person) end assert person.is_member_of?(community) @@ -206,7 +206,7 @@ class CommunityTest < ActiveSupport::TestCase should 'set as member without task if organization is not closed and has no members' do community = fast_create(Community) - assert_no_difference AddMember, :count do + assert_no_difference 'AddMember.count' do community.add_member(person) end assert person.is_member_of?(community) @@ -221,11 +221,11 @@ class CommunityTest < ActiveSupport::TestCase community.stubs(:notification_emails).returns(['sample@example.org']) - assert_difference AddMember, :count do + assert_difference 'AddMember.count' do community.add_member(person) end - assert_no_difference AddMember, :count do + assert_no_difference 'AddMember.count' do community.add_member(person) end end @@ -271,7 +271,7 @@ class CommunityTest < ActiveSupport::TestCase RoleAssignment.delete_all ActionTrackerNotification.delete_all - assert_difference(ActionTrackerNotification, :count, 5) do + assert_difference 'ActionTrackerNotification.count', 5 do community.add_member(p1) process_delayed_job_queue community.add_member(p3) @@ -364,7 +364,7 @@ class CommunityTest < ActiveSupport::TestCase community = fast_create(Community) UserStampSweeper.any_instance.expects(:current_user).returns(person).at_least_once - assert_difference ActionTracker::Record, :count, 1 do + assert_difference 'ActionTracker::Record.count', 1 do article = create(TinyMceArticle, :profile => community, :name => 'An article about free software') end diff --git a/test/unit/create_community_test.rb b/test/unit/create_community_test.rb index bccc6b5..041e937 100644 --- a/test/unit/create_community_test.rb +++ b/test/unit/create_community_test.rb @@ -34,7 +34,7 @@ class CreateCommunityTest < ActiveSupport::TestCase :target => Environment.default, }) - assert_difference Community, :count do + assert_difference 'Community.count' do task.finish end @@ -76,7 +76,7 @@ class CreateCommunityTest < ActiveSupport::TestCase }) assert_equal 'rails.png', task.image.filename - assert_difference Community, :count do + assert_difference 'Community.count' do task.finish end diff --git a/test/unit/enterprise_test.rb b/test/unit/enterprise_test.rb index 8a2ee8f..fddbdf9 100644 --- a/test/unit/enterprise_test.rb +++ b/test/unit/enterprise_test.rb @@ -66,7 +66,7 @@ class EnterpriseTest < ActiveSupport::TestCase create(Product, :enterprise => e, :name => 'One product', :product_category => @product_category) create(Product, :enterprise => e, :name => 'Another product', :product_category => @product_category) - assert_difference Product, :count, -2 do + assert_difference 'Product.count', -2 do e.destroy end end @@ -215,7 +215,7 @@ class EnterpriseTest < ActiveSupport::TestCase end should 'not create activation task when enabled = true' do - assert_no_difference EnterpriseActivation, :count do + assert_no_difference 'EnterpriseActivation.count' do fast_create(Enterprise, :name => 'test enteprise', :identifier => 'test_ent', :enabled => true) end end diff --git a/test/unit/environment_mailing_test.rb b/test/unit/environment_mailing_test.rb index 2c38d77..25bdc8d 100644 --- a/test/unit/environment_mailing_test.rb +++ b/test/unit/environment_mailing_test.rb @@ -61,7 +61,7 @@ class EnvironmentMailingTest < ActiveSupport::TestCase should 'create mailing sent to each recipient after delivering mailing' do mailing = create_mailing(environment, :person => person_1) - assert_difference MailingSent, :count, 2 do + assert_difference 'MailingSent.count', 2 do process_delayed_job_queue end end diff --git a/test/unit/image_test.rb b/test/unit/image_test.rb index 8745ae4..40a6d2d 100644 --- a/test/unit/image_test.rb +++ b/test/unit/image_test.rb @@ -92,7 +92,7 @@ class ImageTest < ActiveSupport::TestCase should 'not create a background job for an image that is not thumbnailable' do # this test verifies whether it created background jobs also for the # thumbnails! - assert_no_difference Delayed::Job, :count do + assert_no_difference 'Delayed::Job.count' do image = build(Image, :uploaded_data => fixture_file_upload('/files/rails.png', 'image/png')) image.stubs(:thumbnailable?).returns(false) image.save! diff --git a/test/unit/invitation_test.rb b/test/unit/invitation_test.rb index 4391c9f..9728c50 100644 --- a/test/unit/invitation_test.rb +++ b/test/unit/invitation_test.rb @@ -45,7 +45,7 @@ class InvitationTest < ActiveSupport::TestCase person = fast_create(Person) person.user = User.new(:email => 'current_user@email.invalid') - assert_difference InviteFriend, :count do + assert_difference 'InviteFriend.count' do Invitation.invite(person, ['sadam@garotos.podres'], 'hello friend ', person) end end @@ -55,7 +55,7 @@ class InvitationTest < ActiveSupport::TestCase person.user = User.new(:email => 'current_user@email.invalid') community = fast_create(Community) - assert_difference InviteMember, :count do + assert_difference 'InviteMember.count' do Invitation.invite(person, ['sadam@garotos.podres'], 'hello friend ', community) end end diff --git a/test/unit/invite_friend_test.rb b/test/unit/invite_friend_test.rb index 022691c..b505061 100644 --- a/test/unit/invite_friend_test.rb +++ b/test/unit/invite_friend_test.rb @@ -12,7 +12,7 @@ class InviteFriendTest < ActiveSupport::TestCase task = InviteFriend.create!(:person => p1, :friend => p2) - assert_difference Friendship, :count, 2 do + assert_difference 'Friendship.count', 2 do task.finish end diff --git a/test/unit/mailing_job_test.rb b/test/unit/mailing_job_test.rb index 71e2d7f..bbde0c1 100644 --- a/test/unit/mailing_job_test.rb +++ b/test/unit/mailing_job_test.rb @@ -10,7 +10,7 @@ class MailingJobTest < ActiveSupport::TestCase attr_reader :environment should 'create delayed job' do - assert_difference Delayed::Job, :count, 1 do + assert_difference 'Delayed::Job.count', 1 do mailing = @environment.mailings.build(:subject => 'Hello', :body => 'We have some news') mailing.person = @person_1 mailing.save! diff --git a/test/unit/organization_mailing_test.rb b/test/unit/organization_mailing_test.rb index dd26c31..ea79525 100644 --- a/test/unit/organization_mailing_test.rb +++ b/test/unit/organization_mailing_test.rb @@ -74,7 +74,7 @@ class OrganizationMailingTest < ActiveSupport::TestCase should 'create mailing sent to each recipient after delivering mailing' do mailing = create(OrganizationMailing, :source => community, :subject => 'Hello', :body => 'We have some news', :person => person) - assert_difference MailingSent, :count, 2 do + assert_difference 'MailingSent.count', 2 do process_delayed_job_queue end end diff --git a/test/unit/person_test.rb b/test/unit/person_test.rb index 355d090..d0208fd 100644 --- a/test/unit/person_test.rb +++ b/test/unit/person_test.rb @@ -260,7 +260,7 @@ class PersonTest < ActiveSupport::TestCase p2 = create_user('testuser2').person p1.add_friend(p2, 'friends') - assert_difference Friendship, :count, -1 do + assert_difference 'Friendship.count', -1 do p1.remove_friend(p2) end assert_not_includes p1.friends(true), p2 @@ -272,7 +272,7 @@ class PersonTest < ActiveSupport::TestCase p1.add_friend(p2, 'friends') p2.add_friend(p1, 'friends') - assert_difference Friendship, :count, -2 do + assert_difference 'Friendship.count', -2 do p1.destroy end assert_not_includes p2.friends(true), p1 @@ -280,7 +280,7 @@ class PersonTest < ActiveSupport::TestCase should 'destroy use when person is destroyed' do person = create_user('testuser').person - assert_difference User, :count, -1 do + assert_difference 'User.count', -1 do person.destroy end end @@ -374,7 +374,7 @@ class PersonTest < ActiveSupport::TestCase should 'destroy all task that it requested when destroyed' do p = create_user('test_profile').person - assert_no_difference Task, :count do + assert_no_difference 'Task.count' do create(Task, :requestor => p) p.destroy end @@ -835,7 +835,7 @@ class PersonTest < ActiveSupport::TestCase action_tracker = fast_create(ActionTracker::Record, :user_id => p1.id) ActionTrackerNotification.delete_all Delayed::Job.destroy_all - assert_difference ActionTrackerNotification, :count, 3 do + assert_difference 'ActionTrackerNotification.count', 3 do Person.notify_activity(action_tracker) process_delayed_job_queue end @@ -858,7 +858,7 @@ class PersonTest < ActiveSupport::TestCase action_tracker = fast_create(ActionTracker::Record) - assert_difference(Delayed::Job, :count, 1) do + assert_difference 'Delayed::Job.count', 1 do Person.notify_activity(action_tracker) end end @@ -878,10 +878,10 @@ class PersonTest < ActiveSupport::TestCase action_tracker = fast_create(ActionTracker::Record, :user_id => p1.id) Delayed::Job.delete_all - assert_difference(Delayed::Job, :count, 1) do + assert_difference 'Delayed::Job.count', 1 do Person.notify_activity(action_tracker) end - assert_difference(ActionTrackerNotification, :count, 3) do + assert_difference 'ActionTrackerNotification.count', 3 do process_delayed_job_queue end end @@ -904,7 +904,7 @@ class PersonTest < ActiveSupport::TestCase action_tracker.target = community action_tracker.save! ActionTrackerNotification.delete_all - assert_difference(ActionTrackerNotification, :count, 3) do + assert_difference 'ActionTrackerNotification.count', 3 do Person.notify_activity(action_tracker) process_delayed_job_queue end @@ -937,7 +937,7 @@ class PersonTest < ActiveSupport::TestCase article.stubs(:profile).returns(community) ActionTrackerNotification.delete_all - assert_difference(Delayed::Job, :count, 1) do + assert_difference 'Delayed::Job.count', 1 do Person.notify_activity(action_tracker) end ActionTrackerNotification.all.map{|a|a.profile}.map do |profile| @@ -1186,12 +1186,12 @@ class PersonTest < ActiveSupport::TestCase profile = fast_create(Profile) abuse_report1 = build(AbuseReport, :reason => 'some reason') - assert_difference AbuseComplaint, :count, 1 do + assert_difference 'AbuseComplaint.count', 1 do p1.register_report(abuse_report1, profile) end abuse_report2 = build(AbuseReport, :reason => 'some reason') - assert_no_difference AbuseComplaint, :count do + assert_no_difference 'AbuseComplaint.count' do p2.register_report(abuse_report2, profile) end diff --git a/test/unit/product_test.rb b/test/unit/product_test.rb index 7ac1aa5..6066860 100644 --- a/test/unit/product_test.rb +++ b/test/unit/product_test.rb @@ -24,7 +24,7 @@ class ProductTest < ActiveSupport::TestCase end should 'create product' do - assert_difference Product, :count do + assert_difference 'Product.count' do p = build(Product, :name => 'test product1', :product_category => @product_category, :enterprise_id => @profile.id) assert p.save end @@ -32,7 +32,7 @@ class ProductTest < ActiveSupport::TestCase should 'destroy product' do p = fast_create(Product, :name => 'test product2', :product_category_id => @product_category.id) - assert_difference Product, :count, -1 do + assert_difference 'Product.count', -1 do p.destroy end end @@ -81,7 +81,7 @@ class ProductTest < ActiveSupport::TestCase end should 'save image on create product' do - assert_difference Product, :count do + assert_difference 'Product.count' do p = create(Product, :name => 'test product1', :product_category => @product_category, :image_builder => { :uploaded_data => fixture_file_upload('/files/rails.png', 'image/png') }, :enterprise_id => @profile.id) @@ -270,7 +270,7 @@ class ProductTest < ActiveSupport::TestCase services_category = fast_create(ProductCategory, :name => 'Services') input2 = fast_create(Input, :product_id => product.id, :product_category_id => services_category.id) - assert_difference Input, :count, -2 do + assert_difference 'Input.count', -2 do product.destroy end end @@ -402,7 +402,7 @@ class ProductTest < ActiveSupport::TestCase cost = fast_create(ProductionCost, :owner_id => Environment.default.id, :owner_type => 'Environment') price_detail = product.price_details.create(:production_cost_id => cost.id, :price => 10) - assert_difference PriceDetail, :count, -1 do + assert_difference 'PriceDetail.count', -1 do product.destroy end end diff --git a/test/unit/profile_categorization_test.rb b/test/unit/profile_categorization_test.rb index de7cba1..78e4b5b 100644 --- a/test/unit/profile_categorization_test.rb +++ b/test/unit/profile_categorization_test.rb @@ -20,7 +20,7 @@ class ProfileCategorizationTest < ActiveSupport::TestCase p = create_user('testuser').person - assert_difference ProfileCategorization, :count, 2 do + assert_difference 'ProfileCategorization.count', 2 do ProfileCategorization.add_category_to_profile(c2, p) end @@ -38,7 +38,7 @@ class ProfileCategorizationTest < ActiveSupport::TestCase p = create_user('testuser').person - assert_difference ProfileCategorization, :count, 3 do + assert_difference 'ProfileCategorization.count', 3 do ProfileCategorization.add_category_to_profile(c2, p) ProfileCategorization.add_category_to_profile(c3, p) end @@ -58,7 +58,7 @@ class ProfileCategorizationTest < ActiveSupport::TestCase ProfileCategorization.add_category_to_profile(c2, p) ProfileCategorization.add_category_to_profile(c3, p) - assert_difference ProfileCategorization, :count, -3 do + assert_difference 'ProfileCategorization.count', -3 do ProfileCategorization.remove_all_for(p) end end diff --git a/test/unit/profile_test.rb b/test/unit/profile_test.rb index 9826a03..d010d7d 100644 --- a/test/unit/profile_test.rb +++ b/test/unit/profile_test.rb @@ -1134,7 +1134,7 @@ class ProfileTest < ActiveSupport::TestCase should 'destroy tasks requested to it when destroyed' do p = Profile.create!(:name => 'test_profile', :identifier => 'test_profile') - assert_no_difference Task, :count do + assert_no_difference 'Task.count' do Task.create(:target => p) p.destroy end diff --git a/test/unit/scrap_notifier_test.rb b/test/unit/scrap_notifier_test.rb index 320051f..ed62806 100644 --- a/test/unit/scrap_notifier_test.rb +++ b/test/unit/scrap_notifier_test.rb @@ -13,14 +13,14 @@ class ScrapNotifierTest < ActiveSupport::TestCase end should 'deliver mail after leave scrap' do - assert_difference ActionMailer::Base.deliveries, :size do + assert_difference 'ActionMailer::Base.deliveries.size' do Scrap.create!(:sender_id => @sender.id, :receiver_id => @receiver.id, :content => 'Hi man!') end end should 'deliver mail even if it is a reply' do s = Scrap.create!(:sender_id => @sender.id, :receiver_id => @receiver.id, :content => 'Hi man!') - assert_difference ActionMailer::Base.deliveries, :size do + assert_difference 'ActionMailer::Base.deliveries.size' do s.replies << Scrap.new(:sender_id => @sender.id, :receiver_id => @receiver.id, :content => 'Hi again man!') end end @@ -50,7 +50,7 @@ class ScrapNotifierTest < ActiveSupport::TestCase end should 'not deliver mail if notify receiver and sender are the same person' do - assert_no_difference ActionMailer::Base.deliveries, :size do + assert_no_difference 'ActionMailer::Base.deliveries.size' do Scrap.create!(:sender_id => @sender.id, :receiver_id => @sender.id, :content => 'Hi myself!') end end @@ -59,7 +59,7 @@ class ScrapNotifierTest < ActiveSupport::TestCase community = fast_create(Community) person = fast_create(Person) scrap = fast_create(Scrap, :receiver_id => community.id, :sender_id => @sender.id) - assert_no_difference ActionMailer::Base.deliveries, :size do + assert_no_difference 'ActionMailer::Base.deliveries.size' do Scrap.create!(:sender_id => person, :receiver_id => @sender.id, :scrap_id => scrap.id, :content => 'Hi myself!') end end diff --git a/test/unit/scrap_test.rb b/test/unit/scrap_test.rb index db52d47..fda3472 100644 --- a/test/unit/scrap_test.rb +++ b/test/unit/scrap_test.rb @@ -288,7 +288,7 @@ class ScrapTest < ActiveSupport::TestCase should 'create activity with reply_scrap_on_self when top_root scrap receiver is the same as sender' do s, r = fast_create(Person), fast_create(Person) root = fast_create(Scrap, :sender_id => s.id, :receiver_id => r.id) - assert_difference ActionTracker::Record, :count, 1 do + assert_difference 'ActionTracker::Record.count', 1 do reply = create(Scrap, :sender => r, :receiver => s, :scrap_id => root.id, :content => 'sample') end activity = ActionTracker::Record.last diff --git a/test/unit/task_test.rb b/test/unit/task_test.rb index 7adf150..58c7759 100644 --- a/test/unit/task_test.rb +++ b/test/unit/task_test.rb @@ -202,7 +202,7 @@ class TaskTest < ActiveSupport::TestCase should 'be destroyed when requestor destroyed' do user = create_user('test_user').person - assert_no_difference Task, :count do + assert_no_difference 'Task.count' do create(Task, :requestor => user) user.destroy end diff --git a/test/unit/textile_article_test.rb b/test/unit/textile_article_test.rb index 3daa67a..e41ee9a 100644 --- a/test/unit/textile_article_test.rb +++ b/test/unit/textile_article_test.rb @@ -41,7 +41,7 @@ class TextileArticleTest < ActiveSupport::TestCase should 'not group trackers activity of article\'s creation' do profile = fast_create(Profile) - assert_difference ActionTracker::Record, :count, 3 do + assert_difference 'ActionTracker::Record.count', 3 do create TextileArticle, :name => 'bar', :profile_id => profile.id, :published => true create TextileArticle, :name => 'another bar', :profile_id => profile.id, :published => true create TextileArticle, :name => 'another bar', :profile_id => fast_create(Profile).id, :published => true @@ -54,7 +54,7 @@ class TextileArticleTest < ActiveSupport::TestCase article = create(TextileArticle, :profile_id => profile.id) time = article.activity.updated_at Time.stubs(:now).returns(time + 1.day) - assert_no_difference ActionTracker::Record, :count do + assert_no_difference 'ActionTracker::Record.count' do article.name = 'foo' article.save! end @@ -65,7 +65,7 @@ class TextileArticleTest < ActiveSupport::TestCase ActionTracker::Record.delete_all a1 = create TextileArticle, :name => 'bar', :profile_id => fast_create(Profile).id, :published => true a2 = create TextileArticle, :name => 'another bar', :profile_id => fast_create(Profile).id, :published => true - assert_no_difference ActionTracker::Record, :count do + assert_no_difference 'ActionTracker::Record.count' do a1.name = 'foo';a1.save! a2.name = 'another foo';a2.save! end @@ -74,7 +74,7 @@ class TextileArticleTest < ActiveSupport::TestCase should 'remove activity after destroying article' do ActionTracker::Record.delete_all a = create TextileArticle, :name => 'bar', :profile_id => fast_create(Profile).id, :published => true - assert_difference ActionTracker::Record, :count, -1 do + assert_difference 'ActionTracker::Record.count', -1 do a.destroy end end @@ -84,7 +84,7 @@ class TextileArticleTest < ActiveSupport::TestCase a1 = create TextileArticle, :name => 'bar', :profile_id => fast_create(Profile).id, :published => true a2 = create TextileArticle, :name => 'another bar', :profile_id => fast_create(Profile).id, :published => true assert_equal 2, ActionTracker::Record.count - assert_difference ActionTracker::Record, :count, -2 do + assert_difference 'ActionTracker::Record.count', -2 do a1.destroy a2.destroy end diff --git a/test/unit/tiny_mce_article_test.rb b/test/unit/tiny_mce_article_test.rb index 34f52c7..b7ba9a4 100644 --- a/test/unit/tiny_mce_article_test.rb +++ b/test/unit/tiny_mce_article_test.rb @@ -145,7 +145,7 @@ class TinyMceArticleTest < ActiveSupport::TestCase article = create(TinyMceArticle, :profile_id => profile.id) time = article.activity.updated_at Time.stubs(:now).returns(time + 1.day) - assert_no_difference ActionTracker::Record, :count do + assert_no_difference 'ActionTracker::Record.count' do article.name = 'foo' article.save! end @@ -156,7 +156,7 @@ class TinyMceArticleTest < ActiveSupport::TestCase ActionTracker::Record.delete_all a1 = create TinyMceArticle, :name => 'bar', :profile_id => fast_create(Profile).id, :published => true a2 = create TinyMceArticle, :name => 'another bar', :profile_id => fast_create(Profile).id, :published => true - assert_no_difference ActionTracker::Record, :count do + assert_no_difference 'ActionTracker::Record.count' do a1.name = 'foo';a1.save! a2.name = 'another foo';a2.save! end @@ -166,7 +166,7 @@ class TinyMceArticleTest < ActiveSupport::TestCase ActionTracker::Record.delete_all a1 = create TinyMceArticle, :name => 'bar', :profile_id => fast_create(Profile).id, :published => true a2 = create TinyMceArticle, :name => 'another bar', :profile_id => fast_create(Profile).id, :published => true - assert_difference ActionTracker::Record, :count, -2 do + assert_difference 'ActionTracker::Record.count', -2 do a1.destroy a2.destroy end diff --git a/test/unit/user_activation_job_test.rb b/test/unit/user_activation_job_test.rb index 1f657b1..893468f 100644 --- a/test/unit/user_activation_job_test.rb +++ b/test/unit/user_activation_job_test.rb @@ -3,7 +3,7 @@ require File.dirname(__FILE__) + '/../test_helper' class NotifyActivityToProfilesJobTest < ActiveSupport::TestCase should 'create job on user creation' do - assert_difference Delayed::Job, :count, 1 do + assert_difference 'Delayed::Job.count', 1 do user = new_user :login => 'test1' assert_equal user.id, YAML.load(Delayed::Job.last.handler).user_id end @@ -13,7 +13,7 @@ class NotifyActivityToProfilesJobTest < ActiveSupport::TestCase should 'destroy user if not activated' do user = new_user :login => 'test2' job = UserActivationJob.new(user.id) - assert_difference User, :count, -1 do + assert_difference 'User.count', -1 do job.perform process_delayed_job_queue end @@ -23,7 +23,7 @@ class NotifyActivityToProfilesJobTest < ActiveSupport::TestCase user = new_user :login => 'test3' user.activate job = UserActivationJob.new(user.id) - assert_no_difference User, :count do + assert_no_difference 'User.count' do job.perform process_delayed_job_queue end diff --git a/test/unit/user_mailer_test.rb b/test/unit/user_mailer_test.rb index 7b60c76..556ff25 100644 --- a/test/unit/user_mailer_test.rb +++ b/test/unit/user_mailer_test.rb @@ -12,7 +12,7 @@ class UserMailerTest < ActiveSupport::TestCase end should 'deliver activation email notify' do - assert_difference ActionMailer::Base.deliveries, :size do + assert_difference 'ActionMailer::Base.deliveries.size' do u = create_user('some-user') UserMailer.activation_email_notify(u).deliver end diff --git a/test/unit/user_test.rb b/test/unit/user_test.rb index 98dd897..0dd0fb4 100644 --- a/test/unit/user_test.rb +++ b/test/unit/user_test.rb @@ -8,35 +8,35 @@ class UserTest < ActiveSupport::TestCase fixtures :users, :environments def test_should_create_user - assert_difference User, :count do + assert_difference 'User.count' do user = new_user assert !user.new_record?, "#{user.errors.full_messages.to_sentence}" end end def test_should_require_login - assert_no_difference User, :count do + assert_no_difference 'User.count' do u = new_user(:login => nil) assert u.errors[:login].present? end end def test_should_require_password - assert_no_difference User, :count do + assert_no_difference 'User.count' do u = new_user(:password => nil) assert u.errors[:password].present? end end def test_should_require_password_confirmation - assert_no_difference User, :count do + assert_no_difference 'User.count' do u = new_user(:password_confirmation => nil) assert u.errors[:password_confirmation].present? end end def test_should_require_email - assert_no_difference User, :count do + assert_no_difference 'User.count' do u = new_user(:email => nil) assert u.errors[:email].present? end @@ -470,7 +470,7 @@ class UserTest < ActiveSupport::TestCase end should 'deliver e-mail with activation code after creation' do - assert_difference(ActionMailer::Base.deliveries, :size, 1) do + assert_difference 'ActionMailer::Base.deliveries.size', 1 do new_user :email => 'pending@activation.com' end assert_equal 'pending@activation.com', ActionMailer::Base.deliveries.last['to'].to_s @@ -478,7 +478,7 @@ class UserTest < ActiveSupport::TestCase should 'not try to deliver email to template users' do Person.any_instance.stubs(:is_template?).returns(true) - assert_no_difference ActionMailer::Base.deliveries, :size do + assert_no_difference 'ActionMailer::Base.deliveries.size' do new_user end end @@ -517,7 +517,7 @@ class UserTest < ActiveSupport::TestCase end should 'delay activation check' do - assert_difference Delayed::Job, :count, 1 do + assert_difference 'Delayed::Job.count', 1 do user = new_user end end @@ -568,7 +568,7 @@ class UserTest < ActiveSupport::TestCase env.save user = new_user :email => 'pending@activation.com' - assert_no_difference(ActionMailer::Base.deliveries, :size) do + assert_no_difference 'ActionMailer::Base.deliveries.size' do user.activate end end @@ -583,7 +583,7 @@ class UserTest < ActiveSupport::TestCase env.save user = new_user :email => 'pending@activation.com' - assert_difference(ActionMailer::Base.deliveries, :size, 1) do + assert_difference 'ActionMailer::Base.deliveries.size', 1 do user.activate process_delayed_job_queue end @@ -603,7 +603,7 @@ class UserTest < ActiveSupport::TestCase env.save user = new_user :email => 'pending@activation.com' - assert_difference(ActionMailer::Base.deliveries, :size, 1) do + assert_difference 'ActionMailer::Base.deliveries.size', 1 do user.activate end @@ -621,7 +621,7 @@ class UserTest < ActiveSupport::TestCase env.save user = new_user :name => 'John Doe', :email => 'pending@activation.com' - assert_difference(ActionMailer::Base.deliveries, :size, 1) do + assert_difference 'ActionMailer::Base.deliveries.size', 1 do user.activate end @@ -638,7 +638,7 @@ class UserTest < ActiveSupport::TestCase env.save user = new_user :email => 'pending@activation.com' - assert_no_difference(ActionMailer::Base.deliveries, :size) do + assert_no_difference 'ActionMailer::Base.deliveries.size' do user.activate end end @@ -649,7 +649,7 @@ class UserTest < ActiveSupport::TestCase env.save user = new_user :email => 'pending@activation.com' - assert_no_difference(ActionMailer::Base.deliveries, :size) do + assert_no_difference 'ActionMailer::Base.deliveries.size' do user.activate end end -- libgit2 0.21.2