Browse Source

Merge branch 'main' into HandleUnpendedLogs

pull/2496/head
Rachael Booth 2 years ago committed by GitHub
parent
commit
29c0d7c539
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 2
      Gemfile
  2. 22
      Gemfile.lock
  3. 3
      app/helpers/tab_nav_helper.rb
  4. 2
      app/views/users/show.html.erb
  5. 8
      spec/helpers/tab_nav_helper_spec.rb
  6. 11
      spec/requests/users_controller_spec.rb

2
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"

22
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

3
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 = "<span class=\"app-!-colour-muted\">#{user.role.to_s.humanize}</span>"
[user.organisation.name, role].join("\n")
[org_name, role].join("\n")
end
end

2
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 %>

8
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 = "<a class=\"govuk-link\" href=\"/users\">#{user.name}</a>\n<span class=\"govuk-visually-hidden\">User </span><span class=\"govuk-!-font-weight-regular app-!-colour-muted\">#{user.email}</span>"
expect(user_cell(user)).to match(expected_html)
expected_html = "<a class=\"govuk-link\" href=\"/users\">#{current_user.name}</a>\n<span class=\"govuk-visually-hidden\">User </span><span class=\"govuk-!-font-weight-regular app-!-colour-muted\">#{current_user.email}</span>"
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\n<span class=\"app-!-colour-muted\">Data provider</span>"
expect(org_cell(user)).to match(expected_html)
expect(org_cell(current_user)).to match(expected_html)
end
end

11
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

Loading…
Cancel
Save