aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLuc Donnet2017-12-11 12:15:46 +0100
committerGitHub2017-12-11 12:15:46 +0100
commit4a020f3e4ad795a780617febbc364a6f270d310d (patch)
tree7d5b77114773f2b31e91d6fc138ae6c39bda5a7a
parent2f10d889ec1bb123bc22eb1ca4e7662b33e555cc (diff)
parent46f530c45d53607949eb29349a0a30f51d42a71f (diff)
downloadchouette-core-4a020f3e4ad795a780617febbc364a6f270d310d.tar.bz2
Merge pull request #140 from af83/5197-compliance-control-set-view-spec
5197 compliance control set view spec
-rw-r--r--app/helpers/compliance_control_sets_helper.rb34
-rw-r--r--app/views/compliance_control_sets/show.html.slim3
-rw-r--r--spec/features/compliance_control_sets_spec.rb10
-rw-r--r--spec/helpers/compliance_control_sets_helper_spec.rb15
4 files changed, 26 insertions, 36 deletions
diff --git a/app/helpers/compliance_control_sets_helper.rb b/app/helpers/compliance_control_sets_helper.rb
index b5d0c5afc..57e6d9608 100644
--- a/app/helpers/compliance_control_sets_helper.rb
+++ b/app/helpers/compliance_control_sets_helper.rb
@@ -4,12 +4,12 @@ module ComplianceControlSetsHelper
[current_organisation, Organisation.find_by_name("STIF")].uniq
end
- def flotted_links ccs_id = @compliance_control_set
+ def floating_links ccs_id
links = [new_control(ccs_id), new_block(ccs_id)]
- unless links.all? &:nil?
- content_tag :div, class: 'select_toolbox' do
+ if links.any?
+ content_tag :div, class: 'select_toolbox', id: 'floating-links' do
content_tag :ul do
- links.collect {|link| concat content_tag(:li, link, class: 'st_action with_text') unless link.nil?}
+ links.collect {|link| concat content_tag(:li, link, class: 'st_action with_text') if link}
end
end
end
@@ -21,8 +21,6 @@ module ComplianceControlSetsHelper
concat content_tag :span, nil, class: 'fa fa-plus'
concat content_tag :span, t('compliance_control_sets.actions.add_compliance_control')
end
- else
- nil
end
end
@@ -32,8 +30,6 @@ module ComplianceControlSetsHelper
concat content_tag :span, nil, class: 'fa fa-plus'
concat content_tag :span,t('compliance_control_sets.actions.add_compliance_control_block')
end
- else
- nil
end
end
@@ -66,7 +62,7 @@ module ComplianceControlSetsHelper
content_tag :div, class: 'btn-group' do
dropdown_button + dropdown_menu
end
-
+
end
def render_compliance_controls(compliance_controls)
@@ -81,7 +77,7 @@ module ComplianceControlSetsHelper
def render_table_builder(compliance_controls)
table = content_tag :div, class: 'select_table' do
table_builder_2 compliance_controls,
- [
+ [
TableBuilderHelper::Column.new(
key: :code,
attribute: 'code'
@@ -90,8 +86,8 @@ module ComplianceControlSetsHelper
key: :name,
attribute: 'name',
link_to: lambda do |compliance_control|
- compliance_control_set_compliance_control_path(@compliance_control_set, compliance_control)
- end
+ compliance_control_set_compliance_control_path(@compliance_control_set, compliance_control)
+ end
),
TableBuilderHelper::Column.new(
key: :criticity,
@@ -101,16 +97,16 @@ module ComplianceControlSetsHelper
key: :comment,
attribute: 'comment'
),
- ],
- sortable: true,
- cls: 'table has-filter has-search',
- model: ComplianceControl
+ ],
+ sortable: true,
+ cls: 'table has-filter has-search',
+ model: ComplianceControl
end
- metas = content_tag :div, I18n.t('compliance_control_blocks.metas.control', count: compliance_controls.count), class: 'pull-right'
- table + metas
+ metas = content_tag :div, I18n.t('compliance_control_blocks.metas.control', count: compliance_controls.count), class: 'pull-right'
+ table + metas
end
def render_no_controls
content_tag :div, I18n.t('compliance_control_blocks.metas.control.zero'), class: 'alert alert-warning'
end
-end \ No newline at end of file
+end
diff --git a/app/views/compliance_control_sets/show.html.slim b/app/views/compliance_control_sets/show.html.slim
index 4385505b0..851a4a41a 100644
--- a/app/views/compliance_control_sets/show.html.slim
+++ b/app/views/compliance_control_sets/show.html.slim
@@ -46,5 +46,4 @@
.col-lg-12
= replacement_msg t('compliance_controls.search_no_results')
- / flotted buttons
- = flotted_links @compliance_control_set.id
+ = floating_links @compliance_control_set.id
diff --git a/spec/features/compliance_control_sets_spec.rb b/spec/features/compliance_control_sets_spec.rb
index 64125a577..36dc5c2a9 100644
--- a/spec/features/compliance_control_sets_spec.rb
+++ b/spec/features/compliance_control_sets_spec.rb
@@ -22,6 +22,9 @@ RSpec.describe "ComplianceControlSets", type: :feature do
end
describe 'show' do
+ let( :control_button_href ){ select_type_compliance_control_set_compliance_controls_path(control_set) }
+ let( :new_group_button_href ) { new_compliance_control_set_compliance_control_block_path(control_set) }
+
before do
visit compliance_control_set_path( control_set )
end
@@ -41,6 +44,13 @@ RSpec.describe "ComplianceControlSets", type: :feature do
controls.each do | control |
expect( page ).to have_content(control.code)
end
+
+ # Floating Buttons
+ within '.select_toolbox#floating-links' do
+ expect( page ).to have_link("ContrĂ´le", href: control_button_href)
+ expect( page ).to have_link("Groupe de contrĂ´les", href: new_group_button_href)
+ end
+
end
it 'we can apply a severity filter' do
diff --git a/spec/helpers/compliance_control_sets_helper_spec.rb b/spec/helpers/compliance_control_sets_helper_spec.rb
deleted file mode 100644
index 981368561..000000000
--- a/spec/helpers/compliance_control_sets_helper_spec.rb
+++ /dev/null
@@ -1,15 +0,0 @@
-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