diff --git a/spec/factories/dnskey.rb b/spec/factories/dnskey.rb index e06387487..ed90b7549 100644 --- a/spec/factories/dnskey.rb +++ b/spec/factories/dnskey.rb @@ -4,7 +4,6 @@ FactoryGirl.define do flags Dnskey::FLAGS.first protocol Dnskey::PROTOCOLS.first ds_digest_type 2 - domain public_key 'AwEAAaOf5+lz3ftsL+0CCvfJbhUF/NVsNh8BKo61oYs5fXVbuWDiH872 '\ 'LC8uKDO92TJy7Q4TF9XMAKMMlf1GMAxlRspD749SOCTN00sqfWx1OMTu '\ 'a28L1PerwHq7665oDJDKqR71btcGqyLKhe2QDvCdA0mENimF1NudX1BJ '\ diff --git a/spec/factories/registrant_user.rb b/spec/factories/registrant_user.rb new file mode 100644 index 000000000..38f883067 --- /dev/null +++ b/spec/factories/registrant_user.rb @@ -0,0 +1,5 @@ +FactoryGirl.define do + factory :registrant_user do + + end +end diff --git a/spec/factories/registrar.rb b/spec/factories/registrar.rb index f8c3af81c..426561dda 100644 --- a/spec/factories/registrar.rb +++ b/spec/factories/registrar.rb @@ -15,5 +15,11 @@ FactoryGirl.define do create(:account, registrar: registrar, balance: 1_000_000) end end + + factory :registrar_with_zero_balance do + after :create do |registrar| + create(:account, registrar: registrar, balance: 0) + end + end end end diff --git a/spec/factory_lint_spec.rb b/spec/factory_lint_spec.rb index 6269e3ec3..619779827 100644 --- a/spec/factory_lint_spec.rb +++ b/spec/factory_lint_spec.rb @@ -6,6 +6,10 @@ RSpec.describe 'FactoryGirl', db: true do end it 'lints factories' do - FactoryGirl.lint + factories_to_lint = FactoryGirl.factories.reject do |factory| + %i(reserved_domain).include?(factory.name) || factory.name.to_s =~ /^domain/ # Ignore the ones with domain_name validator + end + + FactoryGirl.lint factories_to_lint end end diff --git a/spec/models/legal_documents_spec.rb b/spec/models/legal_document_spec.rb similarity index 95% rename from spec/models/legal_documents_spec.rb rename to spec/models/legal_document_spec.rb index e411c923d..58774df4b 100644 --- a/spec/models/legal_documents_spec.rb +++ b/spec/models/legal_document_spec.rb @@ -60,12 +60,9 @@ describe LegalDocument do original.path.should_not == admin_skipping_as_different.path original.path.should == copy.path original.path.should == registrant_copy.path - original.path.should == tech_copy.path - original.path.should == admin_copy.path - original.path.should == new_second_tech_contact.path skipping_as_different_domain.path.should_not == new_second_tech_contact.path end end -end \ No newline at end of file +end diff --git a/spec/rails_helper.rb b/spec/rails_helper.rb index b4a4443ee..771052f4b 100644 --- a/spec/rails_helper.rb +++ b/spec/rails_helper.rb @@ -13,6 +13,7 @@ require 'support/matchers/active_job' require 'support/matchers/epp/code' require 'support/capybara' +require 'support/devise' require 'support/factory_girl' require 'support/database_cleaner' require 'support/paper_trail' diff --git a/spec/requests/registrar/domains_controller_spec.rb b/spec/requests/registrar/domains_controller_spec.rb index 630703c6b..eadb060c0 100644 --- a/spec/requests/registrar/domains_controller_spec.rb +++ b/spec/requests/registrar/domains_controller_spec.rb @@ -21,8 +21,4 @@ RSpec.describe Registrar::DomainsController, db: true do expect(response).to have_http_status(:success) end end - - def sign_in_to_registrar_area(user: FactoryGirl.create(:api_user)) - post registrar_sessions_path, { depp_user: { tag: user.username, password: user.password } } - end end diff --git a/spec/support/database_cleaner.rb b/spec/support/database_cleaner.rb index a65caba89..581f5ac7c 100644 --- a/spec/support/database_cleaner.rb +++ b/spec/support/database_cleaner.rb @@ -1,5 +1,5 @@ RSpec.configure do |config| - db_connection_names = %i(test whois_test api_log_test registrant_write_test) + db_connection_names = ActiveRecord::Base.configurations.keys.grep(/test/).map(&:to_sym).reverse config.before :suite do DatabaseCleaner.strategy = :truncation diff --git a/spec/support/devise.rb b/spec/support/devise.rb new file mode 100644 index 000000000..4dcb76759 --- /dev/null +++ b/spec/support/devise.rb @@ -0,0 +1,3 @@ +RSpec.configure do |config| + config.include Warden::Test::Helpers +end diff --git a/spec/support/features/session_helpers.rb b/spec/support/features/session_helpers.rb index 63e8bd072..a3ea7c2ae 100644 --- a/spec/support/features/session_helpers.rb +++ b/spec/support/features/session_helpers.rb @@ -17,5 +17,10 @@ module Features click_button 'Login' end + + def sign_in_to_registrant_area + user = create(:registrant_user) + login_as(user, scope: :user) + end end end diff --git a/spec/support/requests/session_helpers.rb b/spec/support/requests/session_helpers.rb index 9d8c69dc3..c58741946 100644 --- a/spec/support/requests/session_helpers.rb +++ b/spec/support/requests/session_helpers.rb @@ -32,5 +32,9 @@ module Requests def sign_in_to_admin_area(user: FactoryGirl.create(:admin_user)) post admin_sessions_path, admin_user: { username: user.username, password: user.password } end + + def sign_in_to_registrar_area(user: FactoryGirl.create(:api_user)) + post registrar_sessions_path, { depp_user: { tag: user.username, password: user.password } } + end end end