From 905f869460c7f018343b2c6bdcd221a216e61ac1 Mon Sep 17 00:00:00 2001
From: kosiakkatrina <54268893+kosiakkatrina@users.noreply.github.com>
Date: Mon, 8 Jul 2024 10:57:25 +0100
Subject: [PATCH 1/3] CLDC-2939 Link to organisations from user pages (#2489)
* Link to organisations from user pages
* Fix test
---
app/helpers/tab_nav_helper.rb | 3 ++-
app/views/users/show.html.erb | 2 +-
spec/helpers/tab_nav_helper_spec.rb | 8 ++++----
spec/requests/users_controller_spec.rb | 11 ++++++++++-
4 files changed, 17 insertions(+), 7 deletions(-)
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
From f6a0cc67e5c0dfd30dfc2b03eb5f89756fd01847 Mon Sep 17 00:00:00 2001
From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com>
Date: Mon, 8 Jul 2024 15:58:01 +0100
Subject: [PATCH 2/3] Bump rails_admin from 3.1.2 to 3.1.3 (#2500)
Bumps [rails_admin](https://github.com/sferik/rails_admin) from 3.1.2 to 3.1.3.
- [Changelog](https://github.com/railsadminteam/rails_admin/blob/v3.1.3/CHANGELOG.md)
- [Commits](https://github.com/sferik/rails_admin/compare/v3.1.2...v3.1.3)
---
updated-dependencies:
- dependency-name: rails_admin
dependency-type: direct:production
...
Signed-off-by: dependabot[bot]
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
---
Gemfile | 2 +-
Gemfile.lock | 22 +++++++++++-----------
2 files changed, 12 insertions(+), 12 deletions(-)
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
From ababb3894ca1931d5ade6b93f7a5d1c20e699d54 Mon Sep 17 00:00:00 2001
From: Rachael Booth
Date: Wed, 10 Jul 2024 10:25:50 +0100
Subject: [PATCH 3/3] CLDC-3543: Allow live run of handle unpended logs task
(#2496)
---
lib/tasks/handle_unpended_logs.rake | 20 ++++++++++----------
1 file changed, 10 insertions(+), 10 deletions(-)
diff --git a/lib/tasks/handle_unpended_logs.rake b/lib/tasks/handle_unpended_logs.rake
index fda99687e..02c976682 100644
--- a/lib/tasks/handle_unpended_logs.rake
+++ b/lib/tasks/handle_unpended_logs.rake
@@ -1,6 +1,6 @@
desc "Deduplicates logs where we have inadvertently turned some pending logs to in progress / completed"
task :handle_unpended_logs, %i[perform_updates] => :environment do |_task, _args|
- dry_run = true # args[:perform_updates].blank? || args[:perform_updates] != "true"
+ dry_run = args[:perform_updates].blank? || args[:perform_updates] != "true"
pg = ActiveRecord::Base.connection
query = "SELECT \"versions\".* FROM \"versions\" WHERE \"versions\".\"item_type\" = 'LettingsLog' AND whodunnit is null AND ((object_changes like '%status:\n- 3\n- 1%') OR (object_changes like '%status:\n- 3\n- 2%'))"
@@ -115,9 +115,9 @@ task :handle_unpended_logs, %i[perform_updates] => :environment do |_task, _args
affected_non_updated_duplicates.each do |d|
seen.add(d.id)
csv << [d.id, d.collection_start_year, d.status, d.owning_organisation_name, d.assigned_to_id, d.assigned_to.email, "Delete", "Log is a duplicate of unaffected log(s)", unaffected_logs_reference]
- # unless dry_run
- # d.discard!
- # end
+ unless dry_run
+ d.discard!
+ end
end
next
end
@@ -133,9 +133,9 @@ task :handle_unpended_logs, %i[perform_updates] => :environment do |_task, _args
affected_non_updated_duplicates.each do |d|
seen.add(d.id)
csv << [d.id, d.collection_start_year, d.status, d.owning_organisation_name, d.assigned_to_id, d.assigned_to.email, "Delete", "Log is a duplicate of log(s) which have been updated since being affected", updated_logs_reference]
- # unless dry_run
- # d.discard!
- # end
+ unless dry_run
+ d.discard!
+ end
end
next
end
@@ -149,9 +149,9 @@ task :handle_unpended_logs, %i[perform_updates] => :environment do |_task, _args
seen.add(d.id)
csv << [d.id, d.collection_start_year, d.status, d.owning_organisation_name, d.assigned_to_id, d.assigned_to.email, "Delete", "Log is a duplicate of more recently created affected log", latest_created.id]
- # unless dry_run
- # d.discard!
- # end
+ unless dry_run
+ d.discard!
+ end
end
end
end