Add method to stub current_user in component tests

We're choosing `sign_in` instead of `login_as` because IMHO component
tests are more similar to controller tests than they are to system
tests.
This commit is contained in:
Javi Martín
2021-09-04 15:30:04 +02:00
parent 4cbf945228
commit e97c375063
11 changed files with 30 additions and 31 deletions

View File

@@ -7,7 +7,7 @@ describe MachineLearning::CommentsSummaryComponent do
before do
Setting["feature.machine_learning"] = true
Setting["machine_learning.comments_summary"] = true
allow(controller).to receive(:current_user).and_return(nil)
sign_in(nil)
end
it "is displayed when the setting is enabled" do