Skip to content

Commit

Permalink
tests
Browse files Browse the repository at this point in the history
  • Loading branch information
microstudi committed Nov 28, 2019
1 parent ef60cca commit c295091
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 6 deletions.
4 changes: 2 additions & 2 deletions config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
14 changes: 14 additions & 0 deletions spec/commands/save_area_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ module Decidim::NavigationMaps
{
area: data,
area_id: area_id,
no_popup: no_popup,
title: title,
description: title,
link: link,
Expand All @@ -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
Expand Down Expand Up @@ -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
10 changes: 10 additions & 0 deletions spec/controllers/blueprint_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 6 additions & 4 deletions spec/model/blueprint_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ module NavigationMaps
geometry: data,
properties: {
link: "#link",
popup: false,
color: "#f00",
title: title[:en],
description: description[:en]
Expand All @@ -59,6 +60,7 @@ module NavigationMaps
geometry: data,
properties: {
link: "#another_link",
popup: false,
color: "#f0f",
title: title[:en],
description: description[:en]
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit c295091

Please sign in to comment.