aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.gitignore1
-rw-r--r--Gemfile1
-rw-r--r--Gemfile.lock3
-rw-r--r--app/controllers/compliance_control_sets_controller.rb33
-rw-r--r--app/controllers/compliance_controls_controller.rb22
-rw-r--r--app/decorators/compliance_control_set_decorator.rb26
-rw-r--r--app/helpers/breadcrumb_helper.rb7
-rw-r--r--app/helpers/compliance_control_sets_helper.rb2
-rw-r--r--app/helpers/table_builder_helper.rb1
-rw-r--r--app/helpers/table_builder_helper/url.rb2
-rw-r--r--app/models/compliance_check_message.rb (renamed from app/models/compliance_check_result.rb)2
-rw-r--r--app/models/compliance_control.rb5
-rw-r--r--app/models/compliance_control_set.rb4
-rw-r--r--app/models/generic_attribute_min_max.rb27
-rw-r--r--app/models/organisation.rb1
-rw-r--r--app/policies/compliance_control_set_policy.rb7
-rw-r--r--app/views/compliance_control_sets/_filters.html.slim33
-rw-r--r--app/views/compliance_control_sets/_form.html.slim8
-rw-r--r--app/views/compliance_control_sets/edit.html.slim10
-rw-r--r--app/views/compliance_control_sets/index.html.slim51
-rw-r--r--app/views/compliance_control_sets/new.html.slim11
-rw-r--r--app/views/compliance_control_sets/show.html.slim25
-rw-r--r--app/views/compliance_controls/edit.html.slim0
-rw-r--r--app/views/compliance_controls/index.html.slim0
-rw-r--r--app/views/compliance_controls/new.html.slim0
-rw-r--r--app/views/compliance_controls/show.html.slim0
-rw-r--r--app/views/imports/index.html.slim2
-rw-r--r--app/views/layouts/navigation/_main_nav_left.html.slim14
-rw-r--r--config/locales/compliance_check_results.en.yml3
-rw-r--r--config/locales/compliance_check_results.fr.yml3
-rw-r--r--config/locales/compliance_control_sets.fr.yml21
-rw-r--r--config/locales/import_messages.en.yml5
-rw-r--r--config/locales/import_messages.fr.yml5
-rw-r--r--config/routes.rb6
-rw-r--r--db/migrate/20170915100935_change_crticity_type_for_compliance_control.rb5
-rw-r--r--db/migrate/20170918103913_alter_table_compliance_check_result_to_compliance_check_message.rb5
-rw-r--r--db/schema.rb81
-rw-r--r--lib/tasks/erd.rake4
-rw-r--r--spec/controllers/compliance_control_sets_controller_spec.rb60
-rw-r--r--spec/controllers/compliance_controls_controller_spec.rb59
-rw-r--r--spec/decorators/compliance_control_set_decorator_spec.rb4
-rw-r--r--spec/factories/compliance_check_messages.rb (renamed from spec/factories/compliance_check_results.rb)2
-rw-r--r--spec/factories/compliance_controls.rb4
-rw-r--r--spec/helpers/compliance_control_sets_helper_spec.rb15
-rw-r--r--spec/models/compliance_check_message_spec.rb (renamed from spec/models/compliance_check_result_spec.rb)4
-rw-r--r--spec/models/compliance_control_set_spec.rb3
46 files changed, 507 insertions, 80 deletions
diff --git a/.gitignore b/.gitignore
index 29cc18f2e..41d838ee0 100644
--- a/.gitignore
+++ b/.gitignore
@@ -23,6 +23,7 @@ public/assets/
chouette2.war
vendor/bundle
.ruby-version
+.byebug_history
start.sh
coverage
diff --git a/Gemfile b/Gemfile
index 2334c3fd4..5965602c4 100644
--- a/Gemfile
+++ b/Gemfile
@@ -120,6 +120,7 @@ gem 'acts-as-taggable-on', '~> 4.0.0'
gem 'acts_as_list', '~> 0.6.0'
gem 'acts_as_tree', '~> 2.1.0', require: 'acts_as_tree'
+gem "hstore_accessor", "~> 1.1"
gem 'rabl'
gem 'carrierwave', '~> 1.0'
diff --git a/Gemfile.lock b/Gemfile.lock
index 1e2ac3cf8..fef3270a3 100644
--- a/Gemfile.lock
+++ b/Gemfile.lock
@@ -255,6 +255,8 @@ GEM
hashdiff (0.3.4)
highline (1.7.8)
hike (1.2.3)
+ hstore_accessor (1.1.0)
+ activerecord (>= 4.0.0)
htmlbeautifier (1.3.1)
httparty (0.14.0)
multi_xml (>= 0.5.2)
@@ -602,6 +604,7 @@ DEPENDENCIES
georuby-ext (= 0.0.5)
google-analytics-rails
has_array_of!
+ hstore_accessor (~> 1.1)
htmlbeautifier
i18n-tasks
inherited_resources
diff --git a/app/controllers/compliance_control_sets_controller.rb b/app/controllers/compliance_control_sets_controller.rb
new file mode 100644
index 000000000..1b23becaa
--- /dev/null
+++ b/app/controllers/compliance_control_sets_controller.rb
@@ -0,0 +1,33 @@
+class ComplianceControlSetsController < BreadcrumbController
+ defaults resource_class: ComplianceControlSet
+ respond_to :html
+
+ def index
+ index! do |format|
+ format.html {
+ @compliance_control_sets = decorate_compliance_control_sets(@compliance_control_sets)
+ }
+ end
+ end
+
+ def show
+ show! do
+ @compliance_control_set = @compliance_control_set.decorate
+ end
+ end
+
+ def decorate_compliance_control_sets(compliance_control_sets)
+ ModelDecorator.decorate(
+ compliance_control_sets,
+ with: ComplianceControlSetDecorator
+ )
+ end
+
+ protected
+
+ private
+
+ def compliance_control_set_params
+ params.require(:compliance_control_set).permit(:name)
+ end
+end
diff --git a/app/controllers/compliance_controls_controller.rb b/app/controllers/compliance_controls_controller.rb
new file mode 100644
index 000000000..d198f2cdb
--- /dev/null
+++ b/app/controllers/compliance_controls_controller.rb
@@ -0,0 +1,22 @@
+class ComplianceControlsController < BreadcrumbController
+ defaults resource_class: ComplianceControl
+ belongs_to :compliance_control_set
+
+ def create
+ create!(notice: t('notice.compliance_control.created'))
+ end
+
+ def update
+ path = compliance_control_set_compliance_control_path(parent, resource)
+ update!(notice: t('notice.compliance_control.updated')) { path }
+ end
+
+ def destroy
+ destroy!(notice: t('notice.compliance_control.destroyed'))
+ end
+
+ private
+ def compliance_control_params
+ params.require(:compliance_control).permit(:name, :code, :criticity, :comment, :control_attributes)
+ end
+end
diff --git a/app/decorators/compliance_control_set_decorator.rb b/app/decorators/compliance_control_set_decorator.rb
new file mode 100644
index 000000000..876a54d09
--- /dev/null
+++ b/app/decorators/compliance_control_set_decorator.rb
@@ -0,0 +1,26 @@
+class ComplianceControlSetDecorator < Draper::Decorator
+ delegate_all
+
+ def action_links
+ links = []
+
+ # if h.policy(object).destroy?
+ links << Link.new(
+ content: h.destroy_link_content,
+ href: h.compliance_control_set_path(object.id),
+ method: :delete,
+ data: { confirm: h.t('compliance_control_sets.actions.destroy_confirm') }
+ )
+ # end
+
+ # if h.policy(object).edit?
+ links << Link.new(
+ content: h.t('compliance_control_sets.actions.edit'),
+ href: h.edit_compliance_control_set_path(object.id)
+ )
+ # end
+ links
+ end
+
+end
+
diff --git a/app/helpers/breadcrumb_helper.rb b/app/helpers/breadcrumb_helper.rb
index 55031d4f3..a3ee9de72 100644
--- a/app/helpers/breadcrumb_helper.rb
+++ b/app/helpers/breadcrumb_helper.rb
@@ -50,6 +50,8 @@ module BreadcrumbHelper
compliance_check_breadcrumb action
when "ComplianceCheckTask"
compliance_check_task_breadcrumb action
+ when "ComplianceControlSets"
+ compliance_control_sets_breadcrumb action
when "RuleParameterSet"
rule_parameter_breadcrumb action
when "User"
@@ -239,6 +241,11 @@ module BreadcrumbHelper
add_breadcrumb breadcrumb_label(@compliance_check_task), referential_compliance_check_task_path(@referential, @compliance_check_task),:title => breadcrumb_tooltip(@compliance_check_task) if action == :edit
end
+ def compliance_control_sets_breadcrumb (action)
+ add_breadcrumb I18n.t("breadcrumbs.referentials"), workbenches_path
+ #add_breadcrumb breadcrumb_label(@workbench), workbench_path(@workbench), :title => breadcrumb_tooltip(@workbench)
+ end
+
def rule_parameter_breadcrumb (action)
organisation_breadcrumb
add_breadcrumb Referential.human_attribute_name("rule_parameter_sets"), organisation_path unless action == :index
diff --git a/app/helpers/compliance_control_sets_helper.rb b/app/helpers/compliance_control_sets_helper.rb
new file mode 100644
index 000000000..3e02e0ef7
--- /dev/null
+++ b/app/helpers/compliance_control_sets_helper.rb
@@ -0,0 +1,2 @@
+module ComplianceControlSetsHelper
+end
diff --git a/app/helpers/table_builder_helper.rb b/app/helpers/table_builder_helper.rb
index ec4d487c1..95f53a90d 100644
--- a/app/helpers/table_builder_helper.rb
+++ b/app/helpers/table_builder_helper.rb
@@ -344,7 +344,6 @@ module TableBuilderHelper
)
end
end
-
def gear_menu_link(link)
content_tag(
:li,
diff --git a/app/helpers/table_builder_helper/url.rb b/app/helpers/table_builder_helper/url.rb
index f7ba703ae..a53ac5620 100644
--- a/app/helpers/table_builder_helper/url.rb
+++ b/app/helpers/table_builder_helper/url.rb
@@ -3,7 +3,7 @@ module TableBuilderHelper
def self.polymorphic_url_parts(item, referential)
polymorph_url = []
- unless item.is_a?(Calendar) || item.is_a?(Referential)
+ unless item.is_a?(Calendar) || item.is_a?(Referential) || item.is_a?(ComplianceControlSet)
if referential
polymorph_url << referential
polymorph_url << item.line if item.respond_to? :line
diff --git a/app/models/compliance_check_result.rb b/app/models/compliance_check_message.rb
index 161e45189..86899eb15 100644
--- a/app/models/compliance_check_result.rb
+++ b/app/models/compliance_check_message.rb
@@ -1,4 +1,4 @@
-class ComplianceCheckResult < ActiveRecord::Base
+class ComplianceCheckMessage < ActiveRecord::Base
belongs_to :compliance_check
belongs_to :compliance_check_resource
end
diff --git a/app/models/compliance_control.rb b/app/models/compliance_control.rb
index 64556b524..12ff4737a 100644
--- a/app/models/compliance_control.rb
+++ b/app/models/compliance_control.rb
@@ -2,8 +2,11 @@ class ComplianceControl < ActiveRecord::Base
belongs_to :compliance_control_set
belongs_to :compliance_control_block
- enum criticity: [:info, :warning, :error]
+ extend Enumerize
+ enumerize :criticity, in: %i(info warning error), scope: true, default: :info
+
validates :criticity, presence: true
validates :name, presence: true
validates :code, presence: true
+ validates :compliance_control_set, presence: true
end
diff --git a/app/models/compliance_control_set.rb b/app/models/compliance_control_set.rb
index 7801eb612..cefdfbf1f 100644
--- a/app/models/compliance_control_set.rb
+++ b/app/models/compliance_control_set.rb
@@ -1,3 +1,7 @@
class ComplianceControlSet < ActiveRecord::Base
belongs_to :organisation
+ has_many :compliance_controls
+
+ validates :name, presence: true
+
end
diff --git a/app/models/generic_attribute_min_max.rb b/app/models/generic_attribute_min_max.rb
new file mode 100644
index 000000000..e9a127c56
--- /dev/null
+++ b/app/models/generic_attribute_min_max.rb
@@ -0,0 +1,27 @@
+#module ComplianceControls
+
+ class GenericAttributeMinMax < ComplianceControl
+
+
+ hstore_accessor :control_attributes, minimum: :integer, maximum: :integer
+ #attribute :minimum, type: :integer, optionnal: true
+ #attribute :maximum, type: :integer, optionnal: true
+ # #attribute :target, type: ModelAttribute
+
+ @@default_criticity = :warning
+ @@default_code = "3-Generic-2"
+
+ validate :min_max_values
+ def min_max_values
+ true
+ end
+
+ after_initialize do
+ self.name = 'GenericAttributeMinMax'
+ self.code = @@default_code
+ self.criticity = @@default_criticity
+ end
+
+ end
+
+#end
diff --git a/app/models/organisation.rb b/app/models/organisation.rb
index 895ca03d9..ba65ad375 100644
--- a/app/models/organisation.rb
+++ b/app/models/organisation.rb
@@ -4,6 +4,7 @@ class Organisation < ActiveRecord::Base
has_many :users, :dependent => :destroy
has_many :referentials, :dependent => :destroy
has_many :rule_parameter_sets, :dependent => :destroy
+ has_many :compliance_control_sets, :dependent => :destroy
has_many :stop_area_referential_memberships
has_many :stop_area_referentials, through: :stop_area_referential_memberships
diff --git a/app/policies/compliance_control_set_policy.rb b/app/policies/compliance_control_set_policy.rb
new file mode 100644
index 000000000..12b829aa4
--- /dev/null
+++ b/app/policies/compliance_control_set_policy.rb
@@ -0,0 +1,7 @@
+class ComplianceControlSetPolicy < ApplicationPolicy
+ class Scope < Scope
+ def resolve
+ scope
+ end
+ end
+end
diff --git a/app/views/compliance_control_sets/_filters.html.slim b/app/views/compliance_control_sets/_filters.html.slim
new file mode 100644
index 000000000..8da629e9c
--- /dev/null
+++ b/app/views/compliance_control_sets/_filters.html.slim
@@ -0,0 +1,33 @@
+= search_form_for @q_for_form, url: workbench_path(@workbench.id), builder: SimpleForm::FormBuilder, class: 'form form-filter' do |f|
+ .ffg-row
+ .input-group.search_bar
+ = f.search_field :name_cont, class: 'form-control', placeholder: t('referentials.filters.name')
+ span.input-group-btn
+ button.btn.btn-default type='submit'
+ span.fa.fa-search
+
+ .ffg-row
+ .form-group
+ = f.label t('activerecord.models.line.one').upcase, required: false, class: 'control-label'
+ = f.input :associated_lines_id_eq, as: :select, collection: @workbench.lines.includes(:company).order(:name), input_html: { 'data-select2ed': 'true', 'data-select2ed-placeholder': t('referentials.filters.line') }, label: false, label_method: :display_name, wrapper_html: { class: 'select2ed'}
+
+ .form-group.togglable
+ = f.label Referential.human_attribute_name(:status), required: false, class: 'control-label'
+ .form-group.checkbox_list
+ = f.input :archived_at_not_null, label: ("<span>#{t('activerecord.attributes.referential.archived_at')}<span class='fa fa-archive'></span></span>").html_safe, as: :boolean, wrapper_html: { class: 'checkbox-wrapper' }
+ = f.input :archived_at_null, label: ("<span>#{t('activerecord.attributes.referential.archived_at_null')}<span class='sb sb-lg sb-preparing'></span></span>").html_safe, as: :boolean, wrapper_html: { class: 'checkbox-wrapper' }
+
+ .form-group.togglable
+ = f.label t('activerecord.models.organisation.one'), required: false, class: 'control-label'
+ = f.input :organisation_name_eq_any, collection: Organisation.order('name').pluck(:name), as: :check_boxes, label: false, label_method: lambda{|w| ("<span>#{w}</span>").html_safe}, required: false, wrapper_html: { class: 'checkbox_list' }
+
+ .form-group.togglable
+ = f.label Referential.human_attribute_name(:validity_period), required: false, class: 'control-label'
+ .filter_menu
+ = f.simple_fields_for :validity_period do |p|
+ = p.input :begin_gteq, as: :date, label: t('simple_form.from'), wrapper_html: { class: 'date smart_date filter_menu-item' }, default: @begin_range, include_blank: @begin_range ? false : true
+ = p.input :end_lteq, as: :date, label: t('simple_form.to'), wrapper_html: { class: 'date smart_date filter_menu-item' }, default: @end_range, include_blank: @end_range ? false : true
+
+ .actions
+ = link_to t('actions.erase'), @workbench, class: 'btn btn-link'
+ = f.submit t('actions.filter'), class: 'btn btn-default', id: 'referential_filter_btn'
diff --git a/app/views/compliance_control_sets/_form.html.slim b/app/views/compliance_control_sets/_form.html.slim
new file mode 100644
index 000000000..cf144bbd9
--- /dev/null
+++ b/app/views/compliance_control_sets/_form.html.slim
@@ -0,0 +1,8 @@
+= simple_form_for @compliance_control_set, html: { class: 'form-horizontal', id: 'compliance_control_set_form' }, wrapper: :horizontal_form do |f|
+ .row
+ .col-lg-12
+ = f.input :name
+
+ .separator
+
+ = f.button :submit, t('actions.submit'), class: 'btn btn-default formSubmitr', form: 'compliance_control_set_form'
diff --git a/app/views/compliance_control_sets/edit.html.slim b/app/views/compliance_control_sets/edit.html.slim
new file mode 100644
index 000000000..a9b8d7253
--- /dev/null
+++ b/app/views/compliance_control_sets/edit.html.slim
@@ -0,0 +1,10 @@
+/ PageHeader
+= pageheader 'modele-calendrier',
+ t('compliance_control_sets.index.edit')
+
+/ PageContent
+.page_content
+ .container-fluid
+ .row
+ .col-lg-8.col-lg-offset-2.col-md-8.col-md-offset-2.col-sm-10.col-sm-offset-1
+ = render 'form'
diff --git a/app/views/compliance_control_sets/index.html.slim b/app/views/compliance_control_sets/index.html.slim
new file mode 100644
index 000000000..16879af5a
--- /dev/null
+++ b/app/views/compliance_control_sets/index.html.slim
@@ -0,0 +1,51 @@
+/ PageHeader
+- header_params = ['jeux-de-donnees',
+ t('compliance_control_sets.index.title'),
+ '']
+- header_params << link_to(t('compliance_control_sets.actions.new'), new_compliance_control_set_path, class: 'btn btn-default') if policy(Calendar).create?
+= pageheader(*header_params) do
+
+ / Below is secundary actions & optional contents (filters, ...)
+ .row.mb-sm
+ .col-lg-12.text-right
+
+/ PageContent
+.page_content
+ .container-fluid
+ .row
+ .col-lg-12
+ /= render 'filters'
+ .row
+ .col-lg-12
+ .select_table
+ = table_builder_2 @compliance_control_sets,
+ [ \
+ TableBuilderHelper::Column.new( \
+ key: :name, \
+ attribute: 'name', \
+ link_to: lambda do |compliance_control_set| \
+ compliance_control_set_path(@compliance_control_sets, compliance_control_set) \
+ end \
+ ), \
+ TableBuilderHelper::Column.new( \
+ key: :assignment, \
+ attribute: 'assignment' \
+ ), \
+ TableBuilderHelper::Column.new( \
+ key: :owner_jdc, \
+ attribute: 'owner_jdc' \
+ ), \
+ TableBuilderHelper::Column.new( \
+ key: :control_numbers, \
+ attribute: 'control_numbers' \
+ ), \
+ TableBuilderHelper::Column.new( \
+ key: :update, \
+ attribute: '' \
+ ) \
+ ],
+ sortable: true,
+ links: [:show],
+ cls: 'table has-filter has-search'
+
+
diff --git a/app/views/compliance_control_sets/new.html.slim b/app/views/compliance_control_sets/new.html.slim
new file mode 100644
index 000000000..d6be41ee8
--- /dev/null
+++ b/app/views/compliance_control_sets/new.html.slim
@@ -0,0 +1,11 @@
+/ PageHeader
+= pageheader 'modele-calendrier',
+ t('compliance_control_sets.index.new')
+
+
+/ PageContent
+.page_content
+ .container-fluid
+ .row
+ .col-lg-8.col-lg-offset-2.col-md-8.col-md-offset-2.col-sm-10.col-sm-offset-1
+ = render 'form'
diff --git a/app/views/compliance_control_sets/show.html.slim b/app/views/compliance_control_sets/show.html.slim
new file mode 100644
index 000000000..b4a5b2260
--- /dev/null
+++ b/app/views/compliance_control_sets/show.html.slim
@@ -0,0 +1,25 @@
+/ PageHeader
+= pageheader 'jeux-de-donnees',
+ @compliance_control_set.name,
+ 'Lorem ipsum dolor sit amet'
+
+ / Below is secondary actions & optional contents (filters, ...)
+ .row.mb-sm
+ .col-lg-12.text-right
+ - @compliance_control_set.action_links.each do |link|
+ - if link.is_a?(HTMLElement)
+ = link.to_html(class: 'btn btn-primary')
+ - else
+ = link_to link.href,
+ method: link.method,
+ data: link.data,
+ class: 'btn btn-primary' do
+ = link.content
+
+/ PageContent
+.page_content
+ .container-fluid
+ .row
+ .col-lg-6.col-md-6.col-sm-12.col-xs-12
+ = definition_list t('metadatas'),
+ ComplianceControlSet.human_attribute_name(:name) => @compliance_control_set.name \ No newline at end of file
diff --git a/app/views/compliance_controls/edit.html.slim b/app/views/compliance_controls/edit.html.slim
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/app/views/compliance_controls/edit.html.slim
diff --git a/app/views/compliance_controls/index.html.slim b/app/views/compliance_controls/index.html.slim
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/app/views/compliance_controls/index.html.slim
diff --git a/app/views/compliance_controls/new.html.slim b/app/views/compliance_controls/new.html.slim
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/app/views/compliance_controls/new.html.slim
diff --git a/app/views/compliance_controls/show.html.slim b/app/views/compliance_controls/show.html.slim
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/app/views/compliance_controls/show.html.slim
diff --git a/app/views/imports/index.html.slim b/app/views/imports/index.html.slim
index 2203d3584..a6da730f1 100644
--- a/app/views/imports/index.html.slim
+++ b/app/views/imports/index.html.slim
@@ -24,7 +24,7 @@
), \
TableBuilderHelper::Column.new( \
key: :started_at, \
- attribute: Proc.new { |n| l(n.started_at, format: :long) }, \
+ attribute: Proc.new { |n| l(n.started_at, format: :long) if n.started_at }, \
), \
TableBuilderHelper::Column.new( \
key: :name, \
diff --git a/app/views/layouts/navigation/_main_nav_left.html.slim b/app/views/layouts/navigation/_main_nav_left.html.slim
index 4560f5fa0..12139c93b 100644
--- a/app/views/layouts/navigation/_main_nav_left.html.slim
+++ b/app/views/layouts/navigation/_main_nav_left.html.slim
@@ -11,7 +11,7 @@
.menu-item.panel
.panel-heading
h4.panel-title
- = link_to '#miOne', data: { toggle: 'collapse', parent: '#menu-items' }, 'aria-expanded' => 'false' do
+ = link_to '#miOne', data: {toggle: 'collapse', parent: '#menu-items'}, 'aria-expanded' => 'false' do
|Offres courantes
#miOne.panel-collapse.collapse
@@ -26,7 +26,7 @@
.menu-item.panel
.panel-heading
h4.panel-title
- = link_to '#miTwo', data: { toggle: 'collapse', parent: '#menu-items' }, 'aria-expanded' => 'false' do
+ = link_to '#miTwo', data: {toggle: 'collapse', parent: '#menu-items'}, 'aria-expanded' => 'false' do
|Espace de travail
#miTwo.panel-collapse.collapse
@@ -34,18 +34,18 @@
= link_to workbench_path(current_offer_workbench), class: "list-group-item #{params[:controller] == 'workbenches' ? 'active' : ''}" do
span Jeux de données
= link_to workbench_imports_path(current_offer_workbench), class: "list-group-item #{(params[:controller] == 'imports') ? 'active' : ''}" do
- span Import
+ span Import
= link_to calendars_path, class: 'list-group-item' do
span Modèles de calendrier
= link_to '#', class: 'list-group-item' do
span Rapport de contrôle
- = link_to '#', class: 'list-group-item' do
+ = link_to compliance_control_sets_path, class: 'list-group-item' do
span Jeux de contrôle
.menu-item.panel
.panel-heading
h4.panel-title
- = link_to '#miThree', data: { toggle: 'collapse', parent: '#menu-items' }, 'aria-expanded' => 'false' do
+ = link_to '#miThree', data: {toggle: 'collapse', parent: '#menu-items'}, 'aria-expanded' => 'false' do
|Données
#miThree.panel-collapse.collapse
@@ -74,7 +74,7 @@
.menu-item.panel
.panel-heading
h4.panel-title
- = link_to '#miFour', data: { toggle: 'collapse', parent: '#menu-items' }, 'aria-expanded' => 'false' do
+ = link_to '#miFour', data: {toggle: 'collapse', parent: '#menu-items'}, 'aria-expanded' => 'false' do
|Synchronisation
#miFour.panel-collapse.collapse
@@ -87,7 +87,7 @@
.menu-item.panel
.panel-heading
h4.panel-title
- = link_to '#miFive', data: { toggle: 'collapse', parent: '#menu-items' }, 'aria-expanded' => 'false' do
+ = link_to '#miFive', data: {toggle: 'collapse', parent: '#menu-items'}, 'aria-expanded' => 'false' do
|Outils
#miFive.panel-collapse.collapse
diff --git a/config/locales/compliance_check_results.en.yml b/config/locales/compliance_check_results.en.yml
index e0541ab36..cd22aefb1 100644
--- a/config/locales/compliance_check_results.en.yml
+++ b/config/locales/compliance_check_results.en.yml
@@ -1,3 +1,2 @@
en:
- compliance_check_results:
-
+ compliance_check_messages:
diff --git a/config/locales/compliance_check_results.fr.yml b/config/locales/compliance_check_results.fr.yml
index b3ddc53f2..d3fbf0900 100644
--- a/config/locales/compliance_check_results.fr.yml
+++ b/config/locales/compliance_check_results.fr.yml
@@ -1,3 +1,2 @@
fr:
- compliance_check_results:
-
+ compliance_check_messages:
diff --git a/config/locales/compliance_control_sets.fr.yml b/config/locales/compliance_control_sets.fr.yml
new file mode 100644
index 000000000..c230d593c
--- /dev/null
+++ b/config/locales/compliance_control_sets.fr.yml
@@ -0,0 +1,21 @@
+fr:
+ compliance_control_sets:
+ index:
+ title: Jeux de contrôle
+ new: Création d'un jeux de contrôle
+ edit: Édition d'un jeux de contrôle
+ actions:
+ new: Ajouter
+ edit: Editer
+ destroy: Supprimer
+ destroy_confirm: Etes vous sûr de supprimer ce jeux de contrôle ?
+ activerecord:
+ models:
+ compliance_control_set: Calendrier
+ attributes:
+ compliance_control_set:
+ name: Nom
+ assignment: Affectation
+ owner_jdc: Propriétaire du jeu de contrôle
+ control_numbers: Nb contrôle
+ update: Mis a jour \ No newline at end of file
diff --git a/config/locales/import_messages.en.yml b/config/locales/import_messages.en.yml
index 1ecdebcd1..e1ef8a078 100644
--- a/config/locales/import_messages.en.yml
+++ b/config/locales/import_messages.en.yml
@@ -10,7 +10,7 @@ en:
2_netexstif_2_2: "Le fichier calendriers.xml contient une frame nommée %{error_value} non acceptée"
2_netexstif_3_1: "Le fichier %{source_filename} ne contient pas de frame nommée NETEX_OFFRE_LIGNE"
2_netexstif_3_2: "Le fichier %{source_filename} contient une frame nommée %{error_value} non acceptée"
- 2_netexstif_3_3: "la frame NETEX_OFFRE_LIGNE du fichier %{source_filename} ne contient pas la frame %{NETEX_STRUCTURE|NETEX_HORAIRE} obligatoire"
+ 2_netexstif_3_3: "la frame NETEX_OFFRE_LIGNE du fichier %{source_filename} ne contient pas la frame %{error_value} obligatoire"
2_netexstif_3_4: "la frame NETEX_OFFRE_LIGNE du fichier %{source_filename} contient une frame %{error_value} non acceptée"
2_netexstif_4: "%{source_filename}-Ligne %{source_line_number}-Colonne %{source_column_number} : l'identifiant %{source_objectid} de l'objet %{source_label} ne respecte pas la syntaxe [CODESPACE]:%{source_label}:[identifiant Technique]:LOC"
2_netexstif_6: "%{source_filename}-Ligne %{source_line_number}-Colonne %{source_column_number} : l'objet %{source_label} d'identifiant %{source_objectid} a un état de modification interdit : 'delete'"
@@ -46,5 +46,6 @@ en:
2_netexstif_servicejourney_4: "%{source_filename}-Ligne %{source_line_number}-Colonne %{source_column_number} , objet ServiceJourney d'identifiant %{source_objectid} : le passingTime de rang %{error_value} fournit des horaires antérieurs au passingTime précédent."
2_netexstif_servicejourneypattern_1: "%{source_filename}-Ligne %{source_line_number}-Colonne %{source_column_number} : l'objet ServiceJourneyPattern d'identifiant %{source_objectid} ne référence pas de Route"
2_netexstif_servicejourneypattern_2: "%{source_filename}-Ligne %{source_line_number}-Colonne %{source_column_number} : l'objet ServiceJourneyPattern d'identifiant %{source_objectid} doit contenir au moins 2 StopPointInJourneyPattern"
- 2_netexstif_servicejourneypattern_3: "%{source_filename}-Ligne %{source_line_number}-Colonne %{source_column_number} : l'objet ServiceJourneyPattern d'identifiant %{source_objectid} n'a pas de valeur pour l'attribut ServiceJourneyPatternType"
+ 2_netexstif_servicejourneypattern_3_1: "%{source_filename}-Ligne %{source_line_number}-Colonne %{source_column_number} : l'objet ServiceJourneyPattern d'identifiant %{source_objectid} n'a pas de valeur pour l'attribut ServiceJourneyPatternType"
+ 2_netexstif_servicejourneypattern_3_2: "%{source_filename}-Ligne %{source_line_number}-Colonne %{source_column_number} : l'objet ServiceJourneyPattern d'identifiant %{source_objectid} a une valeur interdite %{error_value} pour l'attribut ServiceJourneyPatternType différente de 'passenger'"
2_netexstif_servicejourneypattern_4: "%{source_filename}-Ligne %{source_line_number}-Colonne %{source_column_number}, objet ServiceJourneyPattern d'identifiant %{source_objectid} : les attributs 'order' des StopPointInJourneyPattern ne sont pas croissants."
diff --git a/config/locales/import_messages.fr.yml b/config/locales/import_messages.fr.yml
index 770cb2c30..8d6a4ee91 100644
--- a/config/locales/import_messages.fr.yml
+++ b/config/locales/import_messages.fr.yml
@@ -10,7 +10,7 @@ fr:
2_netexstif_2_2: "Le fichier calendriers.xml contient une frame nommée %{error_value} non acceptée"
2_netexstif_3_1: "Le fichier %{source_filename} ne contient pas de frame nommée NETEX_OFFRE_LIGNE"
2_netexstif_3_2: "Le fichier %{source_filename} contient une frame nommée %{error_value} non acceptée"
- 2_netexstif_3_3: "la frame NETEX_OFFRE_LIGNE du fichier %{source_filename} ne contient pas la frame %{NETEX_STRUCTURE|NETEX_HORAIRE} obligatoire"
+ 2_netexstif_3_3: "la frame NETEX_OFFRE_LIGNE du fichier %{source_filename} ne contient pas la frame %{error_value} obligatoire"
2_netexstif_3_4: "la frame NETEX_OFFRE_LIGNE du fichier %{source_filename} contient une frame %{error_value} non acceptée"
2_netexstif_4: "%{source_filename}-Ligne %{source_line_number}-Colonne %{source_column_number} : l'identifiant %{source_objectid} de l'objet %{source_label} ne respecte pas la syntaxe [CODESPACE]:%{source_label}:[identifiant Technique]:LOC"
2_netexstif_6: "%{source_filename}-Ligne %{source_line_number}-Colonne %{source_column_number} : l'objet %{source_label} d'identifiant %{source_objectid} a un état de modification interdit : 'delete'"
@@ -46,5 +46,6 @@ fr:
2_netexstif_servicejourney_4: "%{source_filename}-Ligne %{source_line_number}-Colonne %{source_column_number} , objet ServiceJourney d'identifiant %{source_objectid} : le passingTime de rang %{error_value} fournit des horaires antérieurs au passingTime précédent."
2_netexstif_servicejourneypattern_1: "%{source_filename}-Ligne %{source_line_number}-Colonne %{source_column_number} : l'objet ServiceJourneyPattern d'identifiant %{source_objectid} ne référence pas de Route"
2_netexstif_servicejourneypattern_2: "%{source_filename}-Ligne %{source_line_number}-Colonne %{source_column_number} : l'objet ServiceJourneyPattern d'identifiant %{source_objectid} doit contenir au moins 2 StopPointInJourneyPattern"
- 2_netexstif_servicejourneypattern_3: "%{source_filename}-Ligne %{source_line_number}-Colonne %{source_column_number} : l'objet ServiceJourneyPattern d'identifiant %{source_objectid} n'a pas de valeur pour l'attribut ServiceJourneyPatternType"
+ 2_netexstif_servicejourneypattern_3_1: "%{source_filename}-Ligne %{source_line_number}-Colonne %{source_column_number} : l'objet ServiceJourneyPattern d'identifiant %{source_objectid} n'a pas de valeur pour l'attribut ServiceJourneyPatternType"
+ 2_netexstif_servicejourneypattern_3_2: "%{source_filename}-Ligne %{source_line_number}-Colonne %{source_column_number} : l'objet ServiceJourneyPattern d'identifiant %{source_objectid} a une valeur interdite %{error_value} pour l'attribut ServiceJourneyPatternType différente de 'passenger'"
2_netexstif_servicejourneypattern_4: "%{source_filename}-Ligne %{source_line_number}-Colonne %{source_column_number}, objet ServiceJourneyPattern d'identifiant %{source_objectid} : les attributs 'order' des StopPointInJourneyPattern ne sont pas croissants."
diff --git a/config/routes.rb b/config/routes.rb
index 0f1b22e44..97e0257c2 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -12,6 +12,8 @@ ChouetteIhm::Application.routes.draw do
end
end
+ resources :compliance_control_sets
+
devise_for :users, :controllers => {
:registrations => 'users/registrations', :invitations => 'users/invitations'
}
@@ -69,6 +71,10 @@ ChouetteIhm::Application.routes.draw do
resources :api_keys, :only => [:edit, :update, :new, :create, :destroy]
+ resources :compliance_control_sets do
+ resources :compliance_controls
+ end
+
resources :stop_area_referentials, :only => [:show] do
post :sync, on: :member
resources :stop_areas
diff --git a/db/migrate/20170915100935_change_crticity_type_for_compliance_control.rb b/db/migrate/20170915100935_change_crticity_type_for_compliance_control.rb
new file mode 100644
index 000000000..f3e7e7339
--- /dev/null
+++ b/db/migrate/20170915100935_change_crticity_type_for_compliance_control.rb
@@ -0,0 +1,5 @@
+class ChangeCrticityTypeForComplianceControl < ActiveRecord::Migration
+ def change
+ change_column :compliance_controls, :criticity, :string
+ end
+end
diff --git a/db/migrate/20170918103913_alter_table_compliance_check_result_to_compliance_check_message.rb b/db/migrate/20170918103913_alter_table_compliance_check_result_to_compliance_check_message.rb
new file mode 100644
index 000000000..c0dc6225a
--- /dev/null
+++ b/db/migrate/20170918103913_alter_table_compliance_check_result_to_compliance_check_message.rb
@@ -0,0 +1,5 @@
+class AlterTableComplianceCheckResultToComplianceCheckMessage < ActiveRecord::Migration
+ def change
+ rename_table :compliance_check_results, :compliance_check_messages
+ end
+end
diff --git a/db/schema.rb b/db/schema.rb
index 5e2edf33d..2b62fa7f1 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: 20170913074922) do
+ActiveRecord::Schema.define(version: 20170918103913) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
@@ -155,17 +155,7 @@ ActiveRecord::Schema.define(version: 20170913074922) do
add_index "compliance_check_blocks", ["compliance_check_set_id"], name: "index_compliance_check_blocks_on_compliance_check_set_id", using: :btree
- create_table "compliance_check_resources", id: :bigserial, force: :cascade do |t|
- t.string "status"
- t.string "name"
- t.string "type"
- t.string "reference"
- t.hstore "metrics"
- t.datetime "created_at", null: false
- t.datetime "updated_at", null: false
- end
-
- create_table "compliance_check_results", id: :bigserial, force: :cascade do |t|
+ create_table "compliance_check_messages", id: :bigserial, force: :cascade do |t|
t.integer "compliance_check_id"
t.integer "compliance_check_resource_id"
t.string "message_key"
@@ -175,8 +165,18 @@ ActiveRecord::Schema.define(version: 20170913074922) do
t.datetime "updated_at", null: false
end
- add_index "compliance_check_results", ["compliance_check_id"], name: "index_compliance_check_results_on_compliance_check_id", using: :btree
- add_index "compliance_check_results", ["compliance_check_resource_id"], name: "index_compliance_check_results_on_compliance_check_resource_id", using: :btree
+ add_index "compliance_check_messages", ["compliance_check_id"], name: "index_compliance_check_messages_on_compliance_check_id", using: :btree
+ add_index "compliance_check_messages", ["compliance_check_resource_id"], name: "index_compliance_check_messages_on_compliance_check_resource_id", using: :btree
+
+ create_table "compliance_check_resources", id: :bigserial, force: :cascade do |t|
+ t.string "status"
+ t.string "name"
+ t.string "type"
+ t.string "reference"
+ t.hstore "metrics"
+ t.datetime "created_at", null: false
+ t.datetime "updated_at", null: false
+ end
create_table "compliance_check_sets", id: :bigserial, force: :cascade do |t|
t.integer "referential_id"
@@ -237,7 +237,7 @@ ActiveRecord::Schema.define(version: 20170913074922) do
t.json "control_attributes"
t.string "name"
t.string "code"
- t.integer "criticity"
+ t.string "criticity"
t.text "comment"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
@@ -270,22 +270,6 @@ ActiveRecord::Schema.define(version: 20170913074922) do
add_index "connection_links", ["objectid"], name: "connection_links_objectid_key", unique: true, using: :btree
- create_table "delayed_jobs", id: :bigserial, force: :cascade do |t|
- t.integer "priority", default: 0
- t.integer "attempts", default: 0
- t.text "handler"
- t.text "last_error"
- t.datetime "run_at"
- t.datetime "locked_at"
- t.datetime "failed_at"
- t.string "locked_by", limit: 255
- t.string "queue", limit: 255
- t.datetime "created_at"
- t.datetime "updated_at"
- end
-
- add_index "delayed_jobs", ["priority", "run_at"], name: "delayed_jobs_priority", using: :btree
-
create_table "exports", id: :bigserial, force: :cascade do |t|
t.integer "referential_id", limit: 8
t.string "status"
@@ -407,12 +391,12 @@ ActiveRecord::Schema.define(version: 20170913074922) do
t.datetime "started_at"
t.datetime "ended_at"
t.string "token_download"
- t.string "type", limit: 255
+ t.string "type"
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
@@ -564,11 +548,6 @@ ActiveRecord::Schema.define(version: 20170913074922) do
add_index "networks", ["objectid"], name: "networks_objectid_key", unique: true, using: :btree
add_index "networks", ["registration_number"], name: "networks_registration_number_key", using: :btree
- create_table "object_id_factories", id: :bigserial, force: :cascade do |t|
- t.datetime "created_at", null: false
- t.datetime "updated_at", null: false
- end
-
create_table "organisations", id: :bigserial, force: :cascade do |t|
t.string "name"
t.datetime "created_at"
@@ -745,7 +724,7 @@ ActiveRecord::Schema.define(version: 20170913074922) do
create_table "stop_areas", id: :bigserial, force: :cascade do |t|
t.integer "parent_id", limit: 8
- t.string "objectid", null: false
+ t.string "objectid", null: false
t.integer "object_version", limit: 8
t.string "creator_id"
t.string "name"
@@ -754,8 +733,8 @@ ActiveRecord::Schema.define(version: 20170913074922) do
t.string "registration_number"
t.string "nearest_topic_name"
t.integer "fare_code"
- t.decimal "longitude", precision: 19, scale: 16
- t.decimal "latitude", precision: 19, scale: 16
+ t.decimal "longitude", precision: 19, scale: 16
+ t.decimal "latitude", precision: 19, scale: 16
t.string "long_lat_type"
t.string "country_code"
t.string "street_name"
@@ -773,7 +752,7 @@ ActiveRecord::Schema.define(version: 20170913074922) do
t.datetime "deleted_at"
t.datetime "created_at"
t.datetime "updated_at"
- t.string "stif_type", limit: 255
+ t.string "stif_type"
end
add_index "stop_areas", ["name"], name: "index_stop_areas_on_name", using: :btree
@@ -844,18 +823,18 @@ ActiveRecord::Schema.define(version: 20170913074922) do
add_index "time_table_periods", ["time_table_id"], name: "index_time_table_periods_on_time_table_id", using: :btree
create_table "time_tables", id: :bigserial, force: :cascade do |t|
- t.string "objectid", null: false
- t.integer "object_version", limit: 8, default: 1
+ t.string "objectid", null: false
+ t.integer "object_version", limit: 8, default: 1
t.string "creator_id"
t.string "version"
t.string "comment"
- t.integer "int_day_types", default: 0
+ t.integer "int_day_types", default: 0
t.date "start_date"
t.date "end_date"
t.integer "calendar_id", limit: 8
t.datetime "created_at"
t.datetime "updated_at"
- t.string "color", limit: 255
+ t.string "color"
t.integer "created_from_id"
t.string "checksum"
t.text "checksum_source"
@@ -987,8 +966,8 @@ ActiveRecord::Schema.define(version: 20170913074922) do
add_foreign_key "access_links", "access_points", name: "aclk_acpt_fkey"
add_foreign_key "api_keys", "organisations"
add_foreign_key "compliance_check_blocks", "compliance_check_sets"
- add_foreign_key "compliance_check_results", "compliance_check_resources"
- add_foreign_key "compliance_check_results", "compliance_checks"
+ add_foreign_key "compliance_check_messages", "compliance_check_resources"
+ add_foreign_key "compliance_check_messages", "compliance_checks"
add_foreign_key "compliance_check_sets", "compliance_control_sets"
add_foreign_key "compliance_check_sets", "referentials"
add_foreign_key "compliance_check_sets", "workbenches"
@@ -999,13 +978,9 @@ ActiveRecord::Schema.define(version: 20170913074922) do
add_foreign_key "compliance_controls", "compliance_control_blocks"
add_foreign_key "compliance_controls", "compliance_control_sets"
add_foreign_key "group_of_lines_lines", "group_of_lines", name: "groupofline_group_fkey", on_delete: :cascade
- add_foreign_key "journey_frequencies", "timebands", name: "journey_frequencies_timeband_id_fk", on_delete: :nullify
add_foreign_key "journey_frequencies", "timebands", on_delete: :nullify
- add_foreign_key "journey_frequencies", "vehicle_journeys", name: "journey_frequencies_vehicle_journey_id_fk", on_delete: :nullify
add_foreign_key "journey_frequencies", "vehicle_journeys", on_delete: :nullify
- add_foreign_key "journey_pattern_sections", "journey_patterns", name: "journey_pattern_sections_journey_pattern_id_fk", on_delete: :cascade
add_foreign_key "journey_pattern_sections", "journey_patterns", on_delete: :cascade
- add_foreign_key "journey_pattern_sections", "route_sections", name: "journey_pattern_sections_route_section_id_fk", on_delete: :cascade
add_foreign_key "journey_pattern_sections", "route_sections", on_delete: :cascade
add_foreign_key "journey_patterns", "routes", name: "jp_route_fkey", on_delete: :cascade
add_foreign_key "journey_patterns", "stop_points", column: "arrival_stop_point_id", name: "arrival_point_fkey", on_delete: :nullify
diff --git a/lib/tasks/erd.rake b/lib/tasks/erd.rake
index a9b1a3454..6b79967de 100644
--- a/lib/tasks/erd.rake
+++ b/lib/tasks/erd.rake
@@ -3,10 +3,10 @@ namespace :generate do
desc "Create model diagrams for Chouette"
task :model_diagram => :environment do
sh "bundle exec rake erd only='Organisation,Referential,User,Workbench' filename='organisation' title='Organisation'"
- sh "bundle exec rake erd only='Calendar,Referential,Chouette::Line,Chouette::Route,Chouette::JourneyPattern,Chouette::VehicleJourney,Chouette::VehicleJourneyAtStop,Chouette::TimeTable,Chouette::TimeTableDate,Chouette::TimeTablePeriod,Chouette::Footnote,Chouette::Network,Chouette::Company,Chouette::StopPoint,Chouette::StopArea' filename='offer_datas' title='Offer Datas'"
+ sh "bundle exec rake erd only='Calendar,Referential,ReferentialMetadata,Chouette::Line,Chouette::Route,Chouette::JourneyPattern,Chouette::VehicleJourney,Chouette::VehicleJourneyAtStop,Chouette::TimeTable,Chouette::TimeTableDate,Chouette::TimeTablePeriod,Chouette::Footnote,Chouette::Network,Chouette::Company,Chouette::StopPoint,Chouette::StopArea' filename='offer_datas' title='Offer Datas'"
sh "bundle exec rake erd only='Organisation,StopAreaReferential,StopAreaReferentialSync,StopAreaReferentialSyncMessage,StopAreaReferentialMembership,LineReferential,LineReferentialSync,LineReferentialSyncMessage,LineReferentialMembership' filename='referentiels_externes' title='Référentiels externes'"
sh "bundle exec rake erd only='NetexImport,Import,WorkbenchImport,ImportResource,ImportMessage' filename='import' title='Import'"
- #sh "bundle exec rake erd only='' filename='validation' title='Validation'"
+ sh "bundle exec rake erd only='ComplianceControlSet,ComplianceControlBlock,ComplianceControl,ComplianceCheckSet,ComplianceCheckBlock,ComplianceCheck,ComplianceCheckResource,ComplianceCheckMessage' filename='validation' title='Validation'"
#sh "bundle exec rake erd only='VehicleJourney,VehicleJourneyExport' filename='export' title='Export'"
#sh "bundle exec rake erd only='' filename='intégration' title='Integration'"
#sh "bundle exec rake erd only='' filename='fusion' title='Fusion'"
diff --git a/spec/controllers/compliance_control_sets_controller_spec.rb b/spec/controllers/compliance_control_sets_controller_spec.rb
new file mode 100644
index 000000000..25d0becfe
--- /dev/null
+++ b/spec/controllers/compliance_control_sets_controller_spec.rb
@@ -0,0 +1,60 @@
+require 'rails_helper'
+
+RSpec.describe ComplianceControlSetsController, type: :controller do
+ login_user
+
+ let(:compliance_control_set) { create :compliance_control_set }
+
+ describe "GET show" do
+ it 'should be successful' do
+ get :show, id: compliance_control_set.id
+ expect(response).to be_success
+ end
+ end
+
+ describe "GET index" do
+ it 'should be successful' do
+ get :index, id: compliance_control_set.id
+ expect(response).to be_success
+ end
+ end
+
+ describe "GET #edit" do
+ it 'should be successful' do
+ get :edit, id: compliance_control_set.id
+ expect(response).to be_success
+ end
+ end
+
+ describe 'GET #new' do
+ it 'should be successful' do
+ get :new, id: compliance_control_set.id
+ expect(response).to be_success
+ end
+ end
+
+ describe 'POST #create' do
+ it 'should be successful' do
+ post :create, compliance_control_set: build(:compliance_control_set).as_json
+ expect(response).to have_http_status(302)
+ # expect(flash[:notice]).to eq(I18n.t('notice.compliance_control.created'))
+ end
+ end
+
+ describe 'POST #update' do
+ it 'should be successful' do
+ post :update, id: compliance_control_set.id, compliance_control_set: compliance_control_set.as_json
+ expect(response).to redirect_to compliance_control_set_path(compliance_control_set)
+ # expect(flash[:notice]).to eq(I18n.t('notice.compliance_control.updated'))
+ end
+ end
+
+ describe 'DELETE #destroy' do
+ it 'should be successful' do
+ delete :destroy, id: compliance_control_set.id
+ # expect(flash[:notice]).to eq I18n.t('notice.compliance_control.destroyed')
+ end
+ end
+
+
+end
diff --git a/spec/controllers/compliance_controls_controller_spec.rb b/spec/controllers/compliance_controls_controller_spec.rb
new file mode 100644
index 000000000..165c00329
--- /dev/null
+++ b/spec/controllers/compliance_controls_controller_spec.rb
@@ -0,0 +1,59 @@
+require 'rails_helper'
+
+RSpec.describe ComplianceControlsController, type: :controller do
+ login_user
+
+ let(:compliance_control) { create :compliance_control }
+ let(:compliance_control_set) { compliance_control.compliance_control_set }
+
+ describe "GET show" do
+ it 'should be successful' do
+ get :show, compliance_control_set_id: compliance_control_set.id, id: compliance_control.id
+ expect(response).to be_success
+ end
+ end
+
+ describe "GET index" do
+ it 'should be successful' do
+ get :index, compliance_control_set_id: compliance_control_set.id
+ expect(response).to be_success
+ end
+ end
+
+ describe 'GET #edit' do
+ it 'should be successful' do
+ get :edit, compliance_control_set_id: compliance_control_set.id, id: compliance_control.id
+ expect(response).to be_success
+ end
+ end
+
+ describe 'GET #new' do
+ it 'should be successful' do
+ get :new, compliance_control_set_id: compliance_control_set.id
+ expect(response).to be_success
+ end
+ end
+
+ describe 'POST #create' do
+ it 'should be successful' do
+ post :create, compliance_control_set_id: compliance_control_set.id, compliance_control: build(:compliance_control).as_json
+ expect(response).to have_http_status(302)
+ expect(flash[:notice]).to eq(I18n.t('notice.compliance_control.created'))
+ end
+ end
+
+ describe 'POST #update' do
+ it 'should be successful' do
+ post :update, compliance_control_set_id: compliance_control_set.id, id: compliance_control.id, compliance_control: compliance_control.as_json
+ expect(response).to redirect_to compliance_control_set_compliance_control_path(compliance_control_set, compliance_control)
+ expect(flash[:notice]).to eq(I18n.t('notice.compliance_control.updated'))
+ end
+ end
+
+ describe 'DELETE #destroy' do
+ it 'should be successful' do
+ delete :destroy, compliance_control_set_id: compliance_control_set.id, id: compliance_control.id
+ expect(flash[:notice]).to eq I18n.t('notice.compliance_control.destroyed')
+ end
+ end
+end
diff --git a/spec/decorators/compliance_control_set_decorator_spec.rb b/spec/decorators/compliance_control_set_decorator_spec.rb
new file mode 100644
index 000000000..64e9ff9e7
--- /dev/null
+++ b/spec/decorators/compliance_control_set_decorator_spec.rb
@@ -0,0 +1,4 @@
+require 'spec_helper'
+
+describe ComplianceControlSetDecorator do
+end
diff --git a/spec/factories/compliance_check_results.rb b/spec/factories/compliance_check_messages.rb
index a56d77ce4..1a047a242 100644
--- a/spec/factories/compliance_check_results.rb
+++ b/spec/factories/compliance_check_messages.rb
@@ -1,5 +1,5 @@
FactoryGirl.define do
- factory :compliance_check_result do
+ factory :compliance_check_message do
association :compliance_check
association :compliance_check_resource
message_key "message_key"
diff --git a/spec/factories/compliance_controls.rb b/spec/factories/compliance_controls.rb
index 28b760383..8aa16b674 100644
--- a/spec/factories/compliance_controls.rb
+++ b/spec/factories/compliance_controls.rb
@@ -1,8 +1,8 @@
FactoryGirl.define do
factory :compliance_control do
sequence(:name) { |n| "Compliance control #{n}" }
- type "Type"
- criticity :info
+ type "ComplianceControl"
+ criticity :warning
code "code"
comment "Text"
association :compliance_control_set
diff --git a/spec/helpers/compliance_control_sets_helper_spec.rb b/spec/helpers/compliance_control_sets_helper_spec.rb
new file mode 100644
index 000000000..981368561
--- /dev/null
+++ b/spec/helpers/compliance_control_sets_helper_spec.rb
@@ -0,0 +1,15 @@
+require 'rails_helper'
+
+# Specs in this file have access to a helper object that includes
+# the ComplianceControlSetsHelper. For example:
+#
+# describe ComplianceControlSetsHelper do
+# describe "string concat" do
+# it "concats two strings with spaces" do
+# expect(helper.concat_strings("this","that")).to eq("this that")
+# end
+# end
+# end
+RSpec.describe ComplianceControlSetsHelper, type: :helper do
+ pending "add some examples to (or delete) #{__FILE__}"
+end
diff --git a/spec/models/compliance_check_result_spec.rb b/spec/models/compliance_check_message_spec.rb
index 95586862f..8b424595e 100644
--- a/spec/models/compliance_check_result_spec.rb
+++ b/spec/models/compliance_check_message_spec.rb
@@ -1,8 +1,8 @@
require 'rails_helper'
-RSpec.describe ComplianceCheckResult, type: :model do
+RSpec.describe ComplianceCheckMessage, type: :model do
it 'should have a valid factory' do
- expect(FactoryGirl.build(:compliance_check_result)).to be_valid
+ expect(FactoryGirl.build(:compliance_check_message)).to be_valid
end
it { should belong_to :compliance_check }
diff --git a/spec/models/compliance_control_set_spec.rb b/spec/models/compliance_control_set_spec.rb
index fb46bc65a..ededec5e0 100644
--- a/spec/models/compliance_control_set_spec.rb
+++ b/spec/models/compliance_control_set_spec.rb
@@ -6,4 +6,7 @@ RSpec.describe ComplianceControlSet, type: :model do
end
it { should belong_to :organisation }
+ it { should have_many :compliance_controls }
+
+ it { should validate_presence_of :name }
end