Stub current_user in all component tests
The `sign_in(nil)` method was a bit hard to understand IMHO. After all, in controller and system tests we don't have to specify no user is signed in; that's the default behavior. So we're making it the default behavior for component tests as well.
This commit is contained in:
@@ -19,8 +19,6 @@ describe Budgets::Investments::VotesComponent do
|
||||
end
|
||||
|
||||
it "disables the button to support the investment to unidentified users" do
|
||||
sign_in(nil)
|
||||
|
||||
render_inline component
|
||||
|
||||
expect(page).to have_button count: 1, disabled: :all
|
||||
|
||||
@@ -7,8 +7,6 @@ describe Budgets::InvestmentsListComponent do
|
||||
let(:group) { create(:budget_group, budget: budget) }
|
||||
let(:heading) { create(:budget_heading, group: group) }
|
||||
|
||||
before { sign_in(nil) }
|
||||
|
||||
describe "#investments" do
|
||||
let(:component) { Budgets::InvestmentsListComponent.new(budget) }
|
||||
|
||||
|
||||
@@ -53,8 +53,6 @@ describe Budgets::SubheaderComponent do
|
||||
end
|
||||
|
||||
it "and user is not logged in shows links to sign in and sign up" do
|
||||
sign_in(nil)
|
||||
|
||||
render_inline Budgets::SubheaderComponent.new(budget)
|
||||
|
||||
expect(page).to have_content "To create a new budget investment you must"
|
||||
|
||||
@@ -4,7 +4,6 @@ describe Budgets::SupportsInfoComponent do
|
||||
let(:budget) { create(:budget, :selecting) }
|
||||
let(:group) { create(:budget_group, budget: budget) }
|
||||
let(:component) { Budgets::SupportsInfoComponent.new(budget) }
|
||||
before { sign_in(nil) }
|
||||
|
||||
it "renders when the budget is selecting" do
|
||||
create(:budget_heading, group: group)
|
||||
|
||||
@@ -7,7 +7,6 @@ describe MachineLearning::CommentsSummaryComponent do
|
||||
before do
|
||||
Setting["feature.machine_learning"] = true
|
||||
Setting["machine_learning.comments_summary"] = true
|
||||
sign_in(nil)
|
||||
end
|
||||
|
||||
it "is displayed when the setting is enabled" do
|
||||
|
||||
@@ -14,8 +14,6 @@ describe Relationable::RelatedListComponent do
|
||||
create(:related_content, parent_relationable: proposal,
|
||||
child_relationable: machine_proposal,
|
||||
machine_learning: true)
|
||||
|
||||
sign_in(nil)
|
||||
end
|
||||
|
||||
it "displays machine learning and user content when machine learning is enabled" do
|
||||
|
||||
@@ -83,6 +83,10 @@ RSpec.configure do |config|
|
||||
sign_in(create(:administrator).user)
|
||||
end
|
||||
|
||||
config.before(:each, type: :component) do
|
||||
sign_in(nil)
|
||||
end
|
||||
|
||||
config.around(:each, :controller, type: :component) do |example|
|
||||
with_controller_class(example.metadata[:controller]) { example.run }
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user