Files
nairobi/spec/components/sdg_management/relations/index_component_spec.rb
Senén Rodero Rodríguez c6407d82e3 Add filters to SDG relations controller
We have three filters: "pending", "all" and "reviewed". Where "pending"
is the default one.

Now we are rendering the `shared/_filter_subnav` partial we need to stub
helper methods defined at the controller and the helper methods that
rely on the request parameters to test the component.
2021-01-19 14:56:30 +01:00

27 lines
1.0 KiB
Ruby

require "rails_helper"
describe SDGManagement::Relations::IndexComponent, type: :component do
before do
allow(ViewComponent::Base).to receive(:test_controller).and_return("SDGManagement::RelationsController")
allow_any_instance_of(SDGManagement::RelationsController).to receive(:valid_filters)
.and_return(SDGManagement::RelationsController::FILTERS)
allow_any_instance_of(SDGManagement::RelationsController).to receive(:current_filter)
.and_return(SDGManagement::RelationsController::FILTERS.first)
allow_any_instance_of(ApplicationHelper).to receive(:current_path_with_query_params)
.and_return("/anything")
end
describe "#goal_options" do
it "orders goals by code in the select" do
component = SDGManagement::Relations::IndexComponent.new(Proposal.none.page(1))
render_inline component
options = page.find("#goal_code").all("option")
expect(options[0]).to have_content "All goals"
expect(options[1]).to have_content "1. "
expect(options[17]).to have_content "17. "
end
end
end