aboutsummaryrefslogtreecommitdiffstats
path: root/spec
diff options
context:
space:
mode:
authorRobert2017-10-02 10:51:34 +0200
committerRobert2017-10-02 10:51:34 +0200
commit8f11900221be0837e0ee9717746cd4d952a64794 (patch)
tree50654b0b7f2bf29bd8853cac425e5394570509ce /spec
parent6898e54925c93cf44e7d5581d2213d4d3a9ab3c8 (diff)
parenteaf5b3fd868d68856ef94e18656dac39096d866b (diff)
downloadchouette-core-8f11900221be0837e0ee9717746cd4d952a64794.tar.bz2
Merge branch 'master' of github.com:af83/stif-boiv
Diffstat (limited to 'spec')
-rw-r--r--spec/controllers/rule_parameter_sets_controller_spec.rb32
-rw-r--r--spec/factories/compliance_check_messages.rb1
-rw-r--r--spec/factories/compliance_control_blocks.rb1
-rw-r--r--spec/features/api_keys/delete_api_key_feature_spec.rb5
-rw-r--r--spec/features/api_keys/edit_api_key_feature_spec.rb8
-rw-r--r--spec/features/api_keys/new_api_key_feature_spec.rb10
-rw-r--r--spec/models/chouette/transport_mode_spec.rb64
-rw-r--r--spec/models/compliance_check_message_spec.rb1
-rw-r--r--spec/models/compliance_control_block_spec.rb1
-rw-r--r--spec/models/line_referential_spec.rb2
-rw-r--r--spec/models/organisation_spec.rb8
-rw-r--r--spec/models/vehicle_translation_spec.rb2
12 files changed, 36 insertions, 99 deletions
diff --git a/spec/controllers/rule_parameter_sets_controller_spec.rb b/spec/controllers/rule_parameter_sets_controller_spec.rb
index a1d65e92e..0f57855b7 100644
--- a/spec/controllers/rule_parameter_sets_controller_spec.rb
+++ b/spec/controllers/rule_parameter_sets_controller_spec.rb
@@ -1,8 +1,8 @@
-require 'spec_helper'
+# require 'spec_helper'
-describe RuleParameterSetsController, :type => :controller do
- login_user
- let(:mode){"air"}
+# describe RuleParameterSetsController, :type => :controller do
+# login_user
+# let(:mode){"air"}
# shared_examples_for "organisation dependant" do
# it "assigns rule_parameter_set.organisation as current organisation" do
@@ -10,17 +10,17 @@ describe RuleParameterSetsController, :type => :controller do
# end
# end
- describe "GET /index" do
- before(:each) do
- get :index
- end
- it "should assign rule_parameter_sets to organisation rule_parameter_sets" do
- expect(assigns[:rule_parameter_sets].size).to eq(assigns[:rule_parameter_sets][0].organisation.rule_parameter_sets.size)
- assigns[:rule_parameter_sets].each do |rps|
- expect(rps.organisation.id).to eq(assigns[:rule_parameter_sets][0].organisation.id)
- end
- end
- end
+ # describe "GET /index" do
+ # before(:each) do
+ # get :index
+ # end
+ # it "should assign rule_parameter_sets to organisation rule_parameter_sets" do
+ # expect(assigns[:rule_parameter_sets].size).to eq(assigns[:rule_parameter_sets][0].organisation.rule_parameter_sets.size)
+ # assigns[:rule_parameter_sets].each do |rps|
+ # expect(rps.organisation.id).to eq(assigns[:rule_parameter_sets][0].organisation.id)
+ # end
+ # end
+ # end
# describe "GET /new" do
# before(:each) do
@@ -33,4 +33,4 @@ describe RuleParameterSetsController, :type => :controller do
# end
# end
# end
-end
+# end
diff --git a/spec/factories/compliance_check_messages.rb b/spec/factories/compliance_check_messages.rb
index a0d45eb50..e015fb121 100644
--- a/spec/factories/compliance_check_messages.rb
+++ b/spec/factories/compliance_check_messages.rb
@@ -2,6 +2,7 @@ FactoryGirl.define do
factory :compliance_check_message do
association :compliance_check
association :compliance_check_resource
+ association :compliance_check_set
status 'OK'
message_key "message_key"
end
diff --git a/spec/factories/compliance_control_blocks.rb b/spec/factories/compliance_control_blocks.rb
index 5bc45cc75..4785d8419 100644
--- a/spec/factories/compliance_control_blocks.rb
+++ b/spec/factories/compliance_control_blocks.rb
@@ -1,6 +1,7 @@
FactoryGirl.define do
factory :compliance_control_block do
sequence(:name) { |n| "Compliance control block #{n}" }
+ transport_mode "air"
association :compliance_control_set
end
end
diff --git a/spec/features/api_keys/delete_api_key_feature_spec.rb b/spec/features/api_keys/delete_api_key_feature_spec.rb
index b58e819a6..6bfc686af 100644
--- a/spec/features/api_keys/delete_api_key_feature_spec.rb
+++ b/spec/features/api_keys/delete_api_key_feature_spec.rb
@@ -10,7 +10,7 @@ RSpec.describe 'New API Key', type: :feature do
xit 'complete workflow' do
# /workbenches
- visit workbenches_path
+ visit dashboard_path
# the api_key is visible
click_link edit_label
@@ -23,7 +23,7 @@ RSpec.describe 'New API Key', type: :feature do
# expect(Api::V1::ApiKey.where(id: api_key.id)).to be_empty
# # check redirect and changed display
- # expect(page.current_path).to eq(workbenches_path)
+ # expect(page.current_path).to eq(dashboard_path)
# # deleted api_key's not shown anymore
# expect( page ).not_to have_content(edit_label)
end
@@ -31,4 +31,3 @@ RSpec.describe 'New API Key', type: :feature do
end
end
-
diff --git a/spec/features/api_keys/edit_api_key_feature_spec.rb b/spec/features/api_keys/edit_api_key_feature_spec.rb
index 411c11aaf..256c4218b 100644
--- a/spec/features/api_keys/edit_api_key_feature_spec.rb
+++ b/spec/features/api_keys/edit_api_key_feature_spec.rb
@@ -1,4 +1,4 @@
-RSpec.describe 'New API Key', type: :feature do
+RSpec.describe 'Edit API Key', type: :feature do
login_user
describe "api_keys#edit" do
@@ -12,8 +12,7 @@ RSpec.describe 'New API Key', type: :feature do
let( :unique_name ){ SecureRandom.uuid }
it 'complete workflow' do
- # /workbenches
- visit workbenches_path
+ visit dashboard_path
# api_key's new name does not exist yet
expect( page ).not_to have_content(unique_name)
# the api_key is visible
@@ -28,7 +27,7 @@ RSpec.describe 'New API Key', type: :feature do
expect(api_key.reload.name).to eq(unique_name)
# check redirect and changed display
- expect(page.current_path).to eq(workbenches_path)
+ expect(page.current_path).to eq(dashboard_path)
# changed api_key's name exists now
expect( page ).to have_content(unique_name)
end
@@ -36,4 +35,3 @@ RSpec.describe 'New API Key', type: :feature do
end
end
-
diff --git a/spec/features/api_keys/new_api_key_feature_spec.rb b/spec/features/api_keys/new_api_key_feature_spec.rb
index eba873691..988690f3c 100644
--- a/spec/features/api_keys/new_api_key_feature_spec.rb
+++ b/spec/features/api_keys/new_api_key_feature_spec.rb
@@ -1,3 +1,4 @@
+# coding: utf-8
RSpec.describe 'New API Key', type: :feature do
login_user
@@ -13,21 +14,21 @@ RSpec.describe 'New API Key', type: :feature do
it 'complete workflow' do
# /workbenches
- visit workbenches_path
+ visit dashboard_path
expect(page).to have_link(create_label, href: new_api_key_path)
# to be created api_key does not exist yet
expect( page ).not_to have_content(unique_name)
# /api_keys/new
- click_link create_label
- fill_in(name_label, with: unique_name)
+ click_link create_label
+ fill_in(name_label, with: unique_name)
click_button validate_label
# check impact on DB
expect(last_api_key.name).to eq(unique_name)
# check redirect and changed display
- expect(page.current_path).to eq(workbenches_path)
+ expect(page.current_path).to eq(dashboard_path)
# to be created api_key exists now
expect( page ).to have_content(unique_name)
end
@@ -35,4 +36,3 @@ RSpec.describe 'New API Key', type: :feature do
end
end
-
diff --git a/spec/models/chouette/transport_mode_spec.rb b/spec/models/chouette/transport_mode_spec.rb
deleted file mode 100644
index 8f2b2eddb..000000000
--- a/spec/models/chouette/transport_mode_spec.rb
+++ /dev/null
@@ -1,64 +0,0 @@
-require 'spec_helper'
-
-describe Chouette::TransportMode, :type => :model do
-
- def mode(text_code = "test", numerical_code = nil)
- numerical_code ||= 1 if text_code == "test"
- Chouette::TransportMode.new(text_code, numerical_code)
- end
-
- describe "#to_i" do
-
- it "should return numerical code" do
- expect(mode("test", 1).to_i).to eq(1)
- end
-
- end
-
- it "should return true to #test? when text code is 'test'" do
- expect(mode("test")).to be_test
- end
-
- it "should be equal when text codes are identical" do
- expect(mode("test",1)).to eq(mode("test", 2))
- end
-
- describe ".new" do
-
- it "should find numerical code from text code" do
- expect(mode("unknown").to_i).to eq(0)
- end
-
- it "should find text code from numerical code" do
- expect(mode(0)).to be_unknown
- end
-
- it "should accept another mode" do
- expect(Chouette::TransportMode.new(mode("test"))).to eq(mode("test"))
- end
-
- end
-
- describe "#public_transport?" do
-
- it "should return false for interchange" do
- expect(mode("interchange")).not_to be_public_transport
- end
-
- it "should return true for other modes" do
- expect(mode("unknown")).to be_public_transport
- end
-
- end
-
- describe ".all" do
-
- Chouette::TransportMode.definitions.each do |text_code, numerical_code|
- it "should include a TransportMode #{text_code}" do
- expect(Chouette::TransportMode.all).to include(Chouette::TransportMode.new(text_code))
- end
- end
-
- end
-
-end
diff --git a/spec/models/compliance_check_message_spec.rb b/spec/models/compliance_check_message_spec.rb
index 8b424595e..7c8f05953 100644
--- a/spec/models/compliance_check_message_spec.rb
+++ b/spec/models/compliance_check_message_spec.rb
@@ -7,4 +7,5 @@ RSpec.describe ComplianceCheckMessage, type: :model do
it { should belong_to :compliance_check }
it { should belong_to :compliance_check_resource }
+ it { should belong_to :compliance_check_set }
end
diff --git a/spec/models/compliance_control_block_spec.rb b/spec/models/compliance_control_block_spec.rb
index a50fe026b..c7440a5eb 100644
--- a/spec/models/compliance_control_block_spec.rb
+++ b/spec/models/compliance_control_block_spec.rb
@@ -9,4 +9,5 @@ RSpec.describe ComplianceControlBlock, type: :model do
it { should belong_to :compliance_control_set }
it { should have_many(:compliance_controls).dependent(:destroy) }
+ it { should validate_presence_of(:transport_mode) }
end
diff --git a/spec/models/line_referential_spec.rb b/spec/models/line_referential_spec.rb
index 8472faaa0..07725d9e6 100644
--- a/spec/models/line_referential_spec.rb
+++ b/spec/models/line_referential_spec.rb
@@ -12,7 +12,7 @@ RSpec.describe LineReferential, :type => :model do
describe "#transport_modes" do
it 'returns a list of all transport modes' do
- expect(FactoryGirl.create(:line_referential).transport_modes).to eq( Chouette::TransportMode.all.select { |tm| tm.to_i > 0 } )
+ expect(FactoryGirl.create(:line_referential).transport_modes).to match_array(StifTransportModeEnumerations.transport_mode.options.map(&:first) )
end
end
end
diff --git a/spec/models/organisation_spec.rb b/spec/models/organisation_spec.rb
index b16324a56..1217666f7 100644
--- a/spec/models/organisation_spec.rb
+++ b/spec/models/organisation_spec.rb
@@ -6,10 +6,10 @@ describe Organisation, :type => :model do
expect(FactoryGirl.build(:organisation)).to be_valid
end
- it "create a rule_parameter_set" do
- organisation = create(:organisation)
- expect(organisation.rule_parameter_sets.size).to eq(1)
- end
+ # it "create a rule_parameter_set" do
+ # organisation = create(:organisation)
+ # expect(organisation.rule_parameter_sets.size).to eq(1)
+ # end
describe "Portail sync" do
let(:conf) { Rails.application.config.stif_portail_api }
diff --git a/spec/models/vehicle_translation_spec.rb b/spec/models/vehicle_translation_spec.rb
index d30cfa03e..4bbff7f49 100644
--- a/spec/models/vehicle_translation_spec.rb
+++ b/spec/models/vehicle_translation_spec.rb
@@ -9,7 +9,7 @@ describe VehicleTranslation, :type => :model do
:journey_pattern => journey_pattern,
:route => journey_pattern.route,
# :company => company,
- :transport_mode => Chouette::TransportMode.new("metro"),
+ :transport_mode => "metro",
:published_journey_name => "dummy"
)}
subject {build(:vehicle_translation,