From ff8b2635c308d45ec38fd4eed257db7da9b3c4b0 Mon Sep 17 00:00:00 2001 From: Azul Date: Fri, 8 Dec 2017 16:33:15 +0100 Subject: upgrade: bundle to latest that still supports ruby 2.1.5 --- Gemfile | 3 +- Gemfile.lock | 195 ++++++++++++++++++++++++++++++----------------------------- 2 files changed, 100 insertions(+), 98 deletions(-) diff --git a/Gemfile b/Gemfile index 596f280..3199e0a 100644 --- a/Gemfile +++ b/Gemfile @@ -75,6 +75,7 @@ group :test do # we use cucumber to document and test the api gem 'cucumber-rails', require: false + gem 'cucumber', '~> 2.4.0' # version that still supports ruby 2.1 end group :test, :development do @@ -93,7 +94,7 @@ end group :test, :debug do # bundler on jessie doesn't support `:platforms => :ruby_21` - gem 'byebug' + gem 'byebug', '~> 9.0.6' end ## diff --git a/Gemfile.lock b/Gemfile.lock index 2ee1037..430155b 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,13 +1,13 @@ PATH remote: engines/billing specs: - leap_web_billing (0.9.2) + leap_web_billing (0.9.3) braintree PATH remote: engines/support specs: - leap_web_help (0.9.2) + leap_web_help (0.9.3) PATH remote: vendor/gems/certificate_authority @@ -26,56 +26,56 @@ GEM remote: https://rubygems.org/ specs: SyslogLogger (2.0) - actionmailer (4.2.9) - actionpack (= 4.2.9) - actionview (= 4.2.9) - activejob (= 4.2.9) + actionmailer (4.2.10) + actionpack (= 4.2.10) + actionview (= 4.2.10) + activejob (= 4.2.10) mail (~> 2.5, >= 2.5.4) rails-dom-testing (~> 1.0, >= 1.0.5) - actionpack (4.2.9) - actionview (= 4.2.9) - activesupport (= 4.2.9) + actionpack (4.2.10) + actionview (= 4.2.10) + activesupport (= 4.2.10) rack (~> 1.6) rack-test (~> 0.6.2) rails-dom-testing (~> 1.0, >= 1.0.5) rails-html-sanitizer (~> 1.0, >= 1.0.2) - actionview (4.2.9) - activesupport (= 4.2.9) + actionview (4.2.10) + activesupport (= 4.2.10) builder (~> 3.1) erubis (~> 2.7.0) rails-dom-testing (~> 1.0, >= 1.0.5) rails-html-sanitizer (~> 1.0, >= 1.0.3) - activejob (4.2.9) - activesupport (= 4.2.9) + activejob (4.2.10) + activesupport (= 4.2.10) globalid (>= 0.3.0) - activemodel (4.2.9) - activesupport (= 4.2.9) + activemodel (4.2.10) + activesupport (= 4.2.10) builder (~> 3.1) - activerecord (4.2.9) - activemodel (= 4.2.9) - activesupport (= 4.2.9) + activerecord (4.2.10) + activemodel (= 4.2.10) + activesupport (= 4.2.10) arel (~> 6.0) - activesupport (4.2.9) + activesupport (4.2.10) i18n (~> 0.7) minitest (~> 5.1) thread_safe (~> 0.3, >= 0.3.4) tzinfo (~> 1.1) - addressable (2.5.1) - public_suffix (~> 2.0, >= 2.0.2) + addressable (2.5.2) + public_suffix (>= 2.0.2, < 4.0) arel (6.0.4) - autoprefixer-rails (7.1.2.4) + autoprefixer-rails (7.2.2) execjs - binding_of_caller (0.7.2) + binding_of_caller (0.7.3) debug_inspector (>= 0.0.1) bootstrap-sass (3.3.7) autoprefixer-rails (>= 5.2.1) sass (>= 3.3.4) - braintree (2.76.0) + braintree (2.80.1) builder (>= 2.0.0) buftok (0.2.0) builder (3.2.3) byebug (9.0.6) - capybara (2.15.1) + capybara (2.16.1) addressable mini_mime (>= 0.1.3) nokogiri (>= 1.3.3) @@ -90,7 +90,7 @@ GEM client_side_validations (~> 4.2.12) simple_form (~> 3.4) cliver (0.3.2) - coderay (1.1.1) + coderay (1.1.2) concurrent-ruby (1.0.5) couchrest (2.0.0) httpclient (~> 2.8) @@ -104,6 +104,7 @@ GEM actionpack (~> 4.0) couchrest (~> 2.0.0.rc3) couchrest_model (~> 2.1.0.beta2) + crass (1.0.3) cucumber (2.4.0) builder (>= 2.1.2) cucumber-core (~> 1.5.0) @@ -128,25 +129,23 @@ GEM equalizer (0.0.11) erubis (2.7.0) execjs (2.7.0) - factory_girl (4.8.0) + factory_girl (4.9.0) activesupport (>= 3.0.0) - factory_girl_rails (4.8.0) - factory_girl (~> 4.8.0) + factory_girl_rails (4.9.0) + factory_girl (~> 4.9.0) railties (>= 3.0.0) fake_braintree (0.8.0) activesupport braintree (~> 2.32) capybara (>= 2.2.0) sinatra - faker (1.8.4) - i18n (~> 0.5) - faraday (0.11.0) - multipart-post (>= 1.2, < 3) + faker (1.8.5) + i18n (~> 0.9.1) ffi (1.9.18) gherkin (4.1.3) - globalid (0.4.0) + globalid (0.4.1) activesupport (>= 4.2.0) - haml (5.0.2) + haml (5.0.4) temple (>= 0.8.0) tilt haml-rails (1.0.0) @@ -160,18 +159,19 @@ GEM haml (>= 4.0, < 6) nokogiri (>= 1.6.0) ruby_parser (~> 3.5) - http (2.2.2) + http (3.0.0) addressable (~> 2.3) http-cookie (~> 1.0) - http-form_data (~> 1.0.1) + http-form_data (>= 2.0.0.pre.pre2, < 3) http_parser.rb (~> 0.6.0) http-cookie (1.0.3) domain_name (~> 0.5) - http-form_data (1.0.3) + http-form_data (2.0.0) http_accept_language (2.1.1) http_parser.rb (0.6.0) httpclient (2.8.3) - i18n (0.8.6) + i18n (0.9.1) + concurrent-ruby (~> 1.0) i18n-missing_translations (0.0.1) jquery-rails (4.3.1) rails-dom-testing (>= 1, < 3) @@ -179,71 +179,71 @@ GEM thor (>= 0.14, < 2.0) js_regex (1.2.3) regexp_parser (>= 0.3.6, <= 0.5.0) - kaminari (1.0.1) + kaminari (1.1.1) activesupport (>= 4.1.0) - kaminari-actionview (= 1.0.1) - kaminari-activerecord (= 1.0.1) - kaminari-core (= 1.0.1) - kaminari-actionview (1.0.1) + kaminari-actionview (= 1.1.1) + kaminari-activerecord (= 1.1.1) + kaminari-core (= 1.1.1) + kaminari-actionview (1.1.1) actionview - kaminari-core (= 1.0.1) - kaminari-activerecord (1.0.1) + kaminari-core (= 1.1.1) + kaminari-activerecord (1.1.1) activerecord - kaminari-core (= 1.0.1) - kaminari-core (1.0.1) + kaminari-core (= 1.1.1) + kaminari-core (1.1.1) launchy (2.4.3) addressable (~> 2.3) libv8 (3.16.14.19) - loofah (2.0.3) + loofah (2.1.1) + crass (~> 1.0.2) nokogiri (>= 1.5.9) - mail (2.6.6) - mime-types (>= 1.16, < 4) + mail (2.7.0) + mini_mime (>= 0.1.1) memoizable (0.4.2) thread_safe (~> 0.3, >= 0.3.1) metaclass (0.0.4) - method_source (0.8.2) + method_source (0.9.0) mime-types (3.1) mime-types-data (~> 3.2015) mime-types-data (3.2016.0521) - mini_mime (0.1.4) - mini_portile2 (2.2.0) + mini_mime (1.0.0) + mini_portile2 (2.3.0) minitest (5.10.3) minitest-stub-const (0.6) - mocha (1.2.1) + mocha (1.3.0) metaclass (~> 0.0.1) - multi_json (1.12.1) + multi_json (1.12.2) multi_test (0.1.2) multipart-post (2.0.0) naught (1.1.0) - nokogiri (1.8.0) - mini_portile2 (~> 2.2.0) + nokogiri (1.8.1) + mini_portile2 (~> 2.3.0) phantomjs-binaries (2.1.1.1) sys-uname (= 0.9.0) poltergeist (1.16.0) capybara (~> 2.1) cliver (~> 0.3.1) websocket-driver (>= 0.2.0) - pry (0.10.4) + pry (0.11.3) coderay (~> 1.1.0) - method_source (~> 0.8.1) - slop (~> 3.4) + method_source (~> 0.9.0) psych (2.2.4) - public_suffix (2.0.5) + public_suffix (3.0.1) rack (1.6.8) rack-protection (1.5.3) rack rack-test (0.6.3) rack (>= 1.0) - rails (4.2.9) - actionmailer (= 4.2.9) - actionpack (= 4.2.9) - actionview (= 4.2.9) - activejob (= 4.2.9) - activemodel (= 4.2.9) - activerecord (= 4.2.9) - activesupport (= 4.2.9) + rails (4.2.10) + actionmailer (= 4.2.10) + actionpack (= 4.2.10) + actionview (= 4.2.10) + activejob (= 4.2.10) + activemodel (= 4.2.10) + activerecord (= 4.2.10) + activesupport (= 4.2.10) bundler (>= 1.3.0, < 2.0) - railties (= 4.2.9) + railties (= 4.2.10) sprockets-rails rails-deprecated_sanitizer (1.0.3) activesupport (>= 4.2.0.alpha) @@ -258,30 +258,30 @@ GEM railties (~> 4.0) rails_warden (0.5.8) warden (>= 1.0.0) - railties (4.2.9) - actionpack (= 4.2.9) - activesupport (= 4.2.9) + railties (4.2.10) + actionpack (= 4.2.10) + activesupport (= 4.2.10) rake (>= 0.8.7) thor (>= 0.18.1, < 2.0) - rake (12.0.0) + rake (12.3.0) rb-fsevent (0.10.2) rb-inotify (0.9.10) ffi (>= 0.5.0, < 2) rdiscount (2.2.0.1) ref (2.0.0) - regexp_parser (0.4.4) + regexp_parser (0.4.7) responders (2.4.0) actionpack (>= 4.2.0, < 5.3) railties (>= 4.2.0, < 5.3) ruby-srp (0.2.1) ruby_parser (3.10.1) sexp_processor (~> 4.9) - sass (3.5.1) + sass (3.5.3) sass-listen (~> 4.0.0) sass-listen (4.0.0) rb-fsevent (~> 0.9, >= 0.9.4) rb-inotify (~> 0.9, >= 0.9.7) - sass-rails (5.0.6) + sass-rails (5.0.7) railties (>= 4.0.0, < 6) sass (~> 3.1) sprockets (>= 2.8, < 4.0) @@ -296,11 +296,10 @@ GEM rack (~> 1.5) rack-protection (~> 1.4) tilt (>= 1.3, < 3) - slop (3.6.0) sprockets (3.7.1) concurrent-ruby (~> 1.0) rack (> 1, < 3) - sprockets-rails (3.2.0) + sprockets-rails (3.2.1) actionpack (>= 4.0) activesupport (>= 4.0) sprockets (>= 3.0.0) @@ -310,34 +309,35 @@ GEM therubyracer (0.12.3) libv8 (~> 3.16.14.15) ref - thor (0.19.4) + thor (0.20.0) thread_safe (0.3.6) tilt (2.0.8) - twitter (6.1.0) - addressable (~> 2.5) + twitter (6.2.0) + addressable (~> 2.3) buftok (~> 0.2.0) - equalizer (= 0.0.11) - faraday (~> 0.11.0) - http (~> 2.1) + equalizer (~> 0.0.11) + http (~> 3.0) + http-form_data (~> 2.0) http_parser.rb (~> 0.6.0) - memoizable (~> 0.4.2) - naught (~> 1.1) - simple_oauth (~> 0.3.1) - tzinfo (1.2.3) + memoizable (~> 0.4.0) + multipart-post (~> 2.0) + naught (~> 1.0) + simple_oauth (~> 0.3.0) + tzinfo (1.2.4) thread_safe (~> 0.1) - uglifier (3.2.0) + uglifier (4.0.1) execjs (>= 0.3.0, < 3) unf (0.1.4) unf_ext unf_ext (0.0.7.4) - valid_email (0.0.13) + valid_email (0.1.0) activemodel - mail (~> 2.6.1) + mail (>= 2.6.1) warden (1.2.7) rack (>= 1.0) - websocket-driver (0.6.5) + websocket-driver (0.7.0) websocket-extensions (>= 0.1.0) - websocket-extensions (0.1.2) + websocket-extensions (0.1.3) xpath (2.1.0) nokogiri (~> 1.3) @@ -348,7 +348,7 @@ DEPENDENCIES SyslogLogger (~> 2.0) binding_of_caller bootstrap-sass - byebug + byebug (~> 9.0.6) capybara certificate_authority! client_side_validations @@ -357,6 +357,7 @@ DEPENDENCIES couchrest (~> 2.0.0.rc3) couchrest_model (~> 2.1.0.beta2) couchrest_session_store (~> 0.4.2) + cucumber (~> 2.4.0) cucumber-rails factory_girl_rails fake_braintree @@ -390,4 +391,4 @@ DEPENDENCIES valid_email BUNDLED WITH - 1.15.3 + 1.16.0 -- cgit v1.2.3 From d839bed40fb7901ea88395d4ba06e58f4b3cc88a Mon Sep 17 00:00:00 2001 From: Azul Date: Fri, 8 Dec 2017 18:27:24 +0100 Subject: upgrade: factory_girl -> factory_bot --- Gemfile | 2 +- Gemfile.lock | 8 ++-- engines/billing/test/broken/admin_customer_test.rb | 4 +- .../billing/test/broken/customer_creation_test.rb | 6 +-- engines/billing/test/broken/subscription_test.rb | 2 +- engines/billing/test/factories.rb | 2 +- engines/support/test/factories.rb | 4 +- .../test/functional/ticket_comments_test.rb | 18 +++++---- .../test/functional/tickets_controller_test.rb | 4 +- .../support/test/functional/tickets_list_test.rb | 47 +++++++++++----------- .../support/test/integration/create_ticket_test.rb | 8 +++- .../support/test/unit/account_extension_test.rb | 2 +- engines/support/test/unit/ticket_test.rb | 21 +++++++--- features/step_definitions/auth_steps.rb | 2 +- features/step_definitions/messages_steps.rb | 4 +- test/factories.rb | 2 +- test/functional/api/identities_controller_test.rb | 7 +++- test/functional/api/messages_controller_test.rb | 13 ++---- test/functional/api/users_controller_test.rb | 4 +- test/functional/identities_controller_test.rb | 16 +++++--- test/integration/api/pgp_key_test.rb | 2 +- test/integration/browser/account_livecycle_test.rb | 2 +- test/integration/browser/admin_test.rb | 2 +- test/integration/browser/security_test.rb | 2 +- test/support/api_integration_test.rb | 2 +- test/support/browser_integration_test.rb | 2 +- test/support/stub_record_helper.rb | 4 +- test/unit/account_test.rb | 7 ++-- test/unit/invite_code_validator_test.rb | 17 ++++---- test/unit/token_test.rb | 17 ++++---- test/unit/user_test.rb | 6 +-- 31 files changed, 134 insertions(+), 105 deletions(-) diff --git a/Gemfile b/Gemfile index 3199e0a..7a17dcd 100644 --- a/Gemfile +++ b/Gemfile @@ -66,7 +66,7 @@ group :test do gem 'minitest-stub-const' # why? # generating test data - gem 'factory_girl_rails' # test data factories + gem 'factory_bot_rails' # test data factories gem 'faker' # names and numbers for test data gem 'psych', '~> 2.2.4' # needed by faker diff --git a/Gemfile.lock b/Gemfile.lock index 430155b..3cae8eb 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -129,10 +129,10 @@ GEM equalizer (0.0.11) erubis (2.7.0) execjs (2.7.0) - factory_girl (4.9.0) + factory_bot (4.8.2) activesupport (>= 3.0.0) - factory_girl_rails (4.9.0) - factory_girl (~> 4.9.0) + factory_bot_rails (4.8.2) + factory_bot (~> 4.8.2) railties (>= 3.0.0) fake_braintree (0.8.0) activesupport @@ -359,7 +359,7 @@ DEPENDENCIES couchrest_session_store (~> 0.4.2) cucumber (~> 2.4.0) cucumber-rails - factory_girl_rails + factory_bot_rails fake_braintree faker haml-rails diff --git a/engines/billing/test/broken/admin_customer_test.rb b/engines/billing/test/broken/admin_customer_test.rb index df92a0d..2fb80ca 100644 --- a/engines/billing/test/broken/admin_customer_test.rb +++ b/engines/billing/test/broken/admin_customer_test.rb @@ -4,8 +4,8 @@ require 'fake_braintree' class AdminCustomerTest < BraintreeIntegrationTest setup do - @admin = User.find_by_login('admin') || FactoryGirl.create(:user, login: 'admin') - @user = FactoryGirl.create(:user) + @admin = User.find_by_login('admin') || FactoryBot.create(:user, login: 'admin') + @user = FactoryBot.create(:user) end teardown do diff --git a/engines/billing/test/broken/customer_creation_test.rb b/engines/billing/test/broken/customer_creation_test.rb index 90319a9..da171c4 100644 --- a/engines/billing/test/broken/customer_creation_test.rb +++ b/engines/billing/test/broken/customer_creation_test.rb @@ -4,7 +4,7 @@ require 'fake_braintree' class CustomerCreationTest < BraintreeIntegrationTest setup do - @user = FactoryGirl.create(:user) + @user = FactoryBot.create(:user) login_as @user end @@ -38,7 +38,7 @@ class CustomerCreationTest < BraintreeIntegrationTest # for a broken customer test "successfully confirms customer creation" do response = post_transparent_redirect :create_customer_data, - customer: FactoryGirl.attributes_for(:braintree_customer), + customer: FactoryBot.attributes_for(:braintree_customer), redirect_url: confirm_customer_url assert_difference("Customer.count") do @@ -57,7 +57,7 @@ class CustomerCreationTest < BraintreeIntegrationTest FakeBraintree.decline_all_cards! response = post_transparent_redirect :create_customer_data, - customer: FactoryGirl.attributes_for(:broken_customer), + customer: FactoryBot.attributes_for(:broken_customer), redirect_url: confirm_customer_url assert FakeBraintree.decline_all_cards? diff --git a/engines/billing/test/broken/subscription_test.rb b/engines/billing/test/broken/subscription_test.rb index cd010bd..dd9bba9 100644 --- a/engines/billing/test/broken/subscription_test.rb +++ b/engines/billing/test/broken/subscription_test.rb @@ -6,7 +6,7 @@ class SubscriptionTest < BraintreeIntegrationTest include StubRecordHelper setup do - @admin = User.find_by_login('admin') || FactoryGirl.create(:user, login: 'admin') + @admin = User.find_by_login('admin') || FactoryBot.create(:user, login: 'admin') @customer = stub_customer @braintree_customer = @customer.braintree_customer response = Braintree::Subscription.create plan_id: '5', diff --git a/engines/billing/test/factories.rb b/engines/billing/test/factories.rb index 6352211..572da48 100644 --- a/engines/billing/test/factories.rb +++ b/engines/billing/test/factories.rb @@ -1,4 +1,4 @@ -FactoryGirl.define do +FactoryBot.define do TEST_CC_NUMBER = %w(4111 1111 1111 1111).join diff --git a/engines/support/test/factories.rb b/engines/support/test/factories.rb index 3fc28b3..7bc2ec7 100644 --- a/engines/support/test/factories.rb +++ b/engines/support/test/factories.rb @@ -1,4 +1,4 @@ -FactoryGirl.define do +FactoryBot.define do factory :ticket do subject { Faker::Lorem.sentence } @@ -14,7 +14,7 @@ FactoryGirl.define do end factory :ticket_with_creator do - created_by { FactoryGirl.create(:user).id } + created_by { FactoryBot.create(:user).id } end end diff --git a/engines/support/test/functional/ticket_comments_test.rb b/engines/support/test/functional/ticket_comments_test.rb index c6c143a..826850d 100644 --- a/engines/support/test/functional/ticket_comments_test.rb +++ b/engines/support/test/functional/ticket_comments_test.rb @@ -9,7 +9,7 @@ class TicketsCommentsTest < ActionController::TestCase end test "add comment to unauthenticated ticket" do - ticket = FactoryGirl.create :ticket, :created_by => nil + ticket = create_ticket :created_by => nil assert_difference('Ticket.find(ticket.id).comments.count') do put :update, :id => ticket.id, @@ -25,7 +25,7 @@ class TicketsCommentsTest < ActionController::TestCase test "add comment to own authenticated ticket" do login - ticket = FactoryGirl.create :ticket, :created_by => @current_user.id + ticket = create_ticket :created_by => @current_user.id #they should be able to comment if it is their ticket: assert_difference('Ticket.find(ticket.id).comments.count') do @@ -42,7 +42,7 @@ class TicketsCommentsTest < ActionController::TestCase test "cannot comment if it is another users ticket" do other_user = find_record :user login :is_admin? => false, :email => nil - ticket = FactoryGirl.create :ticket, :created_by => other_user.id + ticket = create_ticket :created_by => other_user.id # they should *not* be able to comment if it is not their ticket put :update, :id => ticket.id, :ticket => {:comments_attributes => {"0" => {"body" =>"not allowed comment"}} } assert_response :redirect @@ -53,8 +53,8 @@ class TicketsCommentsTest < ActionController::TestCase test "authenticated comment on an anonymous ticket adds to my tickets" do login - ticket = FactoryGirl.create :ticket - other_ticket = FactoryGirl.create :ticket + ticket = create_ticket + other_ticket = create_ticket put :update, :id => ticket.id, :ticket => {:comments_attributes => {"0" => {"body" =>"NEWER comment"}} } assert_not_nil assigns(:ticket).comments.last.posted_by @@ -71,7 +71,7 @@ class TicketsCommentsTest < ActionController::TestCase admin = find_record :user, @current_user other_user = find_record :user - ticket = FactoryGirl.create :ticket, :created_by => other_user.id + ticket = create_ticket :created_by => other_user.id #admin should be able to comment: assert_difference('Ticket.find(ticket.id).comments.count') do @@ -84,7 +84,7 @@ class TicketsCommentsTest < ActionController::TestCase end test "commenting on a ticket adds to tickets that are mine" do - testticket = FactoryGirl.create :ticket + testticket = create_ticket user = find_record :admin_user login user get :index, {:user_id => user.id, :open_status => "open"} @@ -98,4 +98,8 @@ class TicketsCommentsTest < ActionController::TestCase assert_equal assigns(:ticket).comments.last.posted_by, @current_user.id end + def create_ticket(attrs = {}) + FactoryBot.create :ticket, attrs + end + end diff --git a/engines/support/test/functional/tickets_controller_test.rb b/engines/support/test/functional/tickets_controller_test.rb index 2f1e661..e86ec11 100644 --- a/engines/support/test/functional/tickets_controller_test.rb +++ b/engines/support/test/functional/tickets_controller_test.rb @@ -137,7 +137,7 @@ class TicketsControllerTest < ActionController::TestCase test "close ticket" do login - open_ticket = FactoryGirl.create :ticket_with_comment, + open_ticket = FactoryBot.create :ticket_with_comment, created_by: @current_user.id post :close, id: open_ticket.id assert !open_ticket.reload.is_open @@ -145,7 +145,7 @@ class TicketsControllerTest < ActionController::TestCase test "reopen ticket" do login - open_ticket = FactoryGirl.create :ticket_with_comment, + open_ticket = FactoryBot.create :ticket_with_comment, created_by: @current_user.id, is_open: false post :open, id: open_ticket.id assert open_ticket.reload.is_open diff --git a/engines/support/test/functional/tickets_list_test.rb b/engines/support/test/functional/tickets_list_test.rb index ab76f5f..0e676b8 100644 --- a/engines/support/test/functional/tickets_list_test.rb +++ b/engines/support/test/functional/tickets_list_test.rb @@ -12,7 +12,7 @@ class TicketsListTest < ActionController::TestCase test "tickets by admin" do other_user = find_record :user - ticket = FactoryGirl.create :ticket, :created_by => other_user.id + ticket = create_ticket :created_by => other_user.id login :is_admin? => true @@ -29,7 +29,7 @@ class TicketsListTest < ActionController::TestCase test "admin_status mine vs all" do - testticket = FactoryGirl.create :ticket + testticket = create_ticket user = find_record :user login :is_admin? => true, :email => nil @@ -40,8 +40,7 @@ class TicketsListTest < ActionController::TestCase end test "admin ticket ordering" do - tickets = FactoryGirl.create_list :ticket, 2 - + 2.times { create_ticket } login :is_admin? => true, :email => nil get :index, {:admin_status => "all", :open_status => "open", :sort_order => 'created_at_desc'} @@ -63,9 +62,9 @@ class TicketsListTest < ActionController::TestCase test "own tickets include tickets commented upon" do login - ticket = FactoryGirl.create :ticket - other_ticket = FactoryGirl.create :ticket - comment = FactoryGirl.build(:ticket_comment, posted_by: @current_user.id) + ticket = create_ticket + other_ticket = create_ticket + comment = FactoryBot.build :ticket_comment, posted_by: @current_user.id ticket.comments << comment ticket.save @@ -77,20 +76,16 @@ class TicketsListTest < ActionController::TestCase test "list all tickets created by user" do login - ticket = FactoryGirl.create :ticket_with_comment, - created_by: @current_user.id - other_ticket = FactoryGirl.create :ticket_with_comment, - created_by: @current_user.id + ticket = create_ticket_with_comment created_by: @current_user.id + other_ticket = create_ticket_with_comment created_by: @current_user.id get :index, {:open_status => "open"} assert_equal 2, assigns[:all_tickets].count end test "closing ticket removes from open tickets list" do login - ticket = FactoryGirl.create :ticket_with_comment, - created_by: @current_user.id - other_ticket = FactoryGirl.create :ticket_with_comment, - created_by: @current_user.id + ticket = create_ticket_with_comment created_by: @current_user.id + other_ticket = create_ticket_with_comment created_by: @current_user.id other_ticket.reload other_ticket.close other_ticket.save @@ -100,23 +95,29 @@ class TicketsListTest < ActionController::TestCase test "list closed tickets only" do login - open_ticket = FactoryGirl.create :ticket_with_comment, - created_by: @current_user.id - closed_ticket = FactoryGirl.create :ticket_with_comment, - created_by: @current_user.id, is_open: false + open_ticket = create_ticket_with_comment created_by: @current_user.id + closed_ticket = create_ticket_with_comment created_by: @current_user.id, + is_open: false get :index, {:open_status => "closed"} assert_equal [closed_ticket], assigns(:all_tickets).all end test "list all tickets" do login - open_ticket = FactoryGirl.create :ticket_with_comment, - created_by: @current_user.id - closed_ticket = FactoryGirl.create :ticket_with_comment, - created_by: @current_user.id, is_open: false + open_ticket = create_ticket_with_comment created_by: @current_user.id + closed_ticket = create_ticket_with_comment created_by: @current_user.id, + is_open: false get :index, {:open_status => "all"} assert_equal 2, assigns(:all_tickets).count assert assigns(:all_tickets).include?(open_ticket) assert assigns(:all_tickets).include?(closed_ticket) end + + def create_ticket(attrs = {}) + FactoryBot.create :ticket, attrs + end + + def create_ticket_with_comment(attrs = {}) + FactoryBot.create :ticket_with_comment, attrs + end end diff --git a/engines/support/test/integration/create_ticket_test.rb b/engines/support/test/integration/create_ticket_test.rb index fcdc6b8..cccd2b2 100644 --- a/engines/support/test/integration/create_ticket_test.rb +++ b/engines/support/test/integration/create_ticket_test.rb @@ -34,7 +34,9 @@ class CreateTicketTest < BrowserIntegrationTest end test "prefills fields" do - login FactoryGirl.create(:premium_user, :invite_code => @testcode.invite_code) + user = FactoryBot.create :premium_user, + :invite_code => @testcode.invite_code + login user visit '/' click_on "Support Tickets" click_on "New Ticket" @@ -53,7 +55,9 @@ class CreateTicketTest < BrowserIntegrationTest end test "cleared email field should remain clear" do - login FactoryGirl.create(:premium_user, :invite_code => @testcode.invite_code) + user = FactoryBot.create :premium_user, + :invite_code => @testcode.invite_code + login user visit '/' click_on "Support Tickets" click_on "New Ticket" diff --git a/engines/support/test/unit/account_extension_test.rb b/engines/support/test/unit/account_extension_test.rb index 1b97062..88dc681 100644 --- a/engines/support/test/unit/account_extension_test.rb +++ b/engines/support/test/unit/account_extension_test.rb @@ -7,7 +7,7 @@ class AccountExtensionTest < ActiveSupport::TestCase end test "destroying an account triggers ticket destruction" do - t = FactoryGirl.create :ticket_with_creator + t = FactoryBot.create :ticket_with_creator u = t.created_by_user Account.new(u).destroy assert_nil Ticket.find(t.id) diff --git a/engines/support/test/unit/ticket_test.rb b/engines/support/test/unit/ticket_test.rb index 048704c..78c81bd 100644 --- a/engines/support/test/unit/ticket_test.rb +++ b/engines/support/test/unit/ticket_test.rb @@ -7,22 +7,22 @@ class TicketTest < ActiveSupport::TestCase end test "ticket with default attribs is valid" do - t = FactoryGirl.build :ticket + t = build_ticket assert t.valid?, t.errors.full_messages.to_sentence end test "ticket without email is valid" do - t = FactoryGirl.build :ticket, email: "" + t = build_ticket email: "" assert t.valid?, t.errors.full_messages.to_sentence end test "ticket validates email format" do - t = FactoryGirl.build :ticket, email: "invalid email" + t = build_ticket email: "invalid email" assert !t.valid? end test "ticket open states" do - t = FactoryGirl.build :ticket + t = build_ticket assert t.is_open t.close assert !t.is_open @@ -31,7 +31,7 @@ class TicketTest < ActiveSupport::TestCase end test "creation validated" do - user = FactoryGirl.create :user + user = create_user @sample = Ticket.new assert !@sample.is_creator_validated? @sample.created_by = user.id @@ -39,7 +39,7 @@ class TicketTest < ActiveSupport::TestCase end test "destroy all tickets from a user" do - t = FactoryGirl.create :ticket_with_creator + t = FactoryBot.create :ticket_with_creator u = t.created_by_user Ticket.destroy_all_from(u) assert_nil Ticket.find(t.id) @@ -89,4 +89,13 @@ class TicketTest < ActiveSupport::TestCase assert_equal [], Ticket.by_includes_post_by.key('123').all; end + protected + + def build_ticket(attrs = {}) + FactoryBot.build :ticket, attrs + end + + def create_user + FactoryBot.create :user + end end diff --git a/features/step_definitions/auth_steps.rb b/features/step_definitions/auth_steps.rb index 52c92ee..81c5fc5 100644 --- a/features/step_definitions/auth_steps.rb +++ b/features/step_definitions/auth_steps.rb @@ -1,7 +1,7 @@ Given /^I authenticated$/ do @testcode = InviteCode.new @testcode.save! - @user = FactoryGirl.create(:user, :invite_code => @testcode.invite_code) + @user = FactoryBot.create(:user, :invite_code => @testcode.invite_code) @my_auth_token = Token.create user_id: @user.id end diff --git a/features/step_definitions/messages_steps.rb b/features/step_definitions/messages_steps.rb index 30bc7c3..89d0196 100644 --- a/features/step_definitions/messages_steps.rb +++ b/features/step_definitions/messages_steps.rb @@ -1,5 +1,5 @@ Given /^there is a message for me$/ do - @message = FactoryGirl.create :message, user_ids_to_show: [@user.id] + @message = FactoryBot.create :message, user_ids_to_show: [@user.id] end Given /^there is a message for me with:$/ do |options| @@ -8,7 +8,7 @@ Given /^there is a message for me with:$/ do |options| if old_message = Message.find(attributes['id']) old_message.destroy end - @message = FactoryGirl.create :message, attributes + @message = FactoryBot.create :message, attributes end Given(/^that message is marked as read$/) do diff --git a/test/factories.rb b/test/factories.rb index 5d49729..f287842 100644 --- a/test/factories.rb +++ b/test/factories.rb @@ -3,7 +3,7 @@ Dir.glob(ENGINE_FACTORY_FILES) do |factory_file| require factory_file end -FactoryGirl.define do +FactoryBot.define do factory :user do # Faker::Internet.user_name alone was sometimes diff --git a/test/functional/api/identities_controller_test.rb b/test/functional/api/identities_controller_test.rb index 57345c8..bb5608e 100644 --- a/test/functional/api/identities_controller_test.rb +++ b/test/functional/api/identities_controller_test.rb @@ -4,7 +4,7 @@ class Api::IdentitiesControllerTest < ApiControllerTest test "api monitor can fetch identity" do monitor_auth do - identity = FactoryGirl.create :identity + identity = create_identity api_get :show, :id => identity.address, :format => 'json' assert_response :success assert_equal identity, assigns(:identity) @@ -16,9 +16,12 @@ class Api::IdentitiesControllerTest < ApiControllerTest test "anonymous cannot fetch identity" do - identity = FactoryGirl.create :identity + identity = create_identity api_get :show, :id => identity.address, :format => 'json' assert_response :forbidden end + def create_identity + FactoryBot.create :identity + end end diff --git a/test/functional/api/messages_controller_test.rb b/test/functional/api/messages_controller_test.rb index e586980..31ba2b0 100644 --- a/test/functional/api/messages_controller_test.rb +++ b/test/functional/api/messages_controller_test.rb @@ -2,17 +2,12 @@ require 'test_helper' class Api::MessagesControllerTest < ApiControllerTest - setup do - @user = FactoryGirl.build(:user) - @user.save - end - # NOTE: the available languages for test are :en and :de # so :es will result in english response. test "get the motd" do with_config("customization_directory" => Rails.root+'test/files') do - login @user + login api_get :index, :locale => 'es' body = JSON.parse(response.body) message1 = "

