diff options
| author | Luc Donnet | 2017-11-30 22:08:59 +0100 |
|---|---|---|
| committer | GitHub | 2017-11-30 22:08:59 +0100 |
| commit | 2a62685b678f78492b9ded08bfb5234fd14cb05a (patch) | |
| tree | dc11c5b787d6f9059c36cc9be56e2b1fcb1c64b0 | |
| parent | 887a5985c6aba4ae65fbdd7c0c40f30186a778f2 (diff) | |
| parent | 69a6bd72fecad790edab7e51e7d6df5ac1c7abba (diff) | |
| download | chouette-core-2a62685b678f78492b9ded08bfb5234fd14cb05a.tar.bz2 | |
Merge pull request #133 from af83/5093-fix_import_policy
5093 fix import policy
| -rw-r--r-- | app/models/compliance_check_set.rb | 8 | ||||
| -rw-r--r-- | app/policies/compliance_check_set_policy.rb | 3 | ||||
| -rw-r--r-- | app/policies/import_policy.rb | 8 | ||||
| -rw-r--r-- | db/migrate/20171128112629_delete_referential_foreign_key_for_compliance_check_set.rb | 9 | ||||
| -rw-r--r-- | db/schema.rb | 7 | ||||
| -rw-r--r-- | spec/policies/import_policy_spec.rb | 14 |
6 files changed, 27 insertions, 22 deletions
diff --git a/app/models/compliance_check_set.rb b/app/models/compliance_check_set.rb index 00cf057f4..d734e5f5a 100644 --- a/app/models/compliance_check_set.rb +++ b/app/models/compliance_check_set.rb @@ -7,11 +7,11 @@ class ComplianceCheckSet < ActiveRecord::Base belongs_to :workbench belongs_to :parent, polymorphic: true - has_many :compliance_check_blocks - has_many :compliance_checks + has_many :compliance_check_blocks, dependent: :destroy + has_many :compliance_checks, dependent: :destroy - has_many :compliance_check_resources - has_many :compliance_check_messages + has_many :compliance_check_resources, dependent: :destroy + has_many :compliance_check_messages, dependent: :destroy enumerize :status, in: %w[new pending successful warning failed running aborted canceled] diff --git a/app/policies/compliance_check_set_policy.rb b/app/policies/compliance_check_set_policy.rb index 171a33347..90323d7c3 100644 --- a/app/policies/compliance_check_set_policy.rb +++ b/app/policies/compliance_check_set_policy.rb @@ -3,5 +3,6 @@ class ComplianceCheckSetPolicy < ApplicationPolicy def resolve scope end + end -end
\ No newline at end of file +end diff --git a/app/policies/import_policy.rb b/app/policies/import_policy.rb index b12dcc167..512bfc8ac 100644 --- a/app/policies/import_policy.rb +++ b/app/policies/import_policy.rb @@ -6,14 +6,10 @@ class ImportPolicy < ApplicationPolicy end def create? - !archived? && user.has_permission?('imports.create') - end - - def destroy? - !archived? && user.has_permission?('imports.destroy') + user.has_permission?('imports.create') end def update? - !archived? && user.has_permission?('imports.update') + user.has_permission?('imports.update') end end diff --git a/db/migrate/20171128112629_delete_referential_foreign_key_for_compliance_check_set.rb b/db/migrate/20171128112629_delete_referential_foreign_key_for_compliance_check_set.rb new file mode 100644 index 000000000..724bdbb61 --- /dev/null +++ b/db/migrate/20171128112629_delete_referential_foreign_key_for_compliance_check_set.rb @@ -0,0 +1,9 @@ +class DeleteReferentialForeignKeyForComplianceCheckSet < ActiveRecord::Migration + def up + remove_foreign_key :compliance_check_sets, :referentials + end + + def down + add_foreign_key :compliance_check_sets, :referentials + end +end diff --git a/db/schema.rb b/db/schema.rb index c6c3bef7e..4650d8812 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20171130180144) do +ActiveRecord::Schema.define(version: 20171128112629) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -417,9 +417,9 @@ ActiveRecord::Schema.define(version: 20171130180144) do t.string "type", limit: 255 t.integer "parent_id", limit: 8 t.string "parent_type" - t.integer "current_step", default: 0 - t.integer "total_steps", default: 0 t.datetime "notified_parent_at" + t.integer "current_step", default: 0 + t.integer "total_steps", default: 0 t.string "creator" end @@ -982,7 +982,6 @@ ActiveRecord::Schema.define(version: 20171130180144) do add_foreign_key "compliance_check_messages", "compliance_check_sets" add_foreign_key "compliance_check_messages", "compliance_checks" add_foreign_key "compliance_check_resources", "compliance_check_sets" - add_foreign_key "compliance_check_sets", "referentials" add_foreign_key "compliance_check_sets", "workbenches" add_foreign_key "compliance_checks", "compliance_check_blocks" add_foreign_key "compliance_checks", "compliance_check_sets" diff --git a/spec/policies/import_policy_spec.rb b/spec/policies/import_policy_spec.rb index fd9f3172c..9c7fca8a5 100644 --- a/spec/policies/import_policy_spec.rb +++ b/spec/policies/import_policy_spec.rb @@ -9,10 +9,10 @@ RSpec.describe ImportPolicy, type: :policy do context 'Non Destructive actions →' do permissions :index? do - it_behaves_like 'always allowed', 'anything', archived: true + it_behaves_like 'always allowed', 'anything' end permissions :show? do - it_behaves_like 'always allowed', 'anything', archived: true + it_behaves_like 'always allowed', 'anything' end end @@ -23,19 +23,19 @@ RSpec.describe ImportPolicy, type: :policy do context 'Destructive actions →' do permissions :create? do - it_behaves_like 'permitted policy', 'imports.create', archived: true + it_behaves_like 'permitted policy', 'imports.create' end permissions :destroy? do - it_behaves_like 'permitted policy', 'imports.destroy', archived: true + it_behaves_like 'always forbidden', 'imports.destroy' end permissions :edit? do - it_behaves_like 'permitted policy', 'imports.update', archived: true + it_behaves_like 'permitted policy', 'imports.update' end permissions :new? do - it_behaves_like 'permitted policy', 'imports.create', archived: true + it_behaves_like 'permitted policy', 'imports.create' end permissions :update? do - it_behaves_like 'permitted policy', 'imports.update', archived: true + it_behaves_like 'permitted policy', 'imports.update' end end end |
