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
|
end
|
||||||
|
|
||||||
it "disables the button to support the investment to unidentified users" do
|
it "disables the button to support the investment to unidentified users" do
|
||||||
sign_in(nil)
|
|
||||||
|
|
||||||
render_inline component
|
render_inline component
|
||||||
|
|
||||||
expect(page).to have_button count: 1, disabled: :all
|
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(:group) { create(:budget_group, budget: budget) }
|
||||||
let(:heading) { create(:budget_heading, group: group) }
|
let(:heading) { create(:budget_heading, group: group) }
|
||||||
|
|
||||||
before { sign_in(nil) }
|
|
||||||
|
|
||||||
describe "#investments" do
|
describe "#investments" do
|
||||||
let(:component) { Budgets::InvestmentsListComponent.new(budget) }
|
let(:component) { Budgets::InvestmentsListComponent.new(budget) }
|
||||||
|
|
||||||
|
|||||||
@@ -53,8 +53,6 @@ describe Budgets::SubheaderComponent do
|
|||||||
end
|
end
|
||||||
|
|
||||||
it "and user is not logged in shows links to sign in and sign up" do
|
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)
|
render_inline Budgets::SubheaderComponent.new(budget)
|
||||||
|
|
||||||
expect(page).to have_content "To create a new budget investment you must"
|
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(:budget) { create(:budget, :selecting) }
|
||||||
let(:group) { create(:budget_group, budget: budget) }
|
let(:group) { create(:budget_group, budget: budget) }
|
||||||
let(:component) { Budgets::SupportsInfoComponent.new(budget) }
|
let(:component) { Budgets::SupportsInfoComponent.new(budget) }
|
||||||
before { sign_in(nil) }
|
|
||||||
|
|
||||||
it "renders when the budget is selecting" do
|
it "renders when the budget is selecting" do
|
||||||
create(:budget_heading, group: group)
|
create(:budget_heading, group: group)
|
||||||
|
|||||||
@@ -7,7 +7,6 @@ describe MachineLearning::CommentsSummaryComponent do
|
|||||||
before do
|
before do
|
||||||
Setting["feature.machine_learning"] = true
|
Setting["feature.machine_learning"] = true
|
||||||
Setting["machine_learning.comments_summary"] = true
|
Setting["machine_learning.comments_summary"] = true
|
||||||
sign_in(nil)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
it "is displayed when the setting is enabled" do
|
it "is displayed when the setting is enabled" do
|
||||||
|
|||||||
@@ -14,8 +14,6 @@ describe Relationable::RelatedListComponent do
|
|||||||
create(:related_content, parent_relationable: proposal,
|
create(:related_content, parent_relationable: proposal,
|
||||||
child_relationable: machine_proposal,
|
child_relationable: machine_proposal,
|
||||||
machine_learning: true)
|
machine_learning: true)
|
||||||
|
|
||||||
sign_in(nil)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
it "displays machine learning and user content when machine learning is enabled" do
|
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)
|
sign_in(create(:administrator).user)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
config.before(:each, type: :component) do
|
||||||
|
sign_in(nil)
|
||||||
|
end
|
||||||
|
|
||||||
config.around(:each, :controller, type: :component) do |example|
|
config.around(:each, :controller, type: :component) do |example|
|
||||||
with_controller_class(example.metadata[:controller]) { example.run }
|
with_controller_class(example.metadata[:controller]) { example.run }
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user