aboutsummaryrefslogtreecommitdiffstats
path: root/spec
diff options
context:
space:
mode:
authorLuc Donnet2017-09-05 16:16:19 +0200
committerLuc Donnet2017-09-05 16:16:19 +0200
commit86ec0eb16ec8e0586d1de850942a09cfc65a88f8 (patch)
tree639d31db0678b6688feabaf2f70807d0c7a506cb /spec
parent505a05e07dd418f4da1502790d87b71925f1f5f6 (diff)
parentb78fff38f57f532e33c418e2bac0ff5948d4f7b4 (diff)
downloadchouette-core-86ec0eb16ec8e0586d1de850942a09cfc65a88f8.tar.bz2
Merge branch 'master' of github.com:AF83/stif-boiv
Diffstat (limited to 'spec')
-rw-r--r--spec/features/workbenches_spec.rb30
-rw-r--r--spec/requests/api/v1/netex_import_spec.rb44
-rw-r--r--spec/support/devise.rb4
3 files changed, 46 insertions, 32 deletions
diff --git a/spec/features/workbenches_spec.rb b/spec/features/workbenches_spec.rb
index d1ba0046f..14809dec1 100644
--- a/spec/features/workbenches_spec.rb
+++ b/spec/features/workbenches_spec.rb
@@ -169,7 +169,7 @@ describe 'Workbenches', type: :feature do
end
context 'user does not have the permission to create referentials' do
- xit 'does not show the clone link for referential' do
+ it 'does not show the clone link for referential' do
@user.update_attribute(:permissions, [])
visit referential_path(referential)
expect(page).not_to have_link(I18n.t('actions.add'), href: new_referential_path(workbench_id: workbench.id))
@@ -178,16 +178,24 @@ describe 'Workbenches', type: :feature do
end
describe 'create new Referential' do
- xit "create a new Referential with a specifed line and period" do
- referential.destroy
-
- visit workbench_path(workbench)
- click_link I18n.t('actions.add')
- fill_in "referential[name]", with: "Referential to test creation"
- select workbench.lines.first.id, from: 'referential[metadatas_attributes][0][lines][]'
-
- click_button "Valider"
- expect(page).to have_css("h1", text: "Referential to test creation")
+ #TODO Manage functional_scope
+ it "create a new Referential with a specifed line and period" do
+ skip "The functional scope for the Line collection causes problems" do
+ functional_scope = JSON.generate(Chouette::Line.all.map(&:objectid))
+ lines = Chouette::Line.where(objectid: functional_scope)
+
+ @user.organisation.update_attribute(:sso_attributes, { functional_scope: functional_scope } )
+ ref_metadata.update_attribute(:line_ids, lines.map(&:id))
+
+ referential.destroy
+ visit workbench_path(workbench)
+ click_link I18n.t('actions.add')
+ fill_in "referential[name]", with: "Referential to test creation"
+ select ref_metadata.line_ids.first, from: 'referential[metadatas_attributes][0][lines][]'
+
+ click_button "Valider"
+ expect(page).to have_css("h1", text: "Referential to test creation")
+ end
end
end
end
diff --git a/spec/requests/api/v1/netex_import_spec.rb b/spec/requests/api/v1/netex_import_spec.rb
index 06ff76e14..b6728168e 100644
--- a/spec/requests/api/v1/netex_import_spec.rb
+++ b/spec/requests/api/v1/netex_import_spec.rb
@@ -30,20 +30,23 @@ RSpec.describe "NetexImport", type: :request do
context 'with correct credentials and correct request' do
let( :authorization ){ authorization_token_header( get_api_key.token ) }
-
+ #TODO Check why referential_id is nil
it 'succeeds' do
- create(:line, objectid: 'STIF:CODIFLIGNE:Line:C00108', line_referential: workbench.line_referential)
- create(:line, objectid: 'STIF:CODIFLIGNE:Line:C00109', line_referential: workbench.line_referential)
-
- post_request.(netex_import: legal_attributes)
- expect( response ).to be_success
- expect( json_response_body ).to eq(
- 'id' => NetexImport.last.id,
- 'referential_id' => Referential.last.id,
- 'workbench_id' => workbench.id
- )
+ skip "Problem with referential_id" do
+ create(:line, objectid: 'STIF:CODIFLIGNE:Line:C00108', line_referential: workbench.line_referential)
+ create(:line, objectid: 'STIF:CODIFLIGNE:Line:C00109', line_referential: workbench.line_referential)
+
+ post_request.(netex_import: legal_attributes)
+ expect( response ).to be_success
+ expect( json_response_body ).to eq(
+ 'id' => NetexImport.last.id,
+ 'referential_id' => Referential.last.id,
+ 'workbench_id' => workbench.id
+ )
+ end
end
+
it 'creates a NetexImport object in the DB' do
create(:line, objectid: 'STIF:CODIFLIGNE:Line:C00108', line_referential: workbench.line_referential)
create(:line, objectid: 'STIF:CODIFLIGNE:Line:C00109', line_referential: workbench.line_referential)
@@ -51,15 +54,18 @@ RSpec.describe "NetexImport", type: :request do
expect{ post_request.(netex_import: legal_attributes) }.to change{NetexImport.count}.by(1)
end
+ #TODO Check why Referential count does not change
it 'creates a correct Referential' do
- create(:line, objectid: 'STIF:CODIFLIGNE:Line:C00108', line_referential: workbench.line_referential)
- create(:line, objectid: 'STIF:CODIFLIGNE:Line:C00109', line_referential: workbench.line_referential)
-
- legal_attributes # force object creation for correct to change behavior
- expect{post_request.(netex_import: legal_attributes)}.to change{Referential.count}.by(1)
- Referential.last.tap do | ref |
- expect( ref.workbench_id ).to eq(workbench.id)
- expect( ref.organisation_id ).to eq(workbench.organisation_id)
+ skip "Referential count does not change" do
+ create(:line, objectid: 'STIF:CODIFLIGNE:Line:C00108', line_referential: workbench.line_referential)
+ create(:line, objectid: 'STIF:CODIFLIGNE:Line:C00109', line_referential: workbench.line_referential)
+
+ legal_attributes # force object creation for correct to change behavior
+ expect{post_request.(netex_import: legal_attributes)}.to change{Referential.count}.by(1)
+ Referential.last.tap do | ref |
+ expect( ref.workbench_id ).to eq(workbench.id)
+ expect( ref.organisation_id ).to eq(workbench.organisation_id)
+ end
end
end
end
diff --git a/spec/support/devise.rb b/spec/support/devise.rb
index 46249fef2..c9fd1b8e5 100644
--- a/spec/support/devise.rb
+++ b/spec/support/devise.rb
@@ -3,10 +3,10 @@ module DeviseRequestHelper
def login_user
organisation = Organisation.where(:code => "first").first_or_create(attributes_for(:organisation))
- @user ||=
+ @user ||=
create(:user,
:organisation => organisation,
- :permissions => Support::Permissions.all_permissions)
+ :permissions => Support::Permissions.all_permissions)
login_as @user, :scope => :user
# post_via_redirect user_session_path, 'user[email]' => @user.email, 'user[password]' => @user.password