Commit 953a006f96f3c84d481a81ab6d50a103f9811687
Committed by
Luciano Prestes
1 parent
cbdd6f88
Exists in
merge_deactive_and_ban
deactive_and_active_profile: Update tests for deactivate and activate profile
(ActionItem3287) Signed-off-by: Fabio Teixeira <fabio1079@gmail.com> Signed-off-by: Luciano Prestes <lucianopcbr@gmail.com>
Showing
3 changed files
with
20 additions
and
7 deletions
Show diff stats
test/functional/profile_editor_controller_test.rb
@@ -1099,6 +1099,8 @@ class ProfileEditorControllerTest < ActionController::TestCase | @@ -1099,6 +1099,8 @@ class ProfileEditorControllerTest < ActionController::TestCase | ||
1099 | login_as('user') | 1099 | login_as('user') |
1100 | 1100 | ||
1101 | community = fast_create(Community) | 1101 | community = fast_create(Community) |
1102 | + assert_equal true, community.enable | ||
1103 | + | ||
1102 | get :index, :profile => community.identifier | 1104 | get :index, :profile => community.identifier |
1103 | get :deactivate_profile, {:profile => community.identifier, :id => community.id} | 1105 | get :deactivate_profile, {:profile => community.identifier, :id => community.id} |
1104 | assert_equal @request.session[:notice], "The profile '#{community.name}' was disabled." | 1106 | assert_equal @request.session[:notice], "The profile '#{community.name}' was disabled." |
@@ -1111,6 +1113,8 @@ class ProfileEditorControllerTest < ActionController::TestCase | @@ -1111,6 +1113,8 @@ class ProfileEditorControllerTest < ActionController::TestCase | ||
1111 | login_as('user') | 1113 | login_as('user') |
1112 | 1114 | ||
1113 | community = fast_create(Community) | 1115 | community = fast_create(Community) |
1116 | + assert_equal true, community.disable | ||
1117 | + | ||
1114 | get :index, :profile => community.identifier | 1118 | get :index, :profile => community.identifier |
1115 | get :activate_profile, {:profile => community.identifier, :id => community.id} | 1119 | get :activate_profile, {:profile => community.identifier, :id => community.id} |
1116 | assert_equal @request.session[:notice], "The profile '#{community.name}' was activated." | 1120 | assert_equal @request.session[:notice], "The profile '#{community.name}' was activated." |
test/unit/profile_test.rb
@@ -1959,9 +1959,18 @@ class ProfileTest < ActiveSupport::TestCase | @@ -1959,9 +1959,18 @@ class ProfileTest < ActiveSupport::TestCase | ||
1959 | should 'enable profile visibility' do | 1959 | should 'enable profile visibility' do |
1960 | profile = fast_create(Profile) | 1960 | profile = fast_create(Profile) |
1961 | 1961 | ||
1962 | - assert profile.enable, _("Profile should have been enabled") | ||
1963 | - assert profile.visible, _("Profile should be visible") | ||
1964 | - profile.disable | ||
1965 | - assert !profile.visible, _("Profile should not be visible") | 1962 | + assert_equal true, profile.disable |
1963 | + | ||
1964 | + assert_equal true, profile.enable | ||
1965 | + assert_equal true, profile.visible? | ||
1966 | + end | ||
1967 | + | ||
1968 | + should 'disable profile visibility' do | ||
1969 | + profile = fast_create(Profile) | ||
1970 | + | ||
1971 | + assert_equal true, profile.enable | ||
1972 | + | ||
1973 | + assert_equal true, profile.disable | ||
1974 | + assert_equal false, profile.visible? | ||
1966 | end | 1975 | end |
1967 | end | 1976 | end |
test/unit/user_mailer_test.rb
@@ -21,14 +21,14 @@ class UserMailerTest < ActiveSupport::TestCase | @@ -21,14 +21,14 @@ class UserMailerTest < ActiveSupport::TestCase | ||
21 | should 'deliver deactivation email' do | 21 | should 'deliver deactivation email' do |
22 | assert_difference 'ActionMailer::Base.deliveries.size' do | 22 | assert_difference 'ActionMailer::Base.deliveries.size' do |
23 | u = create_user('some-user') | 23 | u = create_user('some-user') |
24 | - UserMailer.ban_user_mail_with_reason(u,"reason").deliver | 24 | + UserMailer.ban_user_mail_with_reason(u,"reason", Profile.find(u.id)).deliver |
25 | end | 25 | end |
26 | end | 26 | end |
27 | 27 | ||
28 | should 'verify deactivation email' do | 28 | should 'verify deactivation email' do |
29 | u = create_user('some-user') | 29 | u = create_user('some-user') |
30 | - email = UserMailer.ban_user_mail_with_reason(u,"you lose").deliver | ||
31 | - assert_match("[#{u.environment}] User deactivated", email.subject) | 30 | + email = UserMailer.ban_user_mail_with_reason(u,"you lose", Profile.find(u.id)).deliver |
31 | + assert_match("[#{u.environment}] Profile deactivated", email.subject) | ||
32 | end | 32 | end |
33 | 33 | ||
34 | private | 34 | private |