diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-07-20 12:55:51 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-07-20 12:55:51 +0300 |
commit | e8d2c2579383897a1dd7f9debd359abe8ae8373d (patch) | |
tree | c42be41678c2586d49a75cabce89322082698334 /spec/helpers/users_helper_spec.rb | |
parent | fc845b37ec3a90aaa719975f607740c22ba6a113 (diff) |
Add latest changes from gitlab-org/gitlab@14-1-stable-eev14.1.0-rc42
Diffstat (limited to 'spec/helpers/users_helper_spec.rb')
-rw-r--r-- | spec/helpers/users_helper_spec.rb | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/spec/helpers/users_helper_spec.rb b/spec/helpers/users_helper_spec.rb index 862fd58df04..480b1e2a0de 100644 --- a/spec/helpers/users_helper_spec.rb +++ b/spec/helpers/users_helper_spec.rb @@ -364,4 +364,54 @@ RSpec.describe UsersHelper do expect(data[:paths]).to match_schema('entities/admin_users_data_attributes_paths') end end + + describe '#confirm_user_data' do + confirm_admin_user_path = '/admin/users/root/confirm' + + before do + allow(helper).to receive(:confirm_admin_user_path).with(user).and_return(confirm_admin_user_path) + end + + subject(:confirm_user_data) { helper.confirm_user_data(user) } + + it 'sets `path` key correctly' do + expect(confirm_user_data[:path]).to eq(confirm_admin_user_path) + end + + it 'sets `modal_attributes` key to valid json' do + expect(confirm_user_data[:modal_attributes]).to be_valid_json + end + + context 'when `user.unconfirmed_email` is set' do + let(:user) { create(:user, unconfirmed_email: 'foo@bar.com') } + + it 'sets `modal_attributes.messageHtml` correctly' do + expect(Gitlab::Json.parse(confirm_user_data[:modal_attributes])['messageHtml']).to eq('This user has an unconfirmed email address (foo@bar.com). You may force a confirmation.') + end + end + + context 'when `user.unconfirmed_email` is not set' do + it 'sets `modal_attributes.messageHtml` correctly' do + expect(Gitlab::Json.parse(confirm_user_data[:modal_attributes])['messageHtml']).to eq('This user has an unconfirmed email address. You may force a confirmation.') + end + end + end + + describe '#admin_user_actions_data_attributes' do + subject(:data) { helper.admin_user_actions_data_attributes(user) } + + before do + allow(helper).to receive(:current_user).and_return(user) + allow(Admin::UserEntity).to receive(:represent).and_call_original + end + + it 'user matches the serialized json' do + expect(data[:user]).to be_valid_json + expect(Admin::UserEntity).to have_received(:represent).with(user, hash_including({ current_user: user })) + end + + it 'paths matches the schema' do + expect(data[:paths]).to match_schema('entities/admin_users_data_attributes_paths') + end + end end |