Skip to content

Commit

Permalink
Change 'Admin and Collaborator' to 'Account owner'
Browse files Browse the repository at this point in the history
  • Loading branch information
DaniBitZesty committed Jul 9, 2024
1 parent 4960b38 commit b347466
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 7 deletions.
16 changes: 10 additions & 6 deletions app/decorators/user_decorator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,17 @@ def role
end

def role_name
case object.role.to_s.humanize
when "Account admin"
"Admin and collaborator"
when "Regular"
"Collaborator only"
if account.owner == self
"Account owner"
else
object.role.to_s.humanize
case role.to_s.humanize
when "Account admin"
"Admin and collaborator"
when "Regular"
"Collaborator only"
else
role.to_s.humanize
end
end
end

Expand Down
2 changes: 1 addition & 1 deletion app/views/account/collaborators/_item.html.slim
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
li.list-group-item id=dom_id(collaborator) aria-label="#{role = collaborator == account_owner ? "Account owner" : collaborator.role_name} summary"
li.list-group-item id=dom_id(collaborator) aria-label="#{role = collaborator.role_name} summary"
h3.collaborator__name.govuk-heading-s
= collaborator.full_name_with_status
p.collaborator__jobtitle.govuk-body
Expand Down
7 changes: 7 additions & 0 deletions spec/decorators/user_decorator_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,13 @@
end

describe "#role_name" do
context "when user is account owner" do
it "returns Account owner" do

Check failure on line 99 in spec/decorators/user_decorator_spec.rb

View workflow job for this annotation

GitHub Actions / test

UserDecorator#role_name when user is account owner returns Account owner Failure/Error: user.account.owner = user NoMethodError: undefined method `owner=' for nil:NilClass
user.account.owner = user
expect(subject.role_name).to eq("Account owner")
end
end

context "when user is account_admin" do
it "returns Admin and collaborator" do

Check failure on line 106 in spec/decorators/user_decorator_spec.rb

View workflow job for this annotation

GitHub Actions / test

UserDecorator#role_name when user is account_admin returns Admin and collaborator Failure/Error: if account.owner == self NoMethodError: undefined method `owner' for nil:NilClass
user.role = "account_admin"
Expand Down

0 comments on commit b347466

Please sign in to comment.