From 953a006f96f3c84d481a81ab6d50a103f9811687 Mon Sep 17 00:00:00 2001 From: Fabio Teixeira Date: Mon, 8 Sep 2014 13:21:35 -0300 Subject: [PATCH] deactive_and_active_profile: Update tests for deactivate and activate profile --- test/functional/profile_editor_controller_test.rb | 4 ++++ test/unit/profile_test.rb | 17 +++++++++++++---- test/unit/user_mailer_test.rb | 6 +++--- 3 files changed, 20 insertions(+), 7 deletions(-) diff --git a/test/functional/profile_editor_controller_test.rb b/test/functional/profile_editor_controller_test.rb index c47a900..6cf3727 100644 --- a/test/functional/profile_editor_controller_test.rb +++ b/test/functional/profile_editor_controller_test.rb @@ -1099,6 +1099,8 @@ class ProfileEditorControllerTest < ActionController::TestCase login_as('user') community = fast_create(Community) + assert_equal true, community.enable + get :index, :profile => community.identifier get :deactivate_profile, {:profile => community.identifier, :id => community.id} assert_equal @request.session[:notice], "The profile '#{community.name}' was disabled." @@ -1111,6 +1113,8 @@ class ProfileEditorControllerTest < ActionController::TestCase login_as('user') community = fast_create(Community) + assert_equal true, community.disable + get :index, :profile => community.identifier get :activate_profile, {:profile => community.identifier, :id => community.id} assert_equal @request.session[:notice], "The profile '#{community.name}' was activated." diff --git a/test/unit/profile_test.rb b/test/unit/profile_test.rb index bc8383f..f6e2790 100644 --- a/test/unit/profile_test.rb +++ b/test/unit/profile_test.rb @@ -1959,9 +1959,18 @@ class ProfileTest < ActiveSupport::TestCase should 'enable profile visibility' do profile = fast_create(Profile) - assert profile.enable, _("Profile should have been enabled") - assert profile.visible, _("Profile should be visible") - profile.disable - assert !profile.visible, _("Profile should not be visible") + assert_equal true, profile.disable + + assert_equal true, profile.enable + assert_equal true, profile.visible? + end + + should 'disable profile visibility' do + profile = fast_create(Profile) + + assert_equal true, profile.enable + + assert_equal true, profile.disable + assert_equal false, profile.visible? end end diff --git a/test/unit/user_mailer_test.rb b/test/unit/user_mailer_test.rb index 244f01d..abb4a19 100644 --- a/test/unit/user_mailer_test.rb +++ b/test/unit/user_mailer_test.rb @@ -21,14 +21,14 @@ class UserMailerTest < ActiveSupport::TestCase should 'deliver deactivation email' do assert_difference 'ActionMailer::Base.deliveries.size' do u = create_user('some-user') - UserMailer.ban_user_mail_with_reason(u,"reason").deliver + UserMailer.ban_user_mail_with_reason(u,"reason", Profile.find(u.id)).deliver end end should 'verify deactivation email' do u = create_user('some-user') - email = UserMailer.ban_user_mail_with_reason(u,"you lose").deliver - assert_match("[#{u.environment}] User deactivated", email.subject) + email = UserMailer.ban_user_mail_with_reason(u,"you lose", Profile.find(u.id)).deliver + assert_match("[#{u.environment}] Profile deactivated", email.subject) end private -- libgit2 0.21.2