Infer type for component specs automatically
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
require "rails_helper"
|
||||
|
||||
describe Admin::Budgets::DurationComponent, type: :component do
|
||||
describe Admin::Budgets::DurationComponent do
|
||||
describe "#dates" do
|
||||
it "shows both dates when both are defined" do
|
||||
durable = double(
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
require "rails_helper"
|
||||
|
||||
describe Admin::Budgets::FormComponent, type: :component do
|
||||
describe Admin::Budgets::FormComponent do
|
||||
describe "#voting_styles_select_options" do
|
||||
it "provides vote kinds" do
|
||||
types = [["Knapsack", "knapsack"], ["Approval", "approval"]]
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
require "rails_helper"
|
||||
|
||||
describe Admin::Budgets::IndexComponent, type: :component, controller: Admin::BudgetsController do
|
||||
describe Admin::Budgets::IndexComponent, controller: Admin::BudgetsController do
|
||||
before do
|
||||
allow_any_instance_of(Admin::BudgetsController).to receive(:valid_filters).and_return(["all"])
|
||||
allow_any_instance_of(Admin::BudgetsController).to receive(:current_filter).and_return("all")
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
require "rails_helper"
|
||||
|
||||
describe Admin::Budgets::TableActionsComponent, type: :component, controller: Admin::BaseController do
|
||||
describe Admin::Budgets::TableActionsComponent, controller: Admin::BaseController do
|
||||
let(:budget) { create(:budget) }
|
||||
let(:component) { Admin::Budgets::TableActionsComponent.new(budget) }
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
require "rails_helper"
|
||||
|
||||
describe Admin::BudgetsWizard::Headings::GroupSwitcherComponent, type: :component do
|
||||
describe Admin::BudgetsWizard::Headings::GroupSwitcherComponent do
|
||||
it "is not rendered for budgets with one group" do
|
||||
group = create(:budget_group, budget: create(:budget))
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
require "rails_helper"
|
||||
|
||||
describe Admin::HiddenTableActionsComponent, type: :component do
|
||||
describe Admin::HiddenTableActionsComponent do
|
||||
let(:record) { create(:user) }
|
||||
let(:component) { Admin::HiddenTableActionsComponent.new(record) }
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
require "rails_helper"
|
||||
|
||||
describe Admin::Organizations::TableActionsComponent, type: :component do
|
||||
describe Admin::Organizations::TableActionsComponent do
|
||||
let(:organization) { create(:organization) }
|
||||
let(:component) { Admin::Organizations::TableActionsComponent.new(organization) }
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
require "rails_helper"
|
||||
|
||||
describe Admin::Poll::Officers::OfficersComponent, type: :component, controller: Admin::BaseController do
|
||||
describe Admin::Poll::Officers::OfficersComponent, controller: Admin::BaseController do
|
||||
let(:existing_officer) { create(:poll_officer, name: "Old officer") }
|
||||
let(:new_officer) { build(:poll_officer, name: "New officer") }
|
||||
let(:officers) { [existing_officer, new_officer] }
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
require "rails_helper"
|
||||
|
||||
describe Admin::Poll::Questions::FilterComponent, type: :component do
|
||||
describe Admin::Poll::Questions::FilterComponent do
|
||||
it "renders a button to submit the form" do
|
||||
render_inline Admin::Poll::Questions::FilterComponent.new([])
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
require "rails_helper"
|
||||
|
||||
describe Admin::Roles::TableActionsComponent, type: :component, controller: Admin::BaseController do
|
||||
describe Admin::Roles::TableActionsComponent, controller: Admin::BaseController do
|
||||
let(:user) { create(:user) }
|
||||
|
||||
it "renders link to add the role for new records" do
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
require "rails_helper"
|
||||
|
||||
describe Admin::Stats::SDG::GoalComponent, type: :component do
|
||||
describe Admin::Stats::SDG::GoalComponent do
|
||||
let(:component) { Admin::Stats::SDG::GoalComponent.new(goal: goal) }
|
||||
let(:goal) { SDG::Goal.sample }
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
require "rails_helper"
|
||||
|
||||
describe Admin::TableActionsComponent, type: :component, controller: Admin::BaseController do
|
||||
describe Admin::TableActionsComponent, controller: Admin::BaseController do
|
||||
let(:record) { create(:banner) }
|
||||
|
||||
it "renders links to edit and destroy a record by default" do
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
require "rails_helper"
|
||||
|
||||
describe Budgets::BudgetComponent, type: :component do
|
||||
describe Budgets::BudgetComponent do
|
||||
let(:budget) { create(:budget) }
|
||||
let(:heading) { create(:budget_heading, budget: budget) }
|
||||
let(:user) { create(:user) }
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
require "rails_helper"
|
||||
|
||||
describe Budgets::InvestmentComponent, type: :component do
|
||||
describe Budgets::InvestmentComponent do
|
||||
let(:user) { create(:user) }
|
||||
|
||||
before do
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
require "rails_helper"
|
||||
|
||||
describe Budgets::Investments::FormComponent, type: :component do
|
||||
describe Budgets::Investments::FormComponent do
|
||||
include Rails.application.routes.url_helpers
|
||||
|
||||
let(:budget) { create(:budget) }
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
require "rails_helper"
|
||||
|
||||
describe Budgets::Investments::VotesComponent, type: :component do
|
||||
describe Budgets::Investments::VotesComponent do
|
||||
describe "vote link" do
|
||||
context "when investment shows votes" do
|
||||
let(:investment) { create(:budget_investment, title: "Renovate sidewalks in Main Street") }
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
require "rails_helper"
|
||||
|
||||
describe Budgets::InvestmentsListComponent, type: :component do
|
||||
describe Budgets::InvestmentsListComponent do
|
||||
include Rails.application.routes.url_helpers
|
||||
|
||||
let(:budget) { create(:budget, :accepting) }
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
require "rails_helper"
|
||||
|
||||
describe Budgets::PhasesComponent, type: :component do
|
||||
describe Budgets::PhasesComponent do
|
||||
let(:budget) { create(:budget) }
|
||||
|
||||
it "shows budget current phase main link when defined" do
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
require "rails_helper"
|
||||
|
||||
describe Budgets::SubheaderComponent, type: :component do
|
||||
describe Budgets::SubheaderComponent do
|
||||
it "shows budget current phase name" do
|
||||
allow(controller).to receive(:current_user).and_return(create(:user))
|
||||
budget = create(:budget, :informing)
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
require "rails_helper"
|
||||
|
||||
describe Budgets::SupportsInfoComponent, type: :component do
|
||||
describe Budgets::SupportsInfoComponent do
|
||||
let(:budget) { create(:budget, :selecting) }
|
||||
let(:group) { create(:budget_group, budget: budget) }
|
||||
let(:component) { Budgets::SupportsInfoComponent.new(budget) }
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
require "rails_helper"
|
||||
|
||||
describe Layout::LocaleSwitcherComponent, type: :component do
|
||||
describe Layout::LocaleSwitcherComponent do
|
||||
let(:component) { Layout::LocaleSwitcherComponent.new }
|
||||
|
||||
around do |example|
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
require "rails_helper"
|
||||
|
||||
describe Layout::SocialComponent, type: :component do
|
||||
describe Layout::SocialComponent do
|
||||
describe "#render?" do
|
||||
it "renders when a social setting is present" do
|
||||
Setting["twitter_handle"] = "myhandle"
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
require "rails_helper"
|
||||
|
||||
describe Layout::TopLinksComponent, type: :component do
|
||||
describe Layout::TopLinksComponent do
|
||||
describe "#render?" do
|
||||
it "renders when a content block is defined" do
|
||||
create(:site_customization_content_block, name: "top_links")
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
require "rails_helper"
|
||||
|
||||
describe MachineLearning::CommentsSummaryComponent, type: :component do
|
||||
describe MachineLearning::CommentsSummaryComponent do
|
||||
let(:commentable) { double(summary_comment: double(body: "There's a general agreement")) }
|
||||
let(:component) { MachineLearning::CommentsSummaryComponent.new(commentable) }
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
require "rails_helper"
|
||||
|
||||
describe Pages::Help::SectionComponent, type: :component do
|
||||
describe Pages::Help::SectionComponent do
|
||||
describe "#image_path" do
|
||||
it "returns the image for the first fallback language with an image" do
|
||||
allow(I18n).to receive(:fallbacks).and_return({ en: [:es, :de] })
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
require "rails_helper"
|
||||
|
||||
describe Relationable::RelatedListComponent, type: :component do
|
||||
describe Relationable::RelatedListComponent do
|
||||
let(:proposal) { create(:proposal) }
|
||||
let(:user_proposal) { create(:proposal, title: "I am user related") }
|
||||
let(:machine_proposal) { create(:proposal, title: "I am machine related") }
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
require "rails_helper"
|
||||
|
||||
describe SDG::Goals::HelpPageComponent, type: :component do
|
||||
describe SDG::Goals::HelpPageComponent do
|
||||
let(:goals) { SDG::Goal.all }
|
||||
let(:component) { SDG::Goals::HelpPageComponent.new(goals) }
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
require "rails_helper"
|
||||
|
||||
describe SDG::Goals::IndexComponent, type: :component do
|
||||
describe SDG::Goals::IndexComponent do
|
||||
let!(:goals) { SDG::Goal.all }
|
||||
let!(:phases) { SDG::Phase.all }
|
||||
let!(:component) { SDG::Goals::IndexComponent.new(goals, header: nil, phases: phases) }
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
require "rails_helper"
|
||||
|
||||
describe SDG::Goals::PlainTagListComponent, type: :component do
|
||||
describe SDG::Goals::PlainTagListComponent do
|
||||
let(:debate) { create(:debate, sdg_goals: [SDG::Goal[1], SDG::Goal[3]]) }
|
||||
let(:component) { SDG::Goals::PlainTagListComponent.new(debate) }
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
require "rails_helper"
|
||||
|
||||
describe SDG::Goals::ShowComponent, type: :component do
|
||||
describe SDG::Goals::ShowComponent do
|
||||
let!(:goal_1) { SDG::Goal[1] }
|
||||
|
||||
before do
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
require "rails_helper"
|
||||
|
||||
describe SDG::Goals::TagCloudComponent, type: :component do
|
||||
describe SDG::Goals::TagCloudComponent do
|
||||
before do
|
||||
Setting["feature.sdg"] = true
|
||||
Setting["sdg.process.debates"] = true
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
require "rails_helper"
|
||||
|
||||
describe SDG::Goals::TagListComponent, type: :component do
|
||||
describe SDG::Goals::TagListComponent do
|
||||
let(:debate) { create(:debate, sdg_goals: [SDG::Goal[1], SDG::Goal[3]]) }
|
||||
let(:component) { SDG::Goals::TagListComponent.new(debate) }
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
require "rails_helper"
|
||||
|
||||
describe SDG::Goals::TargetsComponent, type: :component do
|
||||
describe SDG::Goals::TargetsComponent do
|
||||
let(:goal) { SDG::Goal[1] }
|
||||
let(:component) { SDG::Goals::TargetsComponent.new(goal) }
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
require "rails_helper"
|
||||
|
||||
describe SDG::RelatedListSelectorComponent, type: :component do
|
||||
describe SDG::RelatedListSelectorComponent do
|
||||
let(:debate) { create(:debate) }
|
||||
let(:form) { ConsulFormBuilder.new(:debate, debate, ActionView::Base.new, {}) }
|
||||
let(:component) { SDG::RelatedListSelectorComponent.new(form) }
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
require "rails_helper"
|
||||
|
||||
describe SDG::TagListComponent, type: :component do
|
||||
describe SDG::TagListComponent do
|
||||
let(:debate) do
|
||||
create(:debate,
|
||||
sdg_goals: [SDG::Goal[3]],
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
require "rails_helper"
|
||||
|
||||
describe SDG::Targets::PlainTagListComponent, type: :component do
|
||||
describe SDG::Targets::PlainTagListComponent do
|
||||
let(:debate) do
|
||||
create(:debate,
|
||||
sdg_targets: [SDG::Target[1.1], SDG::Target[3.2], create(:sdg_local_target, code: "3.2.1")]
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
require "rails_helper"
|
||||
|
||||
describe SDG::Targets::TagListComponent, type: :component do
|
||||
describe SDG::Targets::TagListComponent do
|
||||
let(:debate) do
|
||||
create(:debate,
|
||||
sdg_targets: [SDG::Target[1.1], SDG::Target[3.2], create(:sdg_local_target, code: "3.2.1")]
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
require "rails_helper"
|
||||
|
||||
describe SDGManagement::MenuComponent, type: :component do
|
||||
describe SDGManagement::MenuComponent do
|
||||
let(:component) { SDGManagement::MenuComponent.new }
|
||||
|
||||
before do
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
require "rails_helper"
|
||||
|
||||
describe SDGManagement::Relations::IndexComponent, type: :component, controller: SDGManagement::RelationsController do
|
||||
describe SDGManagement::Relations::IndexComponent, controller: SDGManagement::RelationsController do
|
||||
before do
|
||||
allow_any_instance_of(SDGManagement::RelationsController).to receive(:valid_filters)
|
||||
.and_return(SDGManagement::RelationsController::FILTERS)
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
require "rails_helper"
|
||||
|
||||
describe SDGManagement::Relations::SearchComponent, type: :component do
|
||||
describe SDGManagement::Relations::SearchComponent do
|
||||
describe "#goal_options" do
|
||||
it "orders goals by code in the select" do
|
||||
component = SDGManagement::Relations::SearchComponent.new(label: "Search proposals")
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
require "rails_helper"
|
||||
|
||||
describe SDGManagement::SubnavigationComponent, type: :component do
|
||||
describe SDGManagement::SubnavigationComponent do
|
||||
let(:component) do
|
||||
SDGManagement::SubnavigationComponent.new(current: :goals) do
|
||||
"Tab content"
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
require "rails_helper"
|
||||
|
||||
describe Shared::AdvancedSearchComponent, type: :component do
|
||||
describe Shared::AdvancedSearchComponent do
|
||||
let(:component) { Shared::AdvancedSearchComponent.new }
|
||||
|
||||
context "JavaScript disabled" do
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
require "rails_helper"
|
||||
|
||||
describe Shared::BannerComponent, type: :component do
|
||||
describe Shared::BannerComponent do
|
||||
it "renders given a banner" do
|
||||
banner = create(:banner,
|
||||
title: "Vote now!",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
require "rails_helper"
|
||||
|
||||
describe Shared::FilterSelectorComponent, type: :component do
|
||||
describe Shared::FilterSelectorComponent do
|
||||
it "renders a form with a select" do
|
||||
component = Shared::FilterSelectorComponent.new(i18n_namespace: "budgets.investments.index")
|
||||
allow(component).to receive(:valid_filters).and_return(["unfeasible", "winners"])
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
require "rails_helper"
|
||||
|
||||
describe Shared::LinkListComponent, type: :component do
|
||||
describe Shared::LinkListComponent do
|
||||
it "renders nothing with an empty list" do
|
||||
render_inline Shared::LinkListComponent.new
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
require "rails_helper"
|
||||
|
||||
describe Shared::TagListComponent, type: :component do
|
||||
describe Shared::TagListComponent do
|
||||
let(:user_tag) { create(:tag, name: "user tag") }
|
||||
let(:ml_tag) { create(:tag, name: "machine learning tag") }
|
||||
let(:proposal) { create(:proposal, tag_list: [user_tag], ml_tag_list: [ml_tag]) }
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
require "rails_helper"
|
||||
|
||||
describe Widget::Feeds::DebateComponent, type: :component do
|
||||
describe Widget::Feeds::DebateComponent do
|
||||
let(:debate) { create(:debate, sdg_goals: [SDG::Goal[1]]) }
|
||||
let(:component) { Widget::Feeds::DebateComponent.new(debate) }
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
require "rails_helper"
|
||||
|
||||
describe Widget::Feeds::FeedComponent, type: :component do
|
||||
describe Widget::Feeds::FeedComponent do
|
||||
it "renders a message when there are no items" do
|
||||
feed = double(kind: "debates", items: [])
|
||||
component = Widget::Feeds::FeedComponent.new(feed)
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
require "rails_helper"
|
||||
|
||||
describe Widget::Feeds::ProcessComponent, type: :component do
|
||||
describe Widget::Feeds::ProcessComponent do
|
||||
let(:process) { create(:legislation_process, sdg_goals: [SDG::Goal[1]]) }
|
||||
let(:component) { Widget::Feeds::ProcessComponent.new(process) }
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
require "rails_helper"
|
||||
|
||||
describe Widget::Feeds::ProposalComponent, type: :component do
|
||||
describe Widget::Feeds::ProposalComponent do
|
||||
let(:proposal) { create(:proposal, sdg_goals: [SDG::Goal[1]]) }
|
||||
let(:component) { Widget::Feeds::ProposalComponent.new(proposal) }
|
||||
|
||||
|
||||
@@ -20,6 +20,10 @@ RSpec.configure do |config|
|
||||
config.include(CommonActions)
|
||||
config.include(ActiveSupport::Testing::TimeHelpers)
|
||||
|
||||
config.define_derived_metadata(file_path: Regexp.new("/spec/components/")) do |metadata|
|
||||
metadata[:type] = :component
|
||||
end
|
||||
|
||||
config.before(:suite) do
|
||||
Rails.application.load_seed
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user