From 416e0e20be452c4224aa803189d22c81741bb5f8 Mon Sep 17 00:00:00 2001 From: Lalith Julian Kandiah Vipulananthan Date: Thu, 3 Jul 2025 16:32:35 +0900 Subject: [PATCH 1/5] Moved success message and updated inbox test --- app/controllers/inbox_controller.rb | 4 ++-- spec/controllers/inbox_controller_spec.rb | 12 ++++-------- 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/app/controllers/inbox_controller.rb b/app/controllers/inbox_controller.rb index f9397575cac..38bc10d42c2 100644 --- a/app/controllers/inbox_controller.rb +++ b/app/controllers/inbox_controller.rb @@ -42,10 +42,10 @@ def update elsif params[:delete] @inbox_comments.each { |i| i.destroy } end + success_message = ts('Inbox successfully updated.') rescue - flash[:caution] = ts("Please select something first") + flash[:caution] = ts("Please select something first.") end - success_message = ts('Inbox successfully updated.') respond_to do |format| format.html { redirect_to request.referer || user_inbox_path(@user, page: params[:page], filters: params[:filters]), notice: success_message } format.json { render json: { item_success_message: success_message }, status: :ok } diff --git a/spec/controllers/inbox_controller_spec.rb b/spec/controllers/inbox_controller_spec.rb index 9e29317db9e..d633a729c08 100644 --- a/spec/controllers/inbox_controller_spec.rb +++ b/spec/controllers/inbox_controller_spec.rb @@ -271,19 +271,15 @@ before { fake_login_known_user(user) } context "with no comments selected" do - it "redirects to inbox with caution and a notice" do + it "redirects to the user's inbox with a caution" do put :update, params: { user_id: user.login, read: "yeah" } - it_redirects_to_with_caution_and_notice(user_inbox_path(user), - "Please select something first", - "Inbox successfully updated.") + it_redirects_to_with_caution(user_inbox_path(user), "Please select something first.") end - it "redirects to the previously viewed page if HTTP_REFERER is set, with a caution and a notice" do + it "redirects to the previously viewed page if HTTP_REFERER is set, with a caution" do @request.env["HTTP_REFERER"] = root_path put :update, params: { user_id: user.login, read: "yeah" } - it_redirects_to_with_caution_and_notice(root_path, - "Please select something first", - "Inbox successfully updated.") + it_redirects_to_with_caution(root_path, "Please select something first.") end end From 689a9ac1bf7260e1c1f72ae351da98d78d32a831 Mon Sep 17 00:00:00 2001 From: talvalin <1560659+talvalin@users.noreply.github.com> Date: Wed, 9 Jul 2025 21:44:04 +0900 Subject: [PATCH 2/5] Initial fix commit --- app/helpers/works_helper.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/helpers/works_helper.rb b/app/helpers/works_helper.rb index 4ad976d8eb9..7fd71a57613 100644 --- a/app/helpers/works_helper.rb +++ b/app/helpers/works_helper.rb @@ -129,7 +129,7 @@ def related_work_note(related_work, relation, download: false) t(".#{relation}.unrevealed", locale: default_locale) end - elsif related_work.restricted? && (download || !logged_in?) + elsif related_work.restricted? && (download || !logged_in?) && !logged_in_as_admin? t(".#{relation}.restricted_html", language: language, locale: default_locale, From 5b571d85c4a3b1aa15947e0bb1f10a2263dcdd25 Mon Sep 17 00:00:00 2001 From: talvalin <1560659+talvalin@users.noreply.github.com> Date: Wed, 9 Jul 2025 00:09:14 +0900 Subject: [PATCH 3/5] Reverting inbox controller changes from a previous fix. --- app/controllers/inbox_controller.rb | 4 ++-- spec/controllers/inbox_controller_spec.rb | 12 ++++++++---- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/app/controllers/inbox_controller.rb b/app/controllers/inbox_controller.rb index 38bc10d42c2..f9397575cac 100644 --- a/app/controllers/inbox_controller.rb +++ b/app/controllers/inbox_controller.rb @@ -42,10 +42,10 @@ def update elsif params[:delete] @inbox_comments.each { |i| i.destroy } end - success_message = ts('Inbox successfully updated.') rescue - flash[:caution] = ts("Please select something first.") + flash[:caution] = ts("Please select something first") end + success_message = ts('Inbox successfully updated.') respond_to do |format| format.html { redirect_to request.referer || user_inbox_path(@user, page: params[:page], filters: params[:filters]), notice: success_message } format.json { render json: { item_success_message: success_message }, status: :ok } diff --git a/spec/controllers/inbox_controller_spec.rb b/spec/controllers/inbox_controller_spec.rb index d633a729c08..9e29317db9e 100644 --- a/spec/controllers/inbox_controller_spec.rb +++ b/spec/controllers/inbox_controller_spec.rb @@ -271,15 +271,19 @@ before { fake_login_known_user(user) } context "with no comments selected" do - it "redirects to the user's inbox with a caution" do + it "redirects to inbox with caution and a notice" do put :update, params: { user_id: user.login, read: "yeah" } - it_redirects_to_with_caution(user_inbox_path(user), "Please select something first.") + it_redirects_to_with_caution_and_notice(user_inbox_path(user), + "Please select something first", + "Inbox successfully updated.") end - it "redirects to the previously viewed page if HTTP_REFERER is set, with a caution" do + it "redirects to the previously viewed page if HTTP_REFERER is set, with a caution and a notice" do @request.env["HTTP_REFERER"] = root_path put :update, params: { user_id: user.login, read: "yeah" } - it_redirects_to_with_caution(root_path, "Please select something first.") + it_redirects_to_with_caution_and_notice(root_path, + "Please select something first", + "Inbox successfully updated.") end end From 70358c291eabe61838d5a99535315a9839078ca3 Mon Sep 17 00:00:00 2001 From: talvalin <1560659+talvalin@users.noreply.github.com> Date: Thu, 10 Jul 2025 23:02:19 +0900 Subject: [PATCH 4/5] Adjusted change as per review comment to fix the download restricted works feature. --- app/helpers/works_helper.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/helpers/works_helper.rb b/app/helpers/works_helper.rb index 7fd71a57613..47d0f3f2396 100644 --- a/app/helpers/works_helper.rb +++ b/app/helpers/works_helper.rb @@ -129,7 +129,7 @@ def related_work_note(related_work, relation, download: false) t(".#{relation}.unrevealed", locale: default_locale) end - elsif related_work.restricted? && (download || !logged_in?) && !logged_in_as_admin? + elsif related_work.restricted? && (download || !logged_in? && !logged_in_as_admin?) t(".#{relation}.restricted_html", language: language, locale: default_locale, From f0ccd04aa8e692d011ad4213e6aa4f92aed665aa Mon Sep 17 00:00:00 2001 From: talvalin <1560659+talvalin@users.noreply.github.com> Date: Thu, 10 Jul 2025 23:18:39 +0900 Subject: [PATCH 5/5] Added parentheses to placate some overly zealous linting --- app/helpers/works_helper.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/helpers/works_helper.rb b/app/helpers/works_helper.rb index 47d0f3f2396..aba0f9570f9 100644 --- a/app/helpers/works_helper.rb +++ b/app/helpers/works_helper.rb @@ -129,7 +129,7 @@ def related_work_note(related_work, relation, download: false) t(".#{relation}.unrevealed", locale: default_locale) end - elsif related_work.restricted? && (download || !logged_in? && !logged_in_as_admin?) + elsif related_work.restricted? && (download || (!logged_in? && !logged_in_as_admin?)) t(".#{relation}.restricted_html", language: language, locale: default_locale,