Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'spec/helpers/users_helper_spec.rb')
-rw-r--r--spec/helpers/users_helper_spec.rb50
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