diff --git a/Gemfile b/Gemfile index 412769b2e..f43a1b7d9 100644 --- a/Gemfile +++ b/Gemfile @@ -63,7 +63,7 @@ gem "possessive" gem "auto_strip_attributes" # Use sidekiq for background processing gem "method_source", "~> 1.1" -gem "rails_admin", "~> 3.0" +gem "rails_admin", "~> 3.1" gem "ruby-openai" gem "sidekiq" gem "sidekiq-cron" diff --git a/Gemfile.lock b/Gemfile.lock index 8f9ea9b52..5c8f48017 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -104,7 +104,7 @@ GEM bindex (0.8.1) bootsnap (1.18.3) msgpack (~> 1.2) - builder (3.2.4) + builder (3.3.0) bundler-audit (0.9.1) bundler (>= 1.2.0, < 3) thor (~> 1.0) @@ -128,7 +128,7 @@ GEM launchy childprocess (5.0.0) coderay (1.1.3) - concurrent-ruby (1.3.1) + concurrent-ruby (1.3.3) connection_pool (2.4.1) crack (1.0.0) bigdecimal @@ -163,7 +163,7 @@ GEM rainbow rubocop smart_properties - erubi (1.12.0) + erubi (1.13.0) et-orbi (1.2.7) tzinfo event_stream_parser (1.0.0) @@ -241,13 +241,13 @@ GEM matrix (0.4.2) method_source (1.1.0) mini_mime (1.1.5) - minitest (5.23.1) + minitest (5.24.1) msgpack (1.7.2) multipart-post (2.4.1) nested_form (0.3.2) net-http (0.4.1) uri - net-imap (0.4.12) + net-imap (0.4.14) date net-protocol net-pop (0.1.2) @@ -257,11 +257,11 @@ GEM net-smtp (0.5.0) net-protocol nio4r (2.7.3) - nokogiri (1.16.5-arm64-darwin) + nokogiri (1.16.6-arm64-darwin) racc (~> 1.4) - nokogiri (1.16.5-x86_64-darwin) + nokogiri (1.16.6-x86_64-darwin) racc (~> 1.4) - nokogiri (1.16.5-x86_64-linux) + nokogiri (1.16.6-x86_64-linux) racc (~> 1.4) notifications-ruby-client (6.0.0) jwt (>= 1.5, < 3) @@ -333,7 +333,7 @@ GEM rails-html-sanitizer (1.6.0) loofah (~> 2.21) nokogiri (~> 1.14) - rails_admin (3.1.2) + rails_admin (3.1.3) activemodel-serializers-xml (>= 1.0) kaminari (>= 0.14, < 2.0) nested_form (~> 0.3) @@ -484,7 +484,7 @@ GEM websocket-extensions (0.1.5) xpath (3.2.0) nokogiri (~> 1.8) - zeitwerk (2.6.15) + zeitwerk (2.6.16) PLATFORMS arm64-darwin-21 @@ -535,7 +535,7 @@ DEPENDENCIES rack-attack rack-mini-profiler (~> 2.0) rails (~> 7.0.8.3) - rails_admin (~> 3.0) + rails_admin (~> 3.1) redis (~> 4.8) roo rspec-rails diff --git a/app/helpers/tab_nav_helper.rb b/app/helpers/tab_nav_helper.rb index 24408be28..27542094d 100644 --- a/app/helpers/tab_nav_helper.rb +++ b/app/helpers/tab_nav_helper.rb @@ -19,7 +19,8 @@ module TabNavHelper end def org_cell(user) + org_name = current_user.support? ? govuk_link_to(user.organisation.name, lettings_logs_organisation_path(user.organisation)) : user.organisation.name role = "#{user.role.to_s.humanize}" - [user.organisation.name, role].join("\n") + [org_name, role].join("\n") end end diff --git a/app/views/users/show.html.erb b/app/views/users/show.html.erb index c62fccf2c..acb53d51d 100644 --- a/app/views/users/show.html.erb +++ b/app/views/users/show.html.erb @@ -67,7 +67,7 @@ <%= summary_list.with_row do |row| row.with_key { "Organisation" } - row.with_value { @user.organisation.name } + row.with_value { current_user.support? ? govuk_link_to(@user.organisation.name, lettings_logs_organisation_path(@user.organisation)) : @user.organisation.name } row.with_action end %> diff --git a/spec/helpers/tab_nav_helper_spec.rb b/spec/helpers/tab_nav_helper_spec.rb index 7b4efc5eb..9dbf92e7a 100644 --- a/spec/helpers/tab_nav_helper_spec.rb +++ b/spec/helpers/tab_nav_helper_spec.rb @@ -2,21 +2,21 @@ require "rails_helper" RSpec.describe TabNavHelper do let(:organisation) { FactoryBot.create(:organisation) } - let(:user) { FactoryBot.build(:user, organisation:) } + let(:current_user) { FactoryBot.build(:user, organisation:) } let(:scheme) { FactoryBot.create(:scheme, service_name: "Some name") } let(:location) { FactoryBot.create(:location, scheme:) } describe "#user_cell" do it "returns user link and email separated by a newline character" do - expected_html = "#{user.name}\nUser #{user.email}" - expect(user_cell(user)).to match(expected_html) + expected_html = "#{current_user.name}\nUser #{current_user.email}" + expect(user_cell(current_user)).to match(expected_html) end end describe "#org_cell" do it "returns the users org name and role separated by a newline character" do expected_html = "DLUHC\nData provider" - expect(org_cell(user)).to match(expected_html) + expect(org_cell(current_user)).to match(expected_html) end end diff --git a/spec/requests/users_controller_spec.rb b/spec/requests/users_controller_spec.rb index 9784aa0dc..bb0a1cca3 100644 --- a/spec/requests/users_controller_spec.rb +++ b/spec/requests/users_controller_spec.rb @@ -1188,7 +1188,7 @@ RSpec.describe UsersController, type: :request do describe "#index" do let!(:other_user) { create(:user, organisation: user.organisation, name: "User 2", email: "other@example.com") } let!(:inactive_user) { create(:user, organisation: user.organisation, active: false, name: "User 3", email: "inactive@example.com", last_sign_in_at: Time.zone.local(2022, 10, 10)) } - let!(:other_org_user) { create(:user, name: "User 4", email: "otherorg@otherexample.com", organisation: create(:organisation, :without_dpc)) } + let!(:other_org_user) { create(:user, name: "User 4", email: "otherorg@otherexample.com", organisation: create(:organisation, :without_dpc, name: "Other name")) } before do get "/users", headers:, params: {} @@ -1201,6 +1201,11 @@ RSpec.describe UsersController, type: :request do expect(page).to have_content(other_org_user.name) end + it "links to user organisations" do + expect(page).to have_link(user.organisation.name, href: "/organisations/#{user.organisation.id}/lettings-logs", count: 3) + expect(page).to have_link(other_org_user.organisation.name, href: "/organisations/#{other_org_user.organisation.id}/lettings-logs", count: 1) + end + it "shows last logged in date for all users" do expect(page).to have_content("10 October 2022") end @@ -1432,6 +1437,10 @@ RSpec.describe UsersController, type: :request do expect(page).to have_link("Change", text: "if a key contact") end + it "links to user organisation" do + expect(page).to have_link(other_user.organisation.name, href: "/organisations/#{other_user.organisation.id}/lettings-logs") + end + it "does not show option to resend confirmation email" do expect(page).not_to have_button("Resend invite link") end