Skip to content

Commit

Permalink
DEV: Update test setup to work with auto groups (#205)
Browse files Browse the repository at this point in the history
We're updating core to change TL based access settings to be group based. This requires some updates of tests to work correctly. (The existing test setup gives false positives.)
  • Loading branch information
Drenmi authored Jan 15, 2024
1 parent 1a07923 commit 2888a52
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 6 deletions.
3 changes: 3 additions & 0 deletions spec/discourse_code_review/lib/github_pr_syncer_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,9 @@ def get_user_email(github_login)
)
end

before { User.set_callback(:create, :after, :ensure_in_trust_level_group) }
after { User.skip_callback(:create, :after, :ensure_in_trust_level_group) }

describe "#sync_pull_request" do
context "when there are no events" do
let!(:syncer) do
Expand Down
3 changes: 3 additions & 0 deletions spec/discourse_code_review/lib/importer_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ def first_post_of(topic_id)
let(:parent_category) { Fabricate(:category) }
let(:repo) { GithubRepo.new("discourse/discourse", Octokit::Client.new, nil, repo_id: 24) }

before { User.set_callback(:create, :after, :ensure_in_trust_level_group) }
after { User.skip_callback(:create, :after, :ensure_in_trust_level_group) }

it "creates categories with a description" do
category = Category.find_by(id: Importer.new(repo).category_id)

Expand Down
2 changes: 1 addition & 1 deletion spec/discourse_code_review/lib/state/commit_topics_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ module DiscourseCodeReview
end

describe "#ensure_commit" do
fab!(:user) { Fabricate(:user) }
fab!(:user) { Fabricate(:user, refresh_auto_groups: true) }
fab!(:category) { Fabricate(:category) }

it "can handle commits without message" do
Expand Down
4 changes: 4 additions & 0 deletions spec/jobs/code_review_sync_commits_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,12 @@
comment: {
},
)

User.set_callback(:create, :after, :ensure_in_trust_level_group)
end

after { User.skip_callback(:create, :after, :ensure_in_trust_level_group) }

it "creates a commit topic and a category topic, with a full sha in the first post" do
expect {
described_class.new.execute(repo_name: "10xninjarockstar/ultimatetodolist", repo_id: 24)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,8 @@
end

context "when signed in as an admin" do
fab!(:signed_in_user) { Fabricate(:admin) }
fab!(:another_admin) { Fabricate(:admin) }
fab!(:signed_in_user) { Fabricate(:admin, refresh_auto_groups: true) }
fab!(:another_admin) { Fabricate(:admin, refresh_auto_groups: true) }

before do
SiteSetting.code_review_enabled = true
Expand Down Expand Up @@ -181,7 +181,7 @@
end

it "skips commits from muted categories" do
admin2 = Fabricate(:admin)
admin2 = Fabricate(:admin, refresh_auto_groups: true)

muted_category = Fabricate(:category)

Expand Down Expand Up @@ -220,7 +220,7 @@
create_post(
raw: "this is an old commit",
tags: [SiteSetting.code_review_pending_tag],
user: Fabricate(:admin),
user: Fabricate(:admin, refresh_auto_groups: true),
)

commit =
Expand Down Expand Up @@ -430,7 +430,7 @@
end

describe ".render_next_topic" do
let(:other_user) { Fabricate(:admin) }
let(:other_user) { Fabricate(:admin, refresh_auto_groups: true) }

it "prefers unread topics over read ones" do
commit =
Expand Down

0 comments on commit 2888a52

Please sign in to comment.