\"This\" is a very fine message. https://bitmask.net

\n" @@ -23,7 +18,7 @@ class Api::MessagesControllerTest < ApiControllerTest test "get localized motd" do with_config("customization_directory" => Rails.root+'test/files') do - login @user + login api_get :index, :locale => 'de' body = JSON.parse(response.body) message1 = "

Dies ist eine sehr feine Nachricht. https://bitmask.net

\n" @@ -32,7 +27,7 @@ class Api::MessagesControllerTest < ApiControllerTest end test "get empty motd" do - login @user + login api_get :index assert_equal "[]", response.body, "motd response should be empty if no motd directory exists" end @@ -44,7 +39,7 @@ class Api::MessagesControllerTest < ApiControllerTest =begin setup do InviteCodeValidator.any_instance.stubs(:validate) - @user = FactoryGirl.build(:user) + @user = FactoryBot.build(:user) @user.save @message = Message.new(:text => 'a test message') @message.user_ids_to_show << @user.id diff --git a/test/functional/api/users_controller_test.rb b/test/functional/api/users_controller_test.rb index ee183f9..dfaf959 100644 --- a/test/functional/api/users_controller_test.rb +++ b/test/functional/api/users_controller_test.rb @@ -96,7 +96,7 @@ class Api::UsersControllerTest < ApiControllerTest end test "admin can show user" do - user = FactoryGirl.create :user + user = FactoryBot.create :user login :is_admin? => true api_get :show, :id => 0, :login => user.login, :format => :json assert_response :success @@ -109,7 +109,7 @@ class Api::UsersControllerTest < ApiControllerTest end test "admin can show is_admin property" do - admin = FactoryGirl.create :user + admin = FactoryBot.create :user with_config(admins: [admin.login]) do login admin api_get :show, :id => admin.id, :format => :json diff --git a/test/functional/identities_controller_test.rb b/test/functional/identities_controller_test.rb index 5af2e88..5e46f9c 100644 --- a/test/functional/identities_controller_test.rb +++ b/test/functional/identities_controller_test.rb @@ -1,4 +1,4 @@ -require_relative '../test_helper' +require 'test_helper' class IdentitiesControllerTest < ActionController::TestCase @@ -26,7 +26,7 @@ class IdentitiesControllerTest < ActionController::TestCase test "admin can unblock username" do # an identity without user_id and destination is a blocked handle - identity = FactoryGirl.create :identity + identity = create_identity login :is_admin? => true delete :destroy, id: identity.id assert_response :redirect @@ -34,13 +34,19 @@ class IdentitiesControllerTest < ActionController::TestCase end test "admin cannot remove main identity" do - user = FactoryGirl.create :user - identity = FactoryGirl.create :identity, - Identity.attributes_from_user(user) + user = create_user + identity = create_identity Identity.attributes_from_user(user) login :is_admin? => true delete :destroy, id: identity.id assert_response :redirect assert_equal identity, Identity.find(identity.id) end + def create_identity(attrs={}) + FactoryBot.create :identity, attrs + end + + def create_user + FactoryBot.create :user + end end diff --git a/test/integration/api/pgp_key_test.rb b/test/integration/api/pgp_key_test.rb index f2744e1..1ffbe54 100644 --- a/test/integration/api/pgp_key_test.rb +++ b/test/integration/api/pgp_key_test.rb @@ -30,7 +30,7 @@ class PgpKeyTest < SrpTest protected def key - @key ||= FactoryGirl.build :pgp_key + @key ||= FactoryBot.build :pgp_key end def assert_invalid_key_response diff --git a/test/integration/browser/account_livecycle_test.rb b/test/integration/browser/account_livecycle_test.rb index 68775d3..48be234 100644 --- a/test/integration/browser/account_livecycle_test.rb +++ b/test/integration/browser/account_livecycle_test.rb @@ -103,7 +103,7 @@ class AccountLivecycleTest < BrowserIntegrationTest test "change pgp key" do with_config user_actions: ['change_pgp_key'] do - pgp_key = FactoryGirl.build :pgp_key + pgp_key = FactoryBot.build :pgp_key username, _password = submit_signup click_on "Account Settings" within('#update_pgp_key') do diff --git a/test/integration/browser/admin_test.rb b/test/integration/browser/admin_test.rb index 0b43c29..ff36416 100644 --- a/test/integration/browser/admin_test.rb +++ b/test/integration/browser/admin_test.rb @@ -21,7 +21,7 @@ class AdminTest < BrowserIntegrationTest end test "clear blocked handle" do - id = FactoryGirl.create :identity + id = FactoryBot.create :identity submit_signup(id.login) assert page.has_content?('has already been taken') login diff --git a/test/integration/browser/security_test.rb b/test/integration/browser/security_test.rb index 825d50b..7073b76 100644 --- a/test/integration/browser/security_test.rb +++ b/test/integration/browser/security_test.rb @@ -10,7 +10,7 @@ class SecurityTest < BrowserIntegrationTest test "detects attempt to circumvent SRP" do InviteCodeValidator.any_instance.stubs(:validate) - user = FactoryGirl.create :user + user = FactoryBot.create :user visit '/login' fill_in 'Username', with: user.login fill_in 'Password', with: "password" diff --git a/test/support/api_integration_test.rb b/test/support/api_integration_test.rb index 7942558..94c88e1 100644 --- a/test/support/api_integration_test.rb +++ b/test/support/api_integration_test.rb @@ -22,7 +22,7 @@ class ApiIntegrationTest < ActionDispatch::IntegrationTest @testcode = InviteCode.new @testcode.save! options.reverse_merge! invite_code: @testcode.invite_code - FactoryGirl.create :user, options + FactoryBot.create :user, options end teardown do diff --git a/test/support/browser_integration_test.rb b/test/support/browser_integration_test.rb index d00e606..cff732b 100644 --- a/test/support/browser_integration_test.rb +++ b/test/support/browser_integration_test.rb @@ -49,7 +49,7 @@ class BrowserIntegrationTest < RackStackTest # ApiIntegrationTest has a working implementation for RackTest def login(user = nil) InviteCodeValidator.any_instance.stubs(:validate) - @user ||= user ||= FactoryGirl.create(:user) + @user ||= user ||= FactoryBot.create(:user) token = Token.create user_id: user.id page.driver.add_header "Authorization", %Q(Token token="#{token}") visit '/' diff --git a/test/support/stub_record_helper.rb b/test/support/stub_record_helper.rb index 25138a0..4d74f2a 100644 --- a/test/support/stub_record_helper.rb +++ b/test/support/stub_record_helper.rb @@ -26,7 +26,7 @@ module StubRecordHelper if record_or_method_hash && !record_or_method_hash.is_a?(Hash) return record_or_method_hash end - FactoryGirl.build_stubbed(factory).tap do |record| + FactoryBot.build_stubbed(factory).tap do |record| if persisted or record.persisted? record_or_method_hash.reverse_merge! :created_at => Time.now, :updated_at => Time.now, :id => Random.rand(100000).to_s @@ -38,7 +38,7 @@ module StubRecordHelper # returns deep stringified attributes so they can be compared to # what the controller receives as params def record_attributes_for(factory, attribs_hash = nil) - FactoryGirl.attributes_for(factory, attribs_hash).tap do |attribs| + FactoryBot.attributes_for(factory, attribs_hash).tap do |attribs| attribs.keys.each do |key| val = attribs.delete(key) attribs[key.to_s] = val.is_a?(Hash) ? val.stringify_keys! : val diff --git a/test/unit/account_test.rb b/test/unit/account_test.rb index ebfff6b..8923a81 100644 --- a/test/unit/account_test.rb +++ b/test/unit/account_test.rb @@ -58,7 +58,7 @@ class AccountTest < ActiveSupport::TestCase test "error on invalid username" do with_config invite_required: false do - attributes = FactoryGirl.attributes_for :user, login: "a" + attributes = user_attributes login: "a" @user = Account.create attributes assert !@user.valid? assert_has_errors @user, login: "Must have at least two characters" @@ -155,7 +155,8 @@ class AccountTest < ActiveSupport::TestCase end test "Invite code stays zero when invite code is not used" do - invalid_user = FactoryGirl.build(:user, :invite_code => @testcode.invite_code) + invalid_user = FactoryBot.build :user, + :invite_code => @testcode.invite_code invalid_user.save user_code = InviteCode.find_by_invite_code invalid_user.invite_code user_code.save @@ -206,7 +207,7 @@ class AccountTest < ActiveSupport::TestCase end def user_attributes(attrs = {}) - FactoryGirl.attributes_for :user, attrs + FactoryBot.attributes_for :user, attrs end end diff --git a/test/unit/invite_code_validator_test.rb b/test/unit/invite_code_validator_test.rb index 934ba2e..7c3501a 100644 --- a/test/unit/invite_code_validator_test.rb +++ b/test/unit/invite_code_validator_test.rb @@ -3,14 +3,14 @@ require 'test_helper' class InviteCodeValidatorTest < ActiveSupport::TestCase test "user should not be created with invalid invite code" do with_config invite_required: true do - invalid_user = FactoryGirl.build(:user) + invalid_user = build_user assert !invalid_user.valid? end end test "user should be created with valid invite code" do - valid_user = FactoryGirl.build(:user) + valid_user = build_user valid_code = InviteCode.create valid_user.invite_code = valid_code.invite_code @@ -19,7 +19,7 @@ class InviteCodeValidatorTest < ActiveSupport::TestCase test "trying to create a user with invalid invite code should add error" do with_config invite_required: true do - invalid_user = FactoryGirl.build(:user, :invite_code => "a non-existent code") + invalid_user = build_user :invite_code => "a non-existent code" invalid_user.valid? @@ -36,7 +36,7 @@ class InviteCodeValidatorTest < ActiveSupport::TestCase user_code.invite_count = 1 user_code.save - user = FactoryGirl.build :user + user = build_user user.invite_code = user_code.invite_code validator.validate(user) @@ -51,7 +51,7 @@ class InviteCodeValidatorTest < ActiveSupport::TestCase user_code = InviteCode.create user_code.save - user = FactoryGirl.build :user + user = build_user user.invite_code = user_code.invite_code validator.validate(user) @@ -64,7 +64,7 @@ class InviteCodeValidatorTest < ActiveSupport::TestCase user_code = InviteCode.create - user = FactoryGirl.build :user + user = build_user user.invite_code = user_code.invite_code validator.validate(user) @@ -75,7 +75,7 @@ class InviteCodeValidatorTest < ActiveSupport::TestCase test "There is an error message if the invite code does not exist" do validator = InviteCodeValidator.new - user = FactoryGirl.build :user + user = build_user user.invite_code = "wrongcode" validator.validate(user) @@ -83,4 +83,7 @@ class InviteCodeValidatorTest < ActiveSupport::TestCase assert_equal ["This is not a valid code"], user.errors[:invite_code] end + def build_user(attrs = {}) + FactoryBot.build :user, attrs + end end diff --git a/test/unit/token_test.rb b/test/unit/token_test.rb index ce7edaa..3015c9a 100644 --- a/test/unit/token_test.rb +++ b/test/unit/token_test.rb @@ -64,7 +64,7 @@ class TokenTest < ActiveSupport::TestCase end test "Token.destroy_all_expired is noop if no expiry is set" do - expired = FactoryGirl.create :token, last_seen_at: 2.hours.ago + expired = create_token last_seen_at: 2.hours.ago with_config auth: {} do Token.destroy_all_expired end @@ -72,8 +72,8 @@ class TokenTest < ActiveSupport::TestCase end test "Token.destroy_all_expired cleans up expired tokens only" do - expired = FactoryGirl.create :token, last_seen_at: 2.hours.ago - fresh = FactoryGirl.create :token + expired = create_token last_seen_at: 2.hours.ago + fresh = create_token with_config auth: {token_expires_after: 60} do Token.destroy_all_expired end @@ -83,7 +83,7 @@ class TokenTest < ActiveSupport::TestCase end test "Token.destroy_all_expired does not interfere with expired.authenticate" do - expired = FactoryGirl.create :token, last_seen_at: 2.hours.ago + expired = create_token last_seen_at: 2.hours.ago with_config auth: {token_expires_after: 60} do Token.destroy_all_expired end @@ -91,7 +91,7 @@ class TokenTest < ActiveSupport::TestCase end test "active logout (destroy) prevents reuse" do - token = FactoryGirl.create :token + token = create_token same = Token.find(token.id) token.destroy assert_raises CouchRest::NotFound do @@ -100,7 +100,7 @@ class TokenTest < ActiveSupport::TestCase end test "logout works on prolonged token" do - token = FactoryGirl.create :token + token = create_token same = Token.find(token.id) token.touch same.destroy @@ -108,11 +108,14 @@ class TokenTest < ActiveSupport::TestCase end test 'second destroy carries on' do - token = FactoryGirl.create :token + token = create_token same = Token.find(token.id) token.destroy same.destroy assert_nil Token.find(same.id) end + def create_token(attrs = {}) + FactoryBot.create :token, attrs + end end diff --git a/test/unit/user_test.rb b/test/unit/user_test.rb index ab7add0..bd05170 100644 --- a/test/unit/user_test.rb +++ b/test/unit/user_test.rb @@ -5,7 +5,7 @@ class UserTest < ActiveSupport::TestCase include SRP::Util setup do InviteCodeValidator.any_instance.stubs(:validate) - @user = FactoryGirl.build(:user) + @user = FactoryBot.build(:user) end test "don't find a user with login nil" do @@ -62,13 +62,13 @@ class UserTest < ActiveSupport::TestCase end test "login needs to be unique" do - other_user = FactoryGirl.create :user, login: @user.login + other_user = FactoryBot.create :user, login: @user.login assert !@user.valid? other_user.destroy end test "login needs to be unique amongst aliases" do - other_user = FactoryGirl.create :user + other_user = FactoryBot.create :user id = Identity.create_for other_user, address: @user.login assert !@user.valid? id.destroy -- cgit v1.2.3 From 7120117687e2e6078d7e94ddb9e8b93e8ad5f2e3 Mon Sep 17 00:00:00 2001 From: Azul Date: Fri, 8 Dec 2017 21:34:14 +0100 Subject: upgrade: fix mocha deprecation --- test/support/auth_test_helper.rb | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/test/support/auth_test_helper.rb b/test/support/auth_test_helper.rb index acc6076..df008e5 100644 --- a/test/support/auth_test_helper.rb +++ b/test/support/auth_test_helper.rb @@ -53,9 +53,8 @@ module AuthTestHelper end def expect_warden_logout - raw = mock('raw session') do - expects(:inspect) - end + raw = mock('raw session') + raw.expects(:inspect) request.env['warden'].expects(:raw_session).returns(raw) request.env['warden'].expects(:logout) end -- cgit v1.2.3