Skip to content

Commit

Permalink
Update some tests
Browse files Browse the repository at this point in the history
  • Loading branch information
nattsw committed May 3, 2024
1 parent 4ee600d commit 5074274
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions spec/controllers/translator_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -114,29 +114,31 @@
end

describe "user is not in a allowlisted group" do
before { SiteSetting.restrict_translation_by_group = "not_in_the_list" }
before do
SiteSetting.restrict_translation_by_group = "#{Group::AUTO_GROUPS[:moderators]}"
end

include_examples "deny_request_to_translate"
end

describe "restrict_translation_by_poster_group" do
fab!(:admin)
fab!(:group)
fab!(:user) { Fabricate(:user, groups: [group]) }

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

log_in_user(admin)
log_in_user(user)
end
describe "post made by an user in a allowlisted group" do
before do
SiteSetting.restrict_translation_by_poster_group = "#{poster.groups.first.id}"
SiteSetting.restrict_translation_by_poster_group = "#{group.id}"
end
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" }
before { SiteSetting.restrict_translation_by_poster_group = "#{Group::AUTO_GROUPS[:moderators]}" }
include_examples "deny_request_to_translate"
end
end
Expand Down

0 comments on commit 5074274

Please sign in to comment.