diff --git a/config/locales/en.yml b/config/locales/en.yml index 21c5c90..519f68c 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -7,11 +7,11 @@ en: navigation_maps: admin: areas: - form: - no_popup: Do not use a popup, link the area directly. create: error: An error ocurred while creating the area success: Area created successfully + form: + no_popup: Do not use a popup, link the area directly. new: area: New area details cancel: Cancel diff --git a/spec/commands/save_area_spec.rb b/spec/commands/save_area_spec.rb index 0f94c56..636c5d8 100644 --- a/spec/commands/save_area_spec.rb +++ b/spec/commands/save_area_spec.rb @@ -16,6 +16,7 @@ module Decidim::NavigationMaps { area: data, area_id: area_id, + no_popup: no_popup, title: title, description: title, link: link, @@ -28,6 +29,7 @@ module Decidim::NavigationMaps let(:title) { Decidim::Faker::Localized.sentence(2) } let(:description) { Decidim::Faker::Localized.paragraph } let(:area_id) { nil } + let(:no_popup) { "0" } let(:link) { "#link" } before do @@ -69,5 +71,17 @@ module Decidim::NavigationMaps expect { subject.call }.to change(BlueprintArea, :count).by(1) end end + + context "when no popup wanted" do + let(:no_popup) { "1" } + + it "broadcasts ok" do + expect { subject.call }.to broadcast(:ok) + end + + it "creates the area" do + expect { subject.call }.to change(BlueprintArea, :count).by(1) + end + end end end diff --git a/spec/controllers/blueprint_controller_spec.rb b/spec/controllers/blueprint_controller_spec.rb index c1e381a..0e1b5ad 100644 --- a/spec/controllers/blueprint_controller_spec.rb +++ b/spec/controllers/blueprint_controller_spec.rb @@ -32,6 +32,16 @@ module Decidim::NavigationMaps::Admin end end + describe "GET #show" do + let!(:blueprint) { create(:blueprint, organization: organization) } + + it "returns http success" do + get :show, params: { id: blueprint.id } + expect(response).to have_http_status(:success) + expect(JSON.parse(response.body)["id"]).to eq(blueprint.id) + end + end + describe "POST #create" do it "returns http success" do post :create diff --git a/spec/model/blueprint_spec.rb b/spec/model/blueprint_spec.rb index 842b805..b5f21e0 100644 --- a/spec/model/blueprint_spec.rb +++ b/spec/model/blueprint_spec.rb @@ -49,6 +49,7 @@ module NavigationMaps geometry: data, properties: { link: "#link", + popup: false, color: "#f00", title: title[:en], description: description[:en] @@ -59,6 +60,7 @@ module NavigationMaps geometry: data, properties: { link: "#another_link", + popup: false, color: "#f0f", title: title[:en], description: description[:en] @@ -88,9 +90,9 @@ module NavigationMaps end it "blueprint contains areas" do - expect(blueprint.areas).to include(area1) - expect(blueprint.areas).to include(area2) - expect(blueprint.areas).not_to include(area3) + expect(subject.areas).to include(area1) + expect(subject.areas).to include(area2) + expect(subject.areas).not_to include(area3) end it "compacts json areas in a single object" do @@ -100,7 +102,7 @@ module NavigationMaps area2.area = data area2.area_id = "102" area2.save - expect(blueprint.blueprint).to eq(blueprint_object) + expect(subject.blueprint).to eq(blueprint_object) end end end