-
-
Notifications
You must be signed in to change notification settings - Fork 398
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[FEATURE] Do not allow to delete areas when they have dependent space…
…s. (#5041) * [FEATURE] Do not allow to delete areas when they have dependent spaces. * Add changelog entry. * [TEST] Set ParticipatoryProcess.area field in factory to nil as default. * [REFACTOR] Remove dependency from ParticipatoryProcesses and Assembiles modules by invoking the manifest registry. * [REFACTOR] Extract method from command to model where it belongs. * [REFACTOR] Extract tests to the modules where they belong to. * [REFACTOR] Use before_destroy callback so that code is more extendable. * Rubocopify.
- Loading branch information
1 parent
ddc1a27
commit 8e740c5
Showing
10 changed files
with
115 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
decidim-assemblies/spec/commands/admin/destroy_area_with_assemblies_spec.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# frozen_string_literal: true | ||
|
||
require "spec_helper" | ||
|
||
module Decidim::Admin | ||
describe DestroyArea do | ||
subject { described_class.new(area, user) } | ||
|
||
let(:organization) { create :organization } | ||
let(:user) { create :user, :admin, :confirmed, organization: organization } | ||
let(:area) { create :area, organization: organization } | ||
|
||
context "when an assembly associated to a given area exist" do | ||
let!(:assembly) { create(:assembly, organization: organization, area: area) } | ||
|
||
it "can not be deleted" do | ||
expect { subject.call }.to broadcast(:has_spaces) | ||
expect(area.reload.destroyed?).to be false | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
decidim-participatory_processes/spec/commands/admin/destroy_area_with_processes_spec.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# frozen_string_literal: true | ||
|
||
require "spec_helper" | ||
|
||
module Decidim::Admin | ||
describe DestroyArea do | ||
subject { described_class.new(area, user) } | ||
|
||
let(:organization) { create :organization } | ||
let(:user) { create :user, :admin, :confirmed, organization: organization } | ||
let(:area) { create :area, organization: organization } | ||
|
||
context "when a participatory process associated to a given area exist" do | ||
let!(:process) { create(:participatory_process, organization: organization, area: area) } | ||
|
||
it "can not be deleted" do | ||
expect { subject.call }.to broadcast(:has_spaces) | ||
expect(area.reload.destroyed?).to be false | ||
end | ||
end | ||
end | ||
end |