Move map location fields partial to a component
This way it'll be easier to test it and refactor it.
This commit is contained in:
28
spec/components/map_locations/form_fields_component_spec.rb
Normal file
28
spec/components/map_locations/form_fields_component_spec.rb
Normal file
@@ -0,0 +1,28 @@
|
||||
require "rails_helper"
|
||||
|
||||
describe MapLocations::FormFieldsComponent do
|
||||
let(:proposal) { Proposal.new }
|
||||
let(:map_location) { MapLocation.new }
|
||||
let(:form) { ConsulFormBuilder.new(:proposal, proposal, ApplicationController.new.view_context, {}) }
|
||||
let(:label) { "Map location" }
|
||||
let(:help) { "Add a marker" }
|
||||
let(:component) do
|
||||
MapLocations::FormFieldsComponent.new(form, map_location: map_location, label: label, help: help)
|
||||
end
|
||||
|
||||
it "is rendered when the map feature is enabled" do
|
||||
Setting["feature.map"] = true
|
||||
|
||||
render_inline component
|
||||
|
||||
expect(page).to be_rendered
|
||||
end
|
||||
|
||||
it "is not rendered when the map feature is not enabled" do
|
||||
Setting["feature.map"] = false
|
||||
|
||||
render_inline component
|
||||
|
||||
expect(page).not_to be_rendered
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user