style check
This commit is contained in:
parent
a7e6931303
commit
d557cee249
24 changed files with 67 additions and 78 deletions
|
@ -5,7 +5,7 @@ describe EntrepriseDecorator do
|
|||
let(:raison_sociale) { 'GRTGaz' }
|
||||
let(:nom) { 'mon nom' }
|
||||
let(:prenom) { 'mon prenom' }
|
||||
let(:entreprise_params) {
|
||||
let(:entreprise_params) do
|
||||
{
|
||||
capital_social: 123_000,
|
||||
code_effectif_entreprise: code_effectif,
|
||||
|
@ -14,7 +14,7 @@ describe EntrepriseDecorator do
|
|||
prenom: prenom
|
||||
|
||||
}
|
||||
}
|
||||
end
|
||||
let(:entreprise) { create(:entreprise, entreprise_params) }
|
||||
subject { entreprise.decorate }
|
||||
describe '#raison_sociale_or_name' do
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
FactoryGirl.define do
|
||||
factory :cerfa do
|
||||
|
||||
end
|
||||
end
|
|
@ -1,5 +1,4 @@
|
|||
FactoryGirl.define do
|
||||
factory :commentaire do
|
||||
|
||||
end
|
||||
end
|
|
@ -1,5 +1,4 @@
|
|||
FactoryGirl.define do
|
||||
factory :piece_jointe do
|
||||
|
||||
end
|
||||
end
|
|
@ -1,5 +1,4 @@
|
|||
FactoryGirl.define do
|
||||
factory :type_piece_jointe do
|
||||
|
||||
end
|
||||
end
|
|
@ -1,12 +1,11 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe SIADE::API do
|
||||
|
||||
describe '.entreprise' do
|
||||
subject { SIADE::API.entreprise(siren) }
|
||||
subject { described_class.entreprise(siren) }
|
||||
before do
|
||||
stub_request(:get, "https://api-dev.apientreprise.fr/api/v1/entreprises/#{siren}?token=#{SIADETOKEN}").
|
||||
to_return(:status => status, :body => body)
|
||||
stub_request(:get, "https://api-dev.apientreprise.fr/api/v1/entreprises/#{siren}?token=#{SIADETOKEN}")
|
||||
.to_return(status: status, body: body)
|
||||
end
|
||||
context 'when siren does not exist' do
|
||||
let(:siren) { '111111111' }
|
||||
|
@ -29,10 +28,10 @@ describe SIADE::API do
|
|||
end
|
||||
|
||||
describe '.etablissement' do
|
||||
subject { SIADE::API.etablissement(siret) }
|
||||
subject { described_class.etablissement(siret) }
|
||||
before do
|
||||
stub_request(:get, "https://api-dev.apientreprise.fr/api/v1/etablissements/#{siret}?token=#{SIADETOKEN}").
|
||||
to_return(:status => status, :body => body)
|
||||
stub_request(:get, "https://api-dev.apientreprise.fr/api/v1/etablissements/#{siret}?token=#{SIADETOKEN}")
|
||||
.to_return(status: status, body: body)
|
||||
end
|
||||
|
||||
context 'when siret does not exist' do
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe SIADE::EntrepriseAdapter do
|
||||
subject { SIADE::EntrepriseAdapter.new('418166096').to_params }
|
||||
subject { described_class.new('418166096').to_params }
|
||||
|
||||
before do
|
||||
stub_request(:get, "https://api-dev.apientreprise.fr/api/v1/entreprises/418166096?token=#{SIADETOKEN}")
|
||||
|
@ -18,7 +18,7 @@ describe SIADE::EntrepriseAdapter do
|
|||
end
|
||||
|
||||
it 'L\'entreprise contient bien un capital_social' do
|
||||
expect(subject[:capital_social]).to eq(372795)
|
||||
expect(subject[:capital_social]).to eq(372_795)
|
||||
end
|
||||
|
||||
it 'L\'entreprise contient bien un numero_tva_intracommunautaire' do
|
||||
|
@ -50,7 +50,7 @@ describe SIADE::EntrepriseAdapter do
|
|||
end
|
||||
|
||||
it 'L\'entreprise contient bien une date_creation' do
|
||||
expect(subject[:date_creation]).to eq(891381600)
|
||||
expect(subject[:date_creation]).to eq(891_381_600)
|
||||
end
|
||||
|
||||
it 'L\'entreprise contient bien un nom' do
|
||||
|
|
|
@ -1,10 +1,9 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe SIADE::EtablissementAdapter do
|
||||
|
||||
context 'SIRET valide' do
|
||||
let(:siret){41816609600051}
|
||||
subject { SIADE::EtablissementAdapter.new(siret).to_params }
|
||||
let(:siret) { 41_816_609_600_051 }
|
||||
subject { described_class.new(siret).to_params }
|
||||
|
||||
before do
|
||||
stub_request(:get, "https://api-dev.apientreprise.fr/api/v1/etablissements/#{siret}?token=#{SIADETOKEN}")
|
||||
|
@ -16,7 +15,6 @@ describe SIADE::EtablissementAdapter do
|
|||
end
|
||||
|
||||
context 'Attributs Etablissements' do
|
||||
|
||||
it 'L\'entreprise contient bien un siret' do
|
||||
expect(subject[:siret]).to eq('41816609600051')
|
||||
end
|
||||
|
@ -71,8 +69,8 @@ describe SIADE::EtablissementAdapter do
|
|||
end
|
||||
|
||||
context 'when siret is not found' do
|
||||
let(:bad_siret){ 11111111111111 }
|
||||
subject { SIADE::EtablissementAdapter.new(bad_siret).to_params }
|
||||
let(:bad_siret) { 11_111_111_111_111 }
|
||||
subject { described_class.new(bad_siret).to_params }
|
||||
|
||||
before do
|
||||
stub_request(:get, "https://api-dev.apientreprise.fr/api/v1/etablissements/#{bad_siret}?token=#{SIADETOKEN}")
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe Dossier do
|
||||
|
||||
describe 'database columns' do
|
||||
it { is_expected.to have_db_column(:description) }
|
||||
it { is_expected.to have_db_column(:autorisation_donnees) }
|
||||
|
@ -26,7 +25,7 @@ describe Dossier do
|
|||
it { is_expected.to have_one(:entreprise) }
|
||||
end
|
||||
|
||||
describe "delegation" do
|
||||
describe 'delegation' do
|
||||
it { is_expected.to delegate_method(:siren).to(:entreprise) }
|
||||
it { is_expected.to delegate_method(:siret).to(:etablissement) }
|
||||
it { is_expected.to delegate_method(:types_piece_jointe).to(:formulaire) }
|
||||
|
@ -49,11 +48,11 @@ describe Dossier do
|
|||
|
||||
describe 'creation' do
|
||||
it 'create default cerfa' do
|
||||
expect{Dossier.create}.to change{ Cerfa.count }.by(1)
|
||||
expect { described_class.create }.to change { Cerfa.count }.by(1)
|
||||
end
|
||||
|
||||
it 'link cerfa to dossier' do
|
||||
dossier = Dossier.create
|
||||
dossier = described_class.create
|
||||
expect(dossier.cerfa).to eq(Cerfa.last)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -13,9 +13,9 @@ describe EvenementVie do
|
|||
end
|
||||
|
||||
describe '.for_admi_facile' do
|
||||
let(:evenement_for_admi_facile) { EvenementVie.where(use_admi_facile: true).first }
|
||||
let(:evenement_not_for_admi_facile) { EvenementVie.where(use_admi_facile: false).first }
|
||||
subject { EvenementVie.for_admi_facile }
|
||||
let(:evenement_for_admi_facile) { described_class.where(use_admi_facile: true).first }
|
||||
let(:evenement_not_for_admi_facile) { described_class.where(use_admi_facile: false).first }
|
||||
subject { described_class.for_admi_facile }
|
||||
it 'returns elements where use_admi_facile is true' do
|
||||
expect(subject).to include(evenement_for_admi_facile)
|
||||
end
|
||||
|
|
|
@ -26,8 +26,8 @@ describe Formulaire do
|
|||
|
||||
describe '.for_admi_facile' do
|
||||
it 'retruns Formulaire where use_admi_facile is true' do
|
||||
expect(Formulaire.for_admi_facile.size).to eq(Formulaire.where(use_admi_facile: true).count)
|
||||
expect(Formulaire.for_admi_facile).to include(Formulaire.where(use_admi_facile: true).first)
|
||||
expect(described_class.for_admi_facile.size).to eq(described_class.where(use_admi_facile: true).count)
|
||||
expect(described_class.for_admi_facile).to include(described_class.where(use_admi_facile: true).first)
|
||||
end
|
||||
end
|
||||
end
|
|
@ -17,9 +17,9 @@
|
|||
#
|
||||
# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
|
||||
|
||||
ENV["RAILS_ENV"] ||= 'test'
|
||||
ENV['RAILS_ENV'] ||= 'test'
|
||||
|
||||
require File.expand_path("../../config/environment", __FILE__)
|
||||
require File.expand_path('../../config/environment', __FILE__)
|
||||
require 'rspec/rails'
|
||||
require 'capybara/rspec'
|
||||
require 'database_cleaner'
|
||||
|
@ -31,26 +31,23 @@ require 'factory_girl'
|
|||
require 'capybara/poltergeist'
|
||||
Capybara.javascript_driver = :poltergeist
|
||||
Capybara.register_driver :poltergeist do |app|
|
||||
Capybara::Poltergeist::Driver.new(app, {js_errors:true, port:44678+ENV['TEST_ENV_NUMBER'].to_i, phantomjs_options:['--proxy-type=none'], timeout:180})
|
||||
Capybara::Poltergeist::Driver.new(app, js_errors: true, port: 44_678 + ENV['TEST_ENV_NUMBER'].to_i, phantomjs_options: ['--proxy-type=none'], timeout: 180)
|
||||
end
|
||||
|
||||
Capybara.default_wait_time = 1
|
||||
|
||||
# Requires supporting ruby files with custom matchers and macros, etc,
|
||||
# in spec/support/ and its subdirectories.
|
||||
Dir[Rails.root.join("spec/support/**/*.rb")].each { |f| require f }
|
||||
Dir[Rails.root.join("spec/factories/**/*.rb")].each { |f| require f }
|
||||
Dir[Rails.root.join('spec/support/**/*.rb')].each { |f| require f }
|
||||
Dir[Rails.root.join('spec/factories/**/*.rb')].each { |f| require f }
|
||||
|
||||
# Checks for pending migrations before tests are run.
|
||||
# If you are not using ActiveRecord, you can remove this line.
|
||||
ActiveRecord::Migration.check_pending! if defined?(ActiveRecord::Migration)
|
||||
|
||||
DatabaseCleaner.strategy = :truncation, {:except => %w[evenement_vies formulaires types_piece_jointe]}
|
||||
DatabaseCleaner.strategy = :truncation, { except: %w(evenement_vies formulaires types_piece_jointe) }
|
||||
|
||||
|
||||
if !(defined? SIADETOKEN)
|
||||
SIADETOKEN = :valid_token
|
||||
end
|
||||
SIADETOKEN = :valid_token unless defined? SIADETOKEN
|
||||
|
||||
include Warden::Test::Helpers
|
||||
|
||||
|
@ -64,9 +61,9 @@ RSpec.configure do |config|
|
|||
|
||||
config.infer_base_class_for_anonymous_controllers = false
|
||||
|
||||
config.order = "random"
|
||||
config.order = 'random'
|
||||
|
||||
config.include Devise::TestHelpers, :type => :controller
|
||||
config.include Devise::TestHelpers, type: :controller
|
||||
|
||||
config.include FactoryGirl::Syntax::Methods
|
||||
end
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
module ControllerHelpers
|
||||
def sign_in(user = double('test@localhost.com'))
|
||||
if user.nil?
|
||||
allow(request.env['warden']).to receive(:authenticate!).and_throw(:warden, {:scope => :user})
|
||||
allow(request.env['warden']).to receive(:authenticate!).and_throw(:warden, scope: :user)
|
||||
allow(controller).to receive(:current_user).and_return(nil)
|
||||
else
|
||||
allow(request.env['warden']).to receive(:authenticate!).and_return(user)
|
||||
|
@ -11,6 +11,6 @@ module ControllerHelpers
|
|||
end
|
||||
|
||||
RSpec.configure do |config|
|
||||
config.include Devise::TestHelpers, :type => :controller
|
||||
config.include ControllerHelpers, :type => :controller
|
||||
config.include Devise::TestHelpers, type: :controller
|
||||
config.include ControllerHelpers, type: :controller
|
||||
end
|
|
@ -1,6 +1,6 @@
|
|||
RSpec.configure do |config|
|
||||
config.before(:suite) do
|
||||
DatabaseCleaner.clean_with(:truncation, {:except => %w[evenement_vies formulaires types_piece_jointe]})
|
||||
DatabaseCleaner.clean_with(:truncation, except: %w(evenement_vies formulaires types_piece_jointe))
|
||||
end
|
||||
|
||||
config.before(:each) do
|
||||
|
|
Loading…
Reference in a new issue