Skip to content

Commit

Permalink
DEV: Make admin login work with new TL4 admins (#136)
Browse files Browse the repository at this point in the history
The current test setup creates the admin with the same user ID every time, causing a unique index violation on the admin group membership, blocking discourse/discourse#25435.

This PR changes the current approach to a more standard fabricate → sign in approach.
  • Loading branch information
Drenmi committed Mar 26, 2024
1 parent 7b3adc4 commit 37ae6ef
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions spec/controllers/translator_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -101,11 +101,15 @@
end

describe "user is in a allowlisted group" do
fab!(:admin)

before do
SiteSetting.restrict_translation_by_group =
"#{Group.find_by(name: "admins").id}|not_in_the_list"

log_in_user(admin)
end
let!(:user) { log_in :admin }

include_examples "translation_successful"
end

Expand All @@ -116,21 +120,23 @@
end

describe "restrict_translation_by_poster_group" do
fab!(:admin)

before do
SiteSetting.restrict_translation_by_group =
"#{Group.find_by(name: "admins").id}|not_in_the_list"

log_in_user(admin)
end
describe "post made by an user in a allowlisted group" do
before do
SiteSetting.restrict_translation_by_poster_group = "#{poster.groups.first.id}"
end
let!(:user) { log_in :admin }
include_examples "translation_successful"
end

describe "post made by an user not in a allowlisted group" do
before { SiteSetting.restrict_translation_by_poster_group = "not_in_the_list" }
let!(:user) { log_in :admin }
include_examples "deny_request_to_translate"
end
end
Expand Down

0 comments on commit 37ae6ef

Please sign in to comment.