diff options
author | Filipa Lacerda <filipa@gitlab.com> | 2019-02-06 15:19:00 +0300 |
---|---|---|
committer | Filipa Lacerda <filipa@gitlab.com> | 2019-02-06 15:19:00 +0300 |
commit | 5bfa8e2f5e03849645570ba8c2dbfcc5c834f1b1 (patch) | |
tree | b8a5f15796039af3f659f74cbc131c401818be9b /spec/helpers | |
parent | 3b4c4095bbda55ae0b4d32f9b17c0e4f03c5ceed (diff) | |
parent | d279cc94088fddd6f6bb2847e456bbf68ae616ea (diff) |
Merge branch '43681-display-last-activity-and-created-at-datetimes-for-users-in-admin-users' into 'master'
Resolve "Display last activity and created at datetimes for users"
Closes #43681
See merge request gitlab-org/gitlab-ce!24181
Diffstat (limited to 'spec/helpers')
-rw-r--r-- | spec/helpers/users_helper_spec.rb | 68 |
1 files changed, 68 insertions, 0 deletions
diff --git a/spec/helpers/users_helper_spec.rb b/spec/helpers/users_helper_spec.rb index ab67a5ab847..f3649495493 100644 --- a/spec/helpers/users_helper_spec.rb +++ b/spec/helpers/users_helper_spec.rb @@ -100,4 +100,72 @@ describe UsersHelper do end end end + + describe '#user_badges_in_admin_section' do + before do + allow(helper).to receive(:current_user).and_return(user) + end + + context 'with a blocked user' do + it "returns the blocked badge" do + blocked_user = create(:user, state: 'blocked') + + badges = helper.user_badges_in_admin_section(blocked_user) + + expect(badges).to eq([text: "Blocked", variant: "danger"]) + end + end + + context 'with an admin user' do + it "returns the admin badge" do + admin_user = create(:admin) + + badges = helper.user_badges_in_admin_section(admin_user) + + expect(badges).to eq([text: "Admin", variant: "success"]) + end + end + + context 'with an external user' do + it 'returns the external badge' do + external_user = create(:user, external: true) + + badges = helper.user_badges_in_admin_section(external_user) + + expect(badges).to eq([text: "External", variant: "secondary"]) + end + end + + context 'with the current user' do + it 'returns the "It\'s You" badge' do + badges = helper.user_badges_in_admin_section(user) + + expect(badges).to eq([text: "It's you!", variant: nil]) + end + end + + context 'with an external blocked admin' do + it 'returns the blocked, admin and external badges' do + user = create(:admin, state: 'blocked', external: true) + + badges = helper.user_badges_in_admin_section(user) + + expect(badges).to eq([ + { text: "Blocked", variant: "danger" }, + { text: "Admin", variant: "success" }, + { text: "External", variant: "secondary" } + ]) + end + end + + context 'get badges for normal user' do + it 'returns no badges' do + user = create(:user) + + badges = helper.user_badges_in_admin_section(user) + + expect(badges).to be_empty + end + end + end end |