diff options
| author | Robert | 2017-10-27 12:49:47 +0200 |
|---|---|---|
| committer | Xinhui | 2017-11-03 12:26:41 +0100 |
| commit | 703c6cab6b0a5cc8699c846796777937e372a9ad (patch) | |
| tree | 6dceb4dba9cbe89e420b7bdd4dfbfbf3db853431 | |
| parent | b3c941878c8b2224449e7e185d9ea5c7537f0c69 (diff) | |
| download | chouette-core-703c6cab6b0a5cc8699c846796777937e372a9ad.tar.bz2 | |
Refs: #4774;
DB Setup for specs
| -rw-r--r-- | app/controllers/compliance_control_sets_controller.rb | 9 | ||||
| -rw-r--r-- | app/helpers/table_builder_helper.rb | 1 | ||||
| -rw-r--r-- | app/views/compliance_control_sets/grouping.html.slim | 39 | ||||
| -rw-r--r-- | app/views/layouts/navigation/_main_nav_left.html.slim | 21 | ||||
| -rw-r--r-- | config/routes.rb | 1 | ||||
| -rw-r--r-- | spec/features/complience_control_sets_spec.rb | 36 | ||||
| -rw-r--r-- | spec/features/connection_links_spec.rb | 2 | ||||
| -rw-r--r-- | spec/models/compliance_control_spec.rb | 4 |
8 files changed, 97 insertions, 16 deletions
diff --git a/app/controllers/compliance_control_sets_controller.rb b/app/controllers/compliance_control_sets_controller.rb index 570204065..7d695a197 100644 --- a/app/controllers/compliance_control_sets_controller.rb +++ b/app/controllers/compliance_control_sets_controller.rb @@ -29,6 +29,13 @@ class ComplianceControlSetsController < InheritedResources::Base redirect_to(compliance_control_sets_path) end + def grouping + show! do | format | + format.html do + @controls = @compliance_control_set.compliance_controls.to_a + end + end + end protected def begin_of_association_chain @@ -54,4 +61,4 @@ class ComplianceControlSetsController < InheritedResources::Base def compliance_control_set_params params.require(:compliance_control_set).permit(:name, :id) end -end
\ No newline at end of file +end diff --git a/app/helpers/table_builder_helper.rb b/app/helpers/table_builder_helper.rb index 95f53a90d..3eacffa9e 100644 --- a/app/helpers/table_builder_helper.rb +++ b/app/helpers/table_builder_helper.rb @@ -116,6 +116,7 @@ module TableBuilderHelper hcont << content_tag(:th, checkbox(id_name: '0', value: 'all')) end + require 'pry'; binding.pry columns.each do |column| if overhead.empty? hcont << content_tag(:th, build_column_header( diff --git a/app/views/compliance_control_sets/grouping.html.slim b/app/views/compliance_control_sets/grouping.html.slim new file mode 100644 index 000000000..d527601b2 --- /dev/null +++ b/app/views/compliance_control_sets/grouping.html.slim @@ -0,0 +1,39 @@ +/ 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 + .row + .col-lg-12 + h2 + = transport_mode("", "") + .row + .col-lg-12 + .select_table + = table_builder_2 @coontrols, \ + [ \ + TableBuilderHelper::Column.new( \ + key: :code, \ + attribute: 'code' \ + ), \ + TableBuilderHelper::Column.new( \ + key: :name, \ + attribute: 'name', \ + link_to: lambda do |compliance_control| \ + compliance_control_set_compliance_control_path(@compliance_control_set, compliance_control) \ + end \ + ), \ + TableBuilderHelper::Column.new( \ + key: :criticity, \ + attribute: 'criticity' \ + ), \ + TableBuilderHelper::Column.new( \ + key: :comment, \ + attribute: 'comment' \ + ), \ + ], + sortable: true, + cls: 'table has-filter has-search' + diff --git a/app/views/layouts/navigation/_main_nav_left.html.slim b/app/views/layouts/navigation/_main_nav_left.html.slim index 062c9383c..837b9cb73 100644 --- a/app/views/layouts/navigation/_main_nav_left.html.slim +++ b/app/views/layouts/navigation/_main_nav_left.html.slim @@ -31,16 +31,17 @@ #miTwo.panel-collapse.collapse .list-group - = 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 - = link_to calendars_path, class: 'list-group-item' do - span Modèles de calendrier - = link_to workbench_compliance_check_sets_path(current_offer_workbench), class: 'list-group-item' do - span Rapport de contrôle - = link_to compliance_control_sets_path, class: 'list-group-item' do - span Jeux de contrôle + - if current_user + = 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 + = link_to calendars_path, class: 'list-group-item' do + span Modèles de calendrier + = link_to workbench_compliance_check_sets_path(current_offer_workbench), class: 'list-group-item' do + span Rapport de contrôle + = link_to compliance_control_sets_path, class: 'list-group-item' do + span Jeux de contrôle .menu-item.panel .panel-heading diff --git a/config/routes.rb b/config/routes.rb index b105e77d6..41897e159 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -75,6 +75,7 @@ ChouetteIhm::Application.routes.draw do resources :compliance_control_sets do get :clone, on: :member + get :grouping, on: :member resources :compliance_controls, except: :index do get :select_type, on: :collection end diff --git a/spec/features/complience_control_sets_spec.rb b/spec/features/complience_control_sets_spec.rb new file mode 100644 index 000000000..0acf42d7f --- /dev/null +++ b/spec/features/complience_control_sets_spec.rb @@ -0,0 +1,36 @@ +RSpec.describe "ComplianceControlSets", type: :feature do + + login_user + + let( :control_set ){ create :compliance_control_set } + let( :min_max_class ){ GenericAttributeControl::MinMax } + let( :pattern_class ){ GenericAttributeControl::Pattern } + + let( :common_atts ){{ + compliance_control_set: control_set, + }} + + + let(:blox){ + 3.times.map{ | _ | create :compliance_control_block, compliance_control_set: control_set } + } + + before do + blox.each do | block | + create( :generic_attribute_control_min_max, code: random_string, compliance_control_block: block, **common_atts ) + create( :generic_attribute_control_pattern, code: random_string, compliance_control_block: block, **common_atts ) + end + end + + describe 'show' do + it 'check setup' do + each_kind_count = 3 + expect( min_max_class.count ).to eq(each_kind_count) + expect( pattern_class.count ).to eq(each_kind_count) + query = ComplianceControl.group(:compliance_control_block) + require 'pry'; binding.pry + end + + end + +end diff --git a/spec/features/connection_links_spec.rb b/spec/features/connection_links_spec.rb index 7272242fe..2f6283dcd 100644 --- a/spec/features/connection_links_spec.rb +++ b/spec/features/connection_links_spec.rb @@ -1,4 +1,4 @@ -RSpec.describe "ConnectionLinks", :type => :feature do +RSpec.describe "ConnectionLinks", type: :feature do login_user let!(:connection_links) { Array.new(2) { create(:connection_link) } } diff --git a/spec/models/compliance_control_spec.rb b/spec/models/compliance_control_spec.rb index db73dab21..4267459ea 100644 --- a/spec/models/compliance_control_spec.rb +++ b/spec/models/compliance_control_spec.rb @@ -4,10 +4,6 @@ RSpec.describe ComplianceControl, type: :model do let(:compliance_control) { build_stubbed :compliance_control } - it 'should have a valid factory' do - expect(compliance_control).to be_valid - end - it { should belong_to :compliance_control_set } it { should belong_to :compliance_control_block } |
