diff --git a/Gemfile b/Gemfile index a60eac29..44094e50 100644 --- a/Gemfile +++ b/Gemfile @@ -4,16 +4,17 @@ source 'http://rubygems.org' # TODO: temporary disable http, until ruby upgrade with new openssl # source 'https://rubygems.org' -gem 'rails', '4.2.11' - -gem 'pg', '~> 0.15.1' +gem 'rails', '~> 5.2', '>= 5.2.3' +gem 'pg' gem 'pghero' gem 'thin' gem 'chartkick' gem 'aasm' -gem 'activemerchant', '~> 1.32.1' +gem 'activemerchant', '~> 1.93' +gem 'money' +gem 'offsite_payments' gem 'bootstrap', '~> 4.2.1' gem 'cancan' gem 'clockwork' @@ -27,14 +28,14 @@ gem 'slim' # Temporary broken with rails 4.2 gem 'active_model_serializers' # , github: 'rails-api/active_model_serializers', branch: '0-9-stable' -gem 'ransack', '1.5.1' +gem 'ransack', '2.1.1' # TODO: switch to stable version gem 'carrierwave' -gem 'draper', '1.4.0' +gem 'draper', '3.1' gem 'gibbon' gem 'mechanize' -gem 'rails_config' +gem 'config' gem 'russian_central_bank' gem 'show_for', github: 'plataformatec/show_for' gem 'whenever', '0.9.0', require: false @@ -46,11 +47,11 @@ gem 'rollbar' # TODO: make it optional via ENV flag gem 'newrelic_rpm' -gem 'json', '~> 1.8' +gem 'json', '~> 2.2' gem 'thread_safe', '0.3.6' group :assets do - gem 'coffee-rails', '~> 4.1.0' + gem 'coffee-rails', '~> 5.0' gem 'sass-rails' gem 'uglifier' end @@ -59,7 +60,7 @@ gem 'jquery-rails' gem 'jquery-ui-rails' gem 'ffi', '>= 1.9.24' -gem 'jbuilder', '~> 1.0.1' +gem 'jbuilder', '~> 2.8' group :development do gem 'better_errors' @@ -68,7 +69,7 @@ group :development do gem 'migration_opener' gem 'rubocop', require: false gem 'sandi_meter', require: false - gem 'web-console', '~> 2.0' + gem 'web-console', '~> 3.7' end group :test, :development do @@ -95,4 +96,5 @@ group :test do gem 'clockwork-test' gem 'fakeweb', github: 'chrisk/fakeweb' gem 'zonebie' + gem 'rails-controller-testing' end diff --git a/Gemfile.lock b/Gemfile.lock index dded63b8..45984b4b 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -6,79 +6,86 @@ GIT GIT remote: git://github.com/plataformatec/show_for.git - revision: 7f2dc583ee84e9fd86d00c70c5e63027b20a8efc + revision: 28166bfd03dc7b9ad54ec2f9939b5b24c8aff76f specs: - show_for (0.3.0.rc) - actionpack (>= 3.2, < 5) - activemodel (>= 3.2, < 5) + show_for (0.6.1) + actionpack (>= 4.1) + activemodel (>= 4.1) GEM remote: http://rubygems.org/ specs: aasm (5.0.1) concurrent-ruby (~> 1.0) - actionmailer (4.2.11) - actionpack (= 4.2.11) - actionview (= 4.2.11) - activejob (= 4.2.11) + actioncable (5.2.3) + actionpack (= 5.2.3) + nio4r (~> 2.0) + websocket-driver (>= 0.6.1) + actionmailer (5.2.3) + actionpack (= 5.2.3) + actionview (= 5.2.3) + activejob (= 5.2.3) mail (~> 2.5, >= 2.5.4) - rails-dom-testing (~> 1.0, >= 1.0.5) - actionpack (4.2.11) - actionview (= 4.2.11) - activesupport (= 4.2.11) - rack (~> 1.6) - rack-test (~> 0.6.2) - rails-dom-testing (~> 1.0, >= 1.0.5) + rails-dom-testing (~> 2.0) + actionpack (5.2.3) + actionview (= 5.2.3) + activesupport (= 5.2.3) + rack (~> 2.0) + rack-test (>= 0.6.3) + rails-dom-testing (~> 2.0) rails-html-sanitizer (~> 1.0, >= 1.0.2) - actionview (4.2.11) - activesupport (= 4.2.11) + actionview (5.2.3) + activesupport (= 5.2.3) builder (~> 3.1) - erubis (~> 2.7.0) - rails-dom-testing (~> 1.0, >= 1.0.5) + erubi (~> 1.4) + rails-dom-testing (~> 2.0) rails-html-sanitizer (~> 1.0, >= 1.0.3) active_model_serializers (0.8.1) activemodel (>= 3.0) - active_utils (1.0.5) - activesupport (>= 2.3.11) - i18n - activejob (4.2.11) - activesupport (= 4.2.11) - globalid (>= 0.3.0) - activemerchant (1.32.1) - active_utils (>= 1.0.2) - activesupport (>= 2.3.14) - builder (>= 2.0.0) + active_utils (3.3.16) + activesupport (>= 4.2) i18n - json (>= 1.5.1) - money - nokogiri - activemodel (4.2.11) - activesupport (= 4.2.11) + activejob (5.2.3) + activesupport (= 5.2.3) + globalid (>= 0.3.6) + activemerchant (1.95.0) + activesupport (>= 4.2) + builder (>= 2.1.2, < 4.0.0) + i18n (>= 0.6.9) + nokogiri (~> 1.4) + activemodel (5.2.3) + activesupport (= 5.2.3) + activemodel-serializers-xml (1.0.2) + activemodel (> 5.x) + activesupport (> 5.x) builder (~> 3.1) - activerecord (4.2.11) - activemodel (= 4.2.11) - activesupport (= 4.2.11) - arel (~> 6.0) - activesupport (4.2.11) - i18n (~> 0.7) + activerecord (5.2.3) + activemodel (= 5.2.3) + activesupport (= 5.2.3) + arel (>= 9.0) + activestorage (5.2.3) + actionpack (= 5.2.3) + activerecord (= 5.2.3) + marcel (~> 0.3.1) + activesupport (5.2.3) + concurrent-ruby (~> 1.0, >= 1.0.2) + i18n (>= 0.7, < 2) minitest (~> 5.1) - thread_safe (~> 0.3, >= 0.3.4) tzinfo (~> 1.1) addressable (2.3.4) akami (1.2.1) gyoku (>= 0.4.0) nokogiri - arel (6.0.4) + arel (9.0.0) ast (2.4.0) - autoprefixer-rails (9.4.4) + autoprefixer-rails (9.6.0) execjs - bcrypt (3.1.12) + bcrypt (3.1.13) better_errors (2.5.1) coderay (>= 1.0.0) erubi (>= 1.0.0) rack (>= 0.9.0) - binding_of_caller (0.7.2) - debug_inspector (>= 0.0.1) + bindex (0.7.0) bootstrap (4.2.1) autoprefixer-rails (>= 9.1.0) popper_js (>= 1.14.3, < 2) @@ -110,26 +117,30 @@ GEM clockwork timecop coderay (1.1.2) - coffee-rails (4.1.1) + coffee-rails (5.0.0) coffee-script (>= 2.2.0) - railties (>= 4.0.0, < 5.1.x) + railties (>= 5.2.0) coffee-script (2.4.1) coffee-script-source execjs coffee-script-source (1.12.2) - concurrent-ruby (1.1.4) + concurrent-ruby (1.1.5) + config (1.7.1) + activesupport (>= 3.0) + deep_merge (~> 1.2.1) + dry-validation (>= 0.12.2) connection_pool (2.2.2) crass (1.0.4) daemons (1.2.6) database_cleaner (1.0.0.RC1) - debug_inspector (0.0.2) + deep_merge (1.2.1) devise (4.5.0) bcrypt (~> 3.0) orm_adapter (~> 0.1) railties (>= 4.1.0, < 6.0) responders warden (~> 1.2.3) - devise-i18n (0.10.3) + devise-i18n (0.10.5) diff-lcs (1.3) docile (1.3.1) domain_name (0.5.19) @@ -138,13 +149,41 @@ GEM dotenv-rails (2.6.0) dotenv (= 2.6.0) railties (>= 3.2, < 6.0) - draper (1.4.0) - actionpack (>= 3.0) - activemodel (>= 3.0) - activesupport (>= 3.0) - request_store (~> 1.0) + draper (3.1.0) + actionpack (>= 5.0) + activemodel (>= 5.0) + activemodel-serializers-xml (>= 1.0) + activesupport (>= 5.0) + request_store (>= 1.0) + dry-configurable (0.8.3) + concurrent-ruby (~> 1.0) + dry-core (~> 0.4, >= 0.4.7) + dry-container (0.7.0) + concurrent-ruby (~> 1.0) + dry-configurable (~> 0.1, >= 0.1.3) + dry-core (0.4.7) + concurrent-ruby (~> 1.0) + dry-equalizer (0.2.2) + dry-inflector (0.1.2) + dry-logic (0.6.1) + concurrent-ruby (~> 1.0) + dry-core (~> 0.2) + dry-equalizer (~> 0.2) + dry-types (0.14.1) + concurrent-ruby (~> 1.0) + dry-container (~> 0.3) + dry-core (~> 0.4, >= 0.4.4) + dry-equalizer (~> 0.2) + dry-inflector (~> 0.1, >= 0.1.2) + dry-logic (~> 0.5, >= 0.5) + dry-validation (0.13.3) + concurrent-ruby (~> 1.0) + dry-configurable (~> 0.1, >= 0.1.3) + dry-core (~> 0.2, >= 0.2.1) + dry-equalizer (~> 0.2) + dry-logic (~> 0.5, >= 0.5.0) + dry-types (~> 0.14.0) erubi (1.8.0) - erubis (2.7.0) eventmachine (1.2.7) execjs (2.7.0) factory_girl (4.2.0) @@ -154,15 +193,17 @@ GEM railties (>= 3.0.0) faker (1.9.3) i18n (>= 0.7) + faraday (0.15.4) + multipart-post (>= 1.2, < 3) ffi (1.9.25) font-awesome-sass (5.6.1) sassc (>= 1.11) foreman (0.63.0) dotenv (>= 0.7) thor (>= 0.13.6) - gibbon (1.1.5) - httparty - multi_json (>= 1.9.0) + gibbon (3.2.0) + faraday (>= 0.9.1) + multi_json (>= 1.11.0) globalid (0.4.2) activesupport (>= 4.2.0) gyoku (1.1.1) @@ -170,9 +211,6 @@ GEM highline (2.0.0) http-cookie (1.0.2) domain_name (~> 0.5) - httparty (0.13.3) - json (~> 1.8) - multi_xml (>= 0.5.2) httpi (2.1.0) rack rubyntlm (~> 0.3.2) @@ -188,15 +226,16 @@ GEM rainbow (>= 2.2.2, < 4.0) terminal-table (>= 1.5.1) jaro_winkler (1.5.2) - jbuilder (1.0.2) - activesupport (>= 3.0.0) + jbuilder (2.8.0) + activesupport (>= 4.2.0) + multi_json (>= 1.2) jquery-rails (4.3.3) rails-dom-testing (>= 1, < 3) railties (>= 4.2.0) thor (>= 0.14, < 2.0) jquery-ui-rails (4.0.5) railties (>= 3.1.0) - json (1.8.6) + json (2.2.0) kaminari (1.1.1) activesupport (>= 4.1.0) kaminari-actionview (= 1.1.1) @@ -218,6 +257,8 @@ GEM nokogiri (>= 1.5.9) mail (2.7.1) mini_mime (>= 0.1.1) + marcel (0.3.3) + mimemagic (~> 0.3.2) mechanize (2.7.2) domain_name (~> 0.5, >= 0.5.1) http-cookie (~> 1.0.0) @@ -231,6 +272,7 @@ GEM migration_opener (0.0.3) rails mime-types (1.25.1) + mimemagic (0.3.3) mini_mime (1.0.1) mini_portile2 (2.4.0) minitest (5.11.3) @@ -238,24 +280,32 @@ GEM money (6.5.0) i18n (>= 0.6.4, <= 0.7.0) multi_json (1.13.1) - multi_xml (0.5.5) + multipart-post (2.1.1) + mustermann (1.0.3) net-http-digest_auth (1.4) net-http-persistent (2.9.4) newrelic_rpm (5.6.0.349) - nokogiri (1.10.1) + nio4r (2.3.1) + nokogiri (1.10.3) mini_portile2 (~> 2.4.0) nori (2.3.0) ntlm-http (0.1.1) + offsite_payments (2.7.13) + actionpack (>= 5.2.3) + actionview (>= 5.1.6.2) + active_utils (~> 3.3.0) + activesupport (>= 5.2.3) + builder (>= 2.1.2, < 4.0.0) + i18n (>= 0.6.6) + nokogiri (>= 1.8.5) orm_adapter (0.5.0) parallel (1.13.0) parser (2.6.0.0) ast (~> 2.4.0) - pg (0.15.1) + pg (1.1.4) pghero (0.1.3) activerecord pg - polyamorous (1.1.0) - activerecord (>= 3.0) popper_js (1.14.5) powerpack (0.1.2) pry (0.12.2) @@ -264,56 +314,58 @@ GEM pry-rails (0.3.9) pry (>= 0.10.4) psych (3.1.0) - rack (1.6.11) - rack-protection (1.5.5) + rack (2.0.7) + rack-protection (2.0.5) rack - rack-test (0.6.3) - rack (>= 1.0) - rails (4.2.11) - actionmailer (= 4.2.11) - actionpack (= 4.2.11) - actionview (= 4.2.11) - activejob (= 4.2.11) - activemodel (= 4.2.11) - activerecord (= 4.2.11) - activesupport (= 4.2.11) - bundler (>= 1.3.0, < 2.0) - railties (= 4.2.11) - sprockets-rails - rails-deprecated_sanitizer (1.0.3) - activesupport (>= 4.2.0.alpha) - rails-dom-testing (1.0.9) - activesupport (>= 4.2.0, < 5.0) - nokogiri (~> 1.6) - rails-deprecated_sanitizer (>= 1.0.1) + rack-test (1.1.0) + rack (>= 1.0, < 3) + rails (5.2.3) + actioncable (= 5.2.3) + actionmailer (= 5.2.3) + actionpack (= 5.2.3) + actionview (= 5.2.3) + activejob (= 5.2.3) + activemodel (= 5.2.3) + activerecord (= 5.2.3) + activestorage (= 5.2.3) + activesupport (= 5.2.3) + bundler (>= 1.3.0) + railties (= 5.2.3) + sprockets-rails (>= 2.0.0) + rails-controller-testing (1.0.4) + actionpack (>= 5.0.1.x) + actionview (>= 5.0.1.x) + activesupport (>= 5.0.1.x) + rails-dom-testing (2.0.3) + activesupport (>= 4.2.0) + nokogiri (>= 1.6) rails-html-sanitizer (1.0.4) loofah (~> 2.2, >= 2.2.2) rails-i18n (0.7.3) i18n (~> 0.5) - rails_config (0.3.3) - activesupport (>= 3.0) - railties (4.2.11) - actionpack (= 4.2.11) - activesupport (= 4.2.11) + railties (5.2.3) + actionpack (= 5.2.3) + activesupport (= 5.2.3) + method_source rake (>= 0.8.7) - thor (>= 0.18.1, < 2.0) + thor (>= 0.19.0, < 2.0) rainbow (3.0.0) rake (12.3.2) - ransack (1.5.1) - actionpack (>= 3.0) - activerecord (>= 3.0) - activesupport (>= 3.0) + ransack (2.1.1) + actionpack (>= 5.0) + activerecord (>= 5.0) + activesupport (>= 5.0) i18n - polyamorous (~> 1.1) rb-fsevent (0.10.3) rb-inotify (0.10.0) ffi (~> 1.0) redis (4.1.0) regexp_parser (1.3.0) - request_store (1.1.0) - responders (2.4.0) - actionpack (>= 4.2.0, < 5.3) - railties (>= 4.2.0, < 5.3) + request_store (1.4.1) + rack (>= 1.4) + responders (2.4.1) + actionpack (>= 4.2.0, < 6.0) + railties (>= 4.2.0, < 6.0) rollbar (2.18.2) multi_json rspec-core (3.8.0) @@ -365,10 +417,10 @@ GEM sprockets (>= 2.8, < 4.0) sprockets-rails (>= 2.0, < 4.0) tilt (>= 1.1, < 3) - sassc (2.0.0) - ffi (~> 1.9.6) + sassc (2.0.1) + ffi (~> 1.9) rake - sassc-rails (2.1.0) + sassc-rails (2.1.1) railties (>= 4.0.0) sassc (>= 2.0) sprockets (> 3.0) @@ -400,10 +452,11 @@ GEM json (>= 1.8, < 3) simplecov-html (~> 0.10.0) simplecov-html (0.10.2) - sinatra (1.4.8) - rack (~> 1.5) - rack-protection (~> 1.4) - tilt (>= 1.3, < 3) + sinatra (2.0.5) + mustermann (~> 1.0) + rack (~> 2.0) + rack-protection (= 2.0.5) + tilt (~> 2.0) slim (4.0.1) temple (>= 0.7.6, < 0.9) tilt (>= 2.0.6, < 2.1) @@ -434,18 +487,21 @@ GEM unf_ext (0.0.6) unicode-display_width (1.4.1) vcr (4.0.0) - warden (1.2.7) - rack (>= 1.0) + warden (1.2.8) + rack (>= 2.0.6) wasabi (3.2.3) httpi (~> 2.0) mime-types (< 2.0.0) nokogiri (>= 1.4.0) - web-console (2.0.0) - activemodel (~> 4.0) - binding_of_caller (>= 0.7.2) - railties (~> 4.0) - sprockets-rails (>= 2.0, < 4.0) + web-console (3.7.0) + actionview (>= 5.0) + activemodel (>= 5.0) + bindex (>= 0.4.0) + railties (>= 5.0) webrobots (0.1.1) + websocket-driver (0.7.0) + websocket-extensions (>= 0.1.0) + websocket-extensions (0.1.3) whenever (0.9.0) activesupport (>= 2.3.4) chronic (>= 0.6.3) @@ -459,7 +515,7 @@ PLATFORMS DEPENDENCIES aasm active_model_serializers - activemerchant (~> 1.32.1) + activemerchant (~> 1.93) better_errors bootstrap (~> 4.2.1) cancan @@ -469,12 +525,13 @@ DEPENDENCIES chartkick clockwork clockwork-test - coffee-rails (~> 4.1.0) + coffee-rails (~> 5.0) + config database_cleaner (= 1.0.0.RC1) devise (= 4.5.0) devise-i18n (~> 0.10.3) dotenv-rails - draper (= 1.4.0) + draper (= 3.1) factory_girl_rails (~> 4.0) faker fakeweb! @@ -483,22 +540,24 @@ DEPENDENCIES foreman gibbon i18n-tasks (~> 0.9.28) - jbuilder (~> 1.0.1) + jbuilder (~> 2.8) jquery-rails jquery-ui-rails - json (~> 1.8) + json (~> 2.2) kaminari letter_opener mechanize migration_opener + money newrelic_rpm - pg (~> 0.15.1) + offsite_payments + pg pghero pry-rails - rails (= 4.2.11) + rails (~> 5.2, >= 5.2.3) + rails-controller-testing rails-i18n - rails_config - ransack (= 1.5.1) + ransack (= 2.1.1) rollbar rspec-its rspec-rails (~> 3.8) @@ -519,7 +578,7 @@ DEPENDENCIES timecop uglifier vcr - web-console (~> 2.0) + web-console (~> 3.7) whenever (= 0.9.0) zonebie diff --git a/app/controllers/admin/change_languages_controller.rb b/app/controllers/admin/change_languages_controller.rb index 608149b1..d899547b 100644 --- a/app/controllers/admin/change_languages_controller.rb +++ b/app/controllers/admin/change_languages_controller.rb @@ -10,7 +10,7 @@ def update def set_session_and_redirect session[:locale] = I18n.locale - redirect_to :back + redirect_back fallback_location: admin_change_languages_path(locale: session[:locale]) end end end diff --git a/app/controllers/admin/users_controller.rb b/app/controllers/admin/users_controller.rb index da392bde..9c5f89b9 100644 --- a/app/controllers/admin/users_controller.rb +++ b/app/controllers/admin/users_controller.rb @@ -63,7 +63,7 @@ def payment def emails_export users = User.search(search_params).result - render text: Admin::UsersSerializer.new(users, :csv).emails + render plain: Admin::UsersSerializer.new(users, :csv).emails end def enable_test_period diff --git a/app/controllers/api/authentication_controller.rb b/app/controllers/api/authentication_controller.rb index 3c13e21c..8f13b6ad 100644 --- a/app/controllers/api/authentication_controller.rb +++ b/app/controllers/api/authentication_controller.rb @@ -13,9 +13,9 @@ class AuthenticationController < Api::BaseController def auth authenticator = Authenticator.new(params[:login], params[:password], params[:hostname]) if authenticator.valid_credentials? - render status: 200, nothing: true + render status: 200, body: nil else - render status: 404, nothing: true + render status: 404, body: nil end end end diff --git a/app/controllers/billing/merchant_controller.rb b/app/controllers/billing/merchant_controller.rb index 59993f73..6b207ffc 100644 --- a/app/controllers/billing/merchant_controller.rb +++ b/app/controllers/billing/merchant_controller.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true class Billing::MerchantController < Billing::BaseController - skip_before_filter :check_authorization, :verify_authenticity_token + skip_before_action :check_authorization, :verify_authenticity_token before_action :check_if_pay_system_is_enabled, only: [:result] def success diff --git a/app/controllers/billing/options_controller.rb b/app/controllers/billing/options_controller.rb index a3b610ad..47545e49 100644 --- a/app/controllers/billing/options_controller.rb +++ b/app/controllers/billing/options_controller.rb @@ -22,7 +22,7 @@ def destroy def update option = current_user.user_options.find_by(option_id: params[:id]) option.update(attrs: params[:option_attributes]) - render nothing: true + head :ok end def toggle diff --git a/app/controllers/billing/paypal_controller.rb b/app/controllers/billing/paypal_controller.rb index 51976e00..f0f303f1 100644 --- a/app/controllers/billing/paypal_controller.rb +++ b/app/controllers/billing/paypal_controller.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true class Billing::PaypalController < Billing::MerchantController - include ActiveMerchant::Billing::Integrations + include OffsitePayments::Integrations def result if notitication.acknowledge diff --git a/app/controllers/billing/robokassa_controller.rb b/app/controllers/billing/robokassa_controller.rb index 50a78399..69ef32d6 100644 --- a/app/controllers/billing/robokassa_controller.rb +++ b/app/controllers/billing/robokassa_controller.rb @@ -3,13 +3,13 @@ # This controller contains endpoints for Robokassa paysystem HTTP callbacks, # that notifies system about incoming payments. class Billing::RobokassaController < Billing::MerchantController - include ActiveMerchant::Billing::Integrations + include OffsitePayments::Integrations - before_filter :create_notification + before_action :create_notification def result if @notification.acknowledge - render text: 'Done' + render plain: 'Done' payment.accept! else raise 'Invalid robokassa notification' diff --git a/app/controllers/billing/webmoney_controller.rb b/app/controllers/billing/webmoney_controller.rb index 93749d2e..1c8a050e 100644 --- a/app/controllers/billing/webmoney_controller.rb +++ b/app/controllers/billing/webmoney_controller.rb @@ -3,15 +3,15 @@ # This controller contains endpoints for Webmoney paysystem HTTP callbacks, # that notifies system about incoming payments. class Billing::WebmoneyController < Billing::MerchantController - include ActiveMerchant::Billing::Integrations + include OffsitePayments::Integrations - before_filter :create_notification + before_action :create_notification def result if @notification.key_present? if @notification.recognizes? if @notification.acknowledge - render text: 'Done' + render plain: 'Done' payment.accept! else raise 'Invalid webmoney verification key' @@ -20,7 +20,7 @@ def result raise 'Undefined transaction_item_id' end else - render text: 'YES' + render plain: 'YES' end end diff --git a/app/models/server/signature.rb b/app/models/server/signature.rb index da01b241..0bd26028 100644 --- a/app/models/server/signature.rb +++ b/app/models/server/signature.rb @@ -15,7 +15,7 @@ class Signature def initialize(server, request_params) @server = server - @request_params = request_params.with_indifferent_access + @request_params = with_indifferent_access(request_params) end def valid? @@ -32,6 +32,14 @@ def signature request_params[:signature] end + def with_indifferent_access(request_params) + if request_params.instance_of? Hash + request_params.with_indifferent_access + else + request_params.to_unsafe_h.with_indifferent_access + end + end + def clean_params IGNORED_PARAMS.each_with_object(request_params.dup) do |param, attrs| attrs.delete(param) diff --git a/app/models/withdrawal.rb b/app/models/withdrawal.rb index 9efd5c29..e7e3e3a5 100644 --- a/app/models/withdrawal.rb +++ b/app/models/withdrawal.rb @@ -7,7 +7,7 @@ class Withdrawal < ActiveRecord::Base has_many :withdrawal_prolongations validates :amount, :user_id, :plan_id, presence: true - validate :balance_greater_than_amount, on: :create, if: 'user.present? && amount.present?' + validate :balance_greater_than_amount, on: :create, if: -> { 'user.present? && amount.present?' } after_create :decrease_user_balance diff --git a/app/services/newsletter_manager.rb b/app/services/newsletter_manager.rb index 0d40967f..7674fe18 100644 --- a/app/services/newsletter_manager.rb +++ b/app/services/newsletter_manager.rb @@ -4,7 +4,7 @@ class NewsletterManager attr_reader :api def initialize - @api = ::Gibbon::API.new(Settings.mailchimp.api_key) + @api = Gibbon::Request.new(api_key: Settings.mailchimp.api_key) end def add_to_list(email, list_name) diff --git a/app/views/billing/payments/forms/_cc.html.slim b/app/views/billing/payments/forms/_cc.html.slim index e71ca4d7..fe6b48e0 100644 --- a/app/views/billing/payments/forms/_cc.html.slim +++ b/app/views/billing/payments/forms/_cc.html.slim @@ -1,5 +1,5 @@ -- require 'active_merchant/billing/integrations/action_view_helper' -- ActionView::Base.send(:include, ActiveMerchant::Billing::Integrations::ActionViewHelper) +- require 'offsite_payments/action_view_helper' +- ActionView::Base.send(:include, OffsitePayments::ActionViewHelper) = payment_service_for @payment.id, Settings.robokassa.login, :amount => @payment.amount, diff --git a/app/views/billing/payments/forms/_wmr.html.slim b/app/views/billing/payments/forms/_wmr.html.slim index e6fc7caa..811ab459 100644 --- a/app/views/billing/payments/forms/_wmr.html.slim +++ b/app/views/billing/payments/forms/_wmr.html.slim @@ -1,5 +1,5 @@ -- require 'active_merchant/billing/integrations/action_view_helper' -- ActionView::Base.send(:include, ActiveMerchant::Billing::Integrations::ActionViewHelper) +- require 'offsite_payments/action_view_helper' +- ActionView::Base.send(:include, OffsitePayments::ActionViewHelper) = payment_service_for @payment.id, Settings.webmoney.wallet.wmr, :amount => @payment.amount, diff --git a/app/views/billing/payments/forms/_wmz.html.slim b/app/views/billing/payments/forms/_wmz.html.slim index d9070819..16178f05 100644 --- a/app/views/billing/payments/forms/_wmz.html.slim +++ b/app/views/billing/payments/forms/_wmz.html.slim @@ -1,5 +1,5 @@ -- require 'active_merchant/billing/integrations/action_view_helper' -- ActionView::Base.send(:include, ActiveMerchant::Billing::Integrations::ActionViewHelper) +- require 'offsite_payments/action_view_helper' +- ActionView::Base.send(:include, OffsitePayments::ActionViewHelper) = payment_service_for @payment.id, Settings.webmoney.wallet.wmz, :amount => @payment.amount, diff --git a/app/views/billing/payments/forms/_yandex.html.slim b/app/views/billing/payments/forms/_yandex.html.slim index e71ca4d7..fe6b48e0 100644 --- a/app/views/billing/payments/forms/_yandex.html.slim +++ b/app/views/billing/payments/forms/_yandex.html.slim @@ -1,5 +1,5 @@ -- require 'active_merchant/billing/integrations/action_view_helper' -- ActionView::Base.send(:include, ActiveMerchant::Billing::Integrations::ActionViewHelper) +- require 'offsite_payments/action_view_helper' +- ActionView::Base.send(:include, OffsitePayments::ActionViewHelper) = payment_service_for @payment.id, Settings.robokassa.login, :amount => @payment.amount, diff --git a/config/application.rb b/config/application.rb index 3b37867b..e020c943 100644 --- a/config/application.rb +++ b/config/application.rb @@ -31,6 +31,6 @@ class Application < Rails::Application I18n.enforce_available_locales = true config.assets.precompile += %w[admin.js admin.scss] - config.active_record.raise_in_transactional_callbacks = true + # config.active_record.raise_in_transactional_callbacks = true end end diff --git a/config/initializers/active_merchant.rb b/config/initializers/active_merchant.rb index 13100852..0477e47a 100644 --- a/config/initializers/active_merchant.rb +++ b/config/initializers/active_merchant.rb @@ -1,8 +1,9 @@ # frozen_string_literal: true require 'active_merchant' -require 'active_merchant/billing/integrations/action_view_helper' +require 'offsite_payments/action_view_helper' -ActionView::Base.send(:include, ActiveMerchant::Billing::Integrations::ActionViewHelper) +# https://github.com/activemerchant/active_merchant/issues/1397 +ActionView::Base.send(:include, OffsitePayments::ActionViewHelper) -ActiveMerchant::Billing::Base.integration_mode = :production +ActiveMerchant::Billing::Base.mode = :production diff --git a/config/initializers/rails_config.rb b/config/initializers/rails_config.rb index c109cd71..41dee6a1 100644 --- a/config/initializers/rails_config.rb +++ b/config/initializers/rails_config.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true -RailsConfig.setup do |config| +Config.setup do |config| config.const_name = 'Settings' end diff --git a/spec/controllers/admin/change_languages_controller_spec.rb b/spec/controllers/admin/change_languages_controller_spec.rb index 2d526829..4bc92517 100644 --- a/spec/controllers/admin/change_languages_controller_spec.rb +++ b/spec/controllers/admin/change_languages_controller_spec.rb @@ -8,7 +8,7 @@ describe 'PUT #update' do before do request.env['HTTP_REFERER'] = 'where_i_came_from' - put :update, locale: :ru + put :update, params: { locale: :ru } end it 'session locale will be set to RU' do diff --git a/spec/controllers/admin/connections_controller_spec.rb b/spec/controllers/admin/connections_controller_spec.rb index b757bd61..3ec8ecf1 100644 --- a/spec/controllers/admin/connections_controller_spec.rb +++ b/spec/controllers/admin/connections_controller_spec.rb @@ -33,7 +33,7 @@ describe 'GET #show' do let(:connection) { create(:connect) } - before { get :show, id: connection.id } + before { get :show, params: { id: connection.id } } it { is_expected.to be_success } it { is_expected.to render_template :show } diff --git a/spec/controllers/admin/options_controller_spec.rb b/spec/controllers/admin/options_controller_spec.rb index 4a3b3bd0..b26d42a8 100644 --- a/spec/controllers/admin/options_controller_spec.rb +++ b/spec/controllers/admin/options_controller_spec.rb @@ -26,12 +26,12 @@ it 'creates new option' do expect do - post :create, option: attrs + post :create, params: { option: attrs } end.to change(Option.all, :count).by(1) end it 'redirects to options path' do - post :create, option: attrs + post :create, params: { option: attrs } expect(response).to redirect_to admin_options_path end end @@ -40,7 +40,7 @@ let(:attrs) { Hash[name: nil, code: nil] } it 'renders new form' do - post :create, option: attrs + post :create, params: { option: attrs } expect(response).to render_template :new end end @@ -48,7 +48,7 @@ describe 'GET #edit' do let(:option) { create(:option) } - before { get :edit, id: option.id } + before { get :edit, params: { id: option.id } } it { is_expected.to be_success } it { is_expected.to render_template :edit } @@ -61,12 +61,12 @@ let(:attrs) { Hash[name: 'new_name', code: 'new_code'] } it 'updates option' do - put :update, id: option.id, option: attrs + put :update, params: { id: option.id, option: attrs } expect(option.reload.name).to eq attrs[:name] end it 'redirects to options path' do - put :update, id: option.id, option: attrs + put :update, params: { id: option.id, option: attrs } expect(subject).to redirect_to admin_options_path end end @@ -75,7 +75,7 @@ let(:attrs) { Hash[code: nil] } it 'renders edit form' do - put :update, id: option.id, option: attrs + put :update, params: { id: option.id, option: attrs } expect(subject).to render_template :edit end end diff --git a/spec/controllers/admin/pay_systems_controller_spec.rb b/spec/controllers/admin/pay_systems_controller_spec.rb index b784ed0e..3c691441 100644 --- a/spec/controllers/admin/pay_systems_controller_spec.rb +++ b/spec/controllers/admin/pay_systems_controller_spec.rb @@ -36,7 +36,7 @@ describe 'GET #show' do let!(:pay_system) { create :pay_system } - before { get :show, id: pay_system.id } + before { get :show, params: { id: pay_system.id } } it 'renders template' do expect(response).to render_template :show @@ -65,12 +65,12 @@ it 'creates new pay_system' do expect do - post :create, pay_system: attrs + post :create, params: { pay_system: attrs } end.to change(PaySystem, :count).by(1) end it 'redirects to pay_systems list' do - post :create, pay_system: attrs + post :create, params: { pay_system: attrs } expect(response).to redirect_to admin_pay_systems_path end end @@ -79,7 +79,7 @@ let(:attrs) { Hash[name: nil, code: nil] } it 'renders pay_system form' do - post :create, pay_system: attrs + post :create, params: { pay_system: attrs } expect(response).to render_template :new end end @@ -89,7 +89,7 @@ let!(:pay_system) { create(:pay_system) } it 'renders edit pay_system page' do - get :edit, id: pay_system.id + get :edit, params: { id: pay_system.id } expect(response).to render_template :edit end end @@ -102,12 +102,12 @@ it 'updates pay_system' do new_pay_system = create(:pay_system) - put :update, id: new_pay_system.id, pay_system: attrs + put :update, params: { id: new_pay_system.id, pay_system: attrs } expect(new_pay_system.reload.name).to eq attrs[:name] end it 'redirects to pay_systems list' do - put :update, id: pay_system.id, pay_system: attrs + put :update, params: { id: pay_system.id, pay_system: attrs } expect(response).to redirect_to admin_pay_systems_path end end @@ -116,7 +116,7 @@ let(:attrs) { Hash[name: nil] } it 'renders edit form' do - put :update, id: pay_system.id, pay_system: attrs + put :update, params: { id: pay_system.id, pay_system: attrs } expect(response).to render_template :edit end end diff --git a/spec/controllers/admin/plans_controller_spec.rb b/spec/controllers/admin/plans_controller_spec.rb index 56073074..2a629425 100644 --- a/spec/controllers/admin/plans_controller_spec.rb +++ b/spec/controllers/admin/plans_controller_spec.rb @@ -52,12 +52,12 @@ it 'creates new plan' do expect do - post :create, plan: attrs + post :create, params: { plan: attrs } end.to change(Plan, :count).by(1) end it 'redirects to plans list' do - post :create, plan: attrs + post :create, params: { plan: attrs } expect(response).to redirect_to admin_plans_path end end @@ -66,7 +66,7 @@ let(:attrs) { Hash[name: nil, price: nil] } it 'renders plan form' do - post :create, plan: attrs + post :create, params: { plan: attrs } expect(response).to render_template :new end end @@ -76,7 +76,7 @@ let!(:plan) { create(:plan) } it 'renders edit plan page' do - get :edit, id: plan.id + get :edit, params: { id: plan.id } expect(response).to render_template :edit end end @@ -89,12 +89,12 @@ it 'updates plan' do new_plan = create(:plan) - put :update, id: new_plan.id, plan: attrs + put :update, params: { id: new_plan.id, plan: attrs } expect(new_plan.reload.name).to eq attrs[:name] end it 'redirects to plans list' do - put :update, id: plan.id, plan: attrs + put :update, params: { id: plan.id, plan: attrs } expect(response).to redirect_to admin_plans_path end end @@ -103,7 +103,7 @@ let(:attrs) { Hash[name: nil] } it 'renders edit form' do - put :update, id: plan.id, plan: attrs + put :update, params: { id: plan.id, plan: attrs } expect(response).to render_template :edit end end @@ -114,7 +114,7 @@ it 'removes plan' do expect do - delete :destroy, id: plan.id + delete :destroy, params: { id: plan.id } end.to change(Plan, :count).by(-1) end end diff --git a/spec/controllers/admin/profiles_controller_spec.rb b/spec/controllers/admin/profiles_controller_spec.rb index 7fa87ada..15c6f4dc 100644 --- a/spec/controllers/admin/profiles_controller_spec.rb +++ b/spec/controllers/admin/profiles_controller_spec.rb @@ -40,7 +40,7 @@ describe 'PUT #update' do let!(:old_password) { admin.encrypted_password } - before { put :update, admin: params } + before { put :update, params: { admin: params } } context 'valid params' do let(:params) do diff --git a/spec/controllers/admin/promos_controller_spec.rb b/spec/controllers/admin/promos_controller_spec.rb index 860c580d..a7480366 100644 --- a/spec/controllers/admin/promos_controller_spec.rb +++ b/spec/controllers/admin/promos_controller_spec.rb @@ -36,13 +36,13 @@ let(:attrs) { Hash[name: 'new name', type: 'withdrawal', promoter_type: 'discount'] } it 'redirects to promos path' do - post :create, promo: attrs + post :create, params: { promo: attrs } expect(subject).to redirect_to edit_admin_promo_path(Promo.last) end it 'creates new promo' do expect do - post :create, promo: attrs + post :create, params: { promo: attrs } end.to change(Promo, :count).by(1) end end @@ -51,13 +51,13 @@ let(:attrs) { Hash[name: nil] } it 'renders new template' do - post :create, promo: attrs + post :create, params: { promo: attrs } expect(subject).to render_template :new end it 'does not create promo' do expect do - post :create, promo: attrs + post :create, params: { promo: attrs } end.not_to change(Promo, :count) end end @@ -65,7 +65,7 @@ describe 'GET #edit' do let(:promo) { create(:promo) } - before { get :edit, id: promo.id } + before { get :edit, params: { id: promo.id } } it { is_expected.to render_template :edit } it { expect(subject.status).to eq 200 } @@ -78,12 +78,12 @@ let(:attrs) { Hash[name: 'new name', type: 'withdrawal', promoter_type: 'discount'] } it 'redirects to edit page' do - put :update, promo: attrs, id: promo.id + put :update, params: { promo: attrs, id: promo.id } expect(subject).to redirect_to edit_admin_promo_path(promo) end it 'updates promo' do - put :update, promo: attrs, id: promo.id + put :update, params: { promo: attrs, id: promo.id } expect(promo.reload.name).to eq attrs[:name] end end @@ -92,12 +92,12 @@ let(:attrs) { Hash[name: 'new name', type: nil, promoter_type: 'discount'] } it 'renders edit form' do - put :update, promo: attrs, id: promo.id + put :update, params: { promo: attrs, id: promo.id } expect(subject).to render_template :edit end it 'does not update promo' do - put :update, promo: attrs, id: promo.id + put :update, params: { promo: attrs, id: promo.id } expect(promo.reload.name).not_to eq attrs[:name] end end diff --git a/spec/controllers/admin/servers_controller_spec.rb b/spec/controllers/admin/servers_controller_spec.rb index d9170ca0..88189d2b 100644 --- a/spec/controllers/admin/servers_controller_spec.rb +++ b/spec/controllers/admin/servers_controller_spec.rb @@ -36,7 +36,7 @@ describe 'GET #show' do let!(:server) { create :server } - before { get :show, id: server.id } + before { get :show, params: { id: server.id } } it 'renders template' do expect(response).to render_template :show @@ -65,12 +65,12 @@ it 'creates new server' do expect do - post :create, server: attrs + post :create, params: { server: attrs } end.to change(Server, :count).by(1) end it 'redirects to servers list' do - post :create, server: attrs + post :create, params: { server: attrs } expect(response).to redirect_to admin_servers_path end end @@ -79,7 +79,7 @@ let(:attrs) { Hash[hostname: nil, ip_address: nil] } it 'renders server form' do - post :create, server: attrs + post :create, params: { server: attrs } expect(response).to render_template :new end end @@ -89,7 +89,7 @@ let!(:server) { create(:server) } it 'renders edit server page' do - get :edit, id: server.id + get :edit, params: { id: server.id } expect(response).to render_template :edit end end @@ -102,12 +102,12 @@ it 'updates server' do new_server = create(:server) - put :update, id: new_server.id, server: attrs + put :update, params: { id: new_server.id, server: attrs } expect(new_server.reload.hostname).to eq attrs[:hostname] end it 'redirects to servers list' do - put :update, id: server.id, server: attrs + put :update, params: { id: server.id, server: attrs } expect(response).to redirect_to admin_servers_path end end @@ -116,7 +116,7 @@ let(:attrs) { Hash[hostname: nil] } it 'renders edit form' do - put :update, id: server.id, server: attrs + put :update, params: { id: server.id, server: attrs } expect(response).to render_template :edit end end @@ -127,7 +127,7 @@ it 'removes server' do expect do - delete :destroy, id: server.id + delete :destroy, params: { id: server.id } end.to change(Server, :count).by(-1) end end @@ -138,11 +138,11 @@ it 'calls config builder' do allow_any_instance_of(ServerConfigBuilder).to receive(:to_text).and_return(config) - get :generate_config, id: server.id + get :generate_config, params: { id: server.id } end it 'sends config to download' do - get :generate_config, id: server.id + get :generate_config, params: { id: server.id } expect(response.header['Content-Type']).to eq 'application/octet-stream' end end diff --git a/spec/controllers/admin/users_controller_spec.rb b/spec/controllers/admin/users_controller_spec.rb index c6a267fa..ef9daaea 100644 --- a/spec/controllers/admin/users_controller_spec.rb +++ b/spec/controllers/admin/users_controller_spec.rb @@ -30,7 +30,7 @@ describe 'GET #show' do let(:user) { create(:user) } - before { get :show, id: user.id } + before { get :show, params: { id: user.id } } it { is_expected.to be_success } it { is_expected.to render_template :show } @@ -38,7 +38,7 @@ describe 'GET #edit' do let(:user) { create(:user) } - before { get :edit, id: user.id } + before { get :edit, params: { id: user.id } } it { is_expected.to be_success } it { is_expected.to render_template :edit } @@ -69,12 +69,12 @@ it 'run operation' do expect(operation).to receive(:call).and_return(success: true, user: user) - post :create, user: params + post :create, params: { user: params } end it 'redirects to users path' do allow(operation).to receive(:call).and_return(success: true, user: user) - post :create, user: params + post :create, params: { user: params } expect(subject).to redirect_to admin_users_path end end @@ -91,12 +91,12 @@ it 'run operation' do expect(operation).to receive(:call).and_return(success: false, user: user) - post :create, user: params + post :create, params: { user: params } end it 'redirects to users path' do allow(operation).to receive(:call).and_return(success: false, user: user) - post :create, user: params + post :create, params: { user: params } expect(subject).to render_template :new end end @@ -105,7 +105,7 @@ describe 'PUT #update' do let(:user) { create(:user) } - before { put :update, id: user.id, user: attrs } + before { put :update, params: { id: user.id, user: attrs } } context 'params correct' do let(:attrs) { Hash[email: 'new@mail.ru'] } @@ -129,7 +129,7 @@ it 'creates new withdrawal' do expect do - put :withdraw, id: user.id + put :withdraw, params: { id: user.id } end.to change(Withdrawal, :count).by(1) end end @@ -141,18 +141,18 @@ it 'creates new withdrawal prolongation' do expect do - put :prolongate, id: user.id, withdrawal_prolongation: attrs + put :prolongate, params: { id: user.id, withdrawal_prolongation: attrs } end.to change(WithdrawalProlongation, :count).by(1) end it 'prolongation is created for last withdrawal' do expect do - put :prolongate, id: user.id, withdrawal_prolongation: attrs + put :prolongate, params: { id: user.id, withdrawal_prolongation: attrs } end.to change(user.withdrawals.last.withdrawal_prolongations, :count).by(1) end it 'prolongation days number equals form data' do - put :prolongate, id: user.id, withdrawal_prolongation: attrs + put :prolongate, params: { id: user.id, withdrawal_prolongation: attrs } expect(user.withdrawals.last.withdrawal_prolongations.last.days_number).to eq attrs[:days_number] end end @@ -164,12 +164,12 @@ it 'creates new payment' do expect do - put :payment, id: user.id, payment: attrs + put :payment, params: { id: user.id, payment: attrs } end.to change(Payment, :count).by(1) end context 'after request' do - before { put :payment, id: user.id, payment: attrs } + before { put :payment, params: { id: user.id, payment: attrs } } it 'payment is accepted' do expect(Payment.last.accepted?).to be true @@ -203,19 +203,19 @@ let(:user) { create(:user) } it 'calles enable action' do - put :enable_test_period, id: user.id + put :enable_test_period, params: { id: user.id } expect(user.reload.test_period.enabled?).to be true end it 'send email' do allow_any_instance_of(User).to receive(:test_period_started_at).and_return(Date.current) expect do - put :enable_test_period, id: user.id + put :enable_test_period, params: { id: user.id } end.to change(ActionMailer::Base.deliveries, :size).by(1) end it 'redirects to user path' do - put :enable_test_period, id: user.id + put :enable_test_period, params: { id: user.id } expect(response).to redirect_to admin_user_path(user) end end @@ -225,11 +225,11 @@ it 'calles disable action' do allow_any_instance_of(TestPeriod).to receive(:disable!) - put :disable_test_period, id: user.id + put :disable_test_period, params: { id: user.id } end it 'redirects to user path' do - put :disable_test_period, id: user.id + put :disable_test_period, params: { id: user.id } expect(response).to redirect_to admin_user_path(user) end end @@ -239,11 +239,11 @@ it 'calls disconnector' do allow_any_instance_of(ForcedDisconnect).to receive(:invoke) - put :force_disconnect, id: user.id + put :force_disconnect, params: { id: user.id } end it 'redirects to user path' do - put :force_disconnect, id: user.id + put :force_disconnect, params: { id: user.id } expect(response).to redirect_to admin_user_path(user) end end diff --git a/spec/controllers/api/authentication_controller_spec.rb b/spec/controllers/api/authentication_controller_spec.rb index 6bc4d1cf..67f6fccb 100644 --- a/spec/controllers/api/authentication_controller_spec.rb +++ b/spec/controllers/api/authentication_controller_spec.rb @@ -19,7 +19,7 @@ before { create(:withdrawal, user: user) } it 'returns 200 status' do - post :auth, params + post :auth, params: params expect(response.status).to eq 200 end end @@ -28,7 +28,7 @@ let(:params) { Hash[login: user.vpn_login, password: 'asd', hostname: server.hostname] } it 'returns 404 status' do - post :auth, params + post :auth, params: params expect(response.status).to eq 404 end end diff --git a/spec/controllers/api/connection_controller_spec.rb b/spec/controllers/api/connection_controller_spec.rb index caced7cd..140f14ae 100644 --- a/spec/controllers/api/connection_controller_spec.rb +++ b/spec/controllers/api/connection_controller_spec.rb @@ -19,13 +19,13 @@ describe 'POST #connect' do it 'calls connector' do allow_any_instance_of(Connector).to receive(:invoke).once - post :connect, attrs + post :connect, params: attrs end it 'passed connect action to connector' do connector = Connector.new(attrs.merge!(action: 'connect')) expect(Connector).to receive(:new).with(attrs).and_return(connector) - post :connect, attrs + post :connect, params: attrs end context 'user has options' do @@ -35,7 +35,7 @@ option = create(:active_option) user.plan.options << option user.options << option - post :connect, params + post :connect, params: params end it { is_expected.to be_json } @@ -49,13 +49,13 @@ describe 'POST #disconnect' do it 'calls connector' do allow_any_instance_of(Connector).to receive(:invoke).once - post :disconnect, attrs + post :disconnect, params: attrs end it 'passed disconnect action to connector' do connector = Connector.new(attrs.merge!(action: 'disconnect')) expect(Connector).to receive(:new).with(attrs).and_return(connector) - post :disconnect, attrs + post :disconnect, params: attrs end end end diff --git a/spec/controllers/api/servers_controller_spec.rb b/spec/controllers/api/servers_controller_spec.rb index dbc9c1ae..4a112b3e 100644 --- a/spec/controllers/api/servers_controller_spec.rb +++ b/spec/controllers/api/servers_controller_spec.rb @@ -23,7 +23,7 @@ it 'raises error' do expect do - post :activate, params + post :activate, params: params end.to raise_error ApiException, "Server already exists: #{server}" end end @@ -33,22 +33,22 @@ let(:server) { Server.last } it 'renders json with auth key' do - post :activate, params + post :activate, params: params expect(response.body).to eq Hash[auth_key: server.auth_key].to_json end it 'returns success status' do - post :activate, params + post :activate, params: params expect(response.status).to eq 200 end it 'updates server pki fields' do - expect { post :activate, params } + expect { post :activate, params: params } .to change { Server.count }.by(1) end it 'assigns certificate data to server' do - post :activate, params + post :activate, params: params expect(server.server_crt).to eq('server crt') expect(server.client_crt).to eq('client crt') expect(server.client_key).to eq('client key') @@ -61,7 +61,7 @@ it 'raises error' do expect do - post :activate, params + post :activate, params: params end.to raise_error ApiException, "Server activation attempt with incorrect token: #{signature}" end end diff --git a/spec/controllers/billing/options_controller_spec.rb b/spec/controllers/billing/options_controller_spec.rb index 5e455a41..8f3b4edd 100644 --- a/spec/controllers/billing/options_controller_spec.rb +++ b/spec/controllers/billing/options_controller_spec.rb @@ -18,7 +18,7 @@ before do allow(Option::Activator).to receive(:run).with(@user, option_code).and_return(activation_result) - post :create, code: option_code + post :create, params: { code: option_code } end context 'success' do @@ -52,7 +52,7 @@ let(:new_attrs) { Hash[country: 'Russia'] } let!(:user_option) { create(:user_option, state: 'enabled', attrs: old_attrs, user: @user, option: option) } - before { put :update, id: option.id, option_attributes: new_attrs } + before { put :update, params: { id: option.id, option_attributes: new_attrs } } it 'changes attributes' do expect(user_option.reload.attrs['country']).to eq 'Russia' @@ -65,7 +65,7 @@ it 'calles toggle! on option' do allow_any_instance_of(UserOption).to receive(:toggle!) - put :toggle, id: option.id + put :toggle, params: { id: option.id } end end end diff --git a/spec/controllers/billing/payments_controller_spec.rb b/spec/controllers/billing/payments_controller_spec.rb index 76efd411..d25301a0 100644 --- a/spec/controllers/billing/payments_controller_spec.rb +++ b/spec/controllers/billing/payments_controller_spec.rb @@ -20,12 +20,12 @@ end it 'displays new payment form' do - get :new, code: pay_system.code + get :new, params: { code: pay_system.code } expect(response).to render_template :new end it 'redirects to merchant form page on payment create' do - post :create, payment: attributes_for(:payment).merge!(pay_system_id: pay_system.id) + post :create, params: { payment: attributes_for(:payment).merge!(pay_system_id: pay_system.id) } expect(response).to redirect_to merchant_billing_payment_path(Payment.last) end @@ -36,7 +36,7 @@ end it 'redirects to pay systems list' do - get :merchant, id: @payment.id + get :merchant, params: { id: @payment.id } expect(response).to redirect_to billing_payments_path end end diff --git a/spec/controllers/billing/promotions_controller_spec.rb b/spec/controllers/billing/promotions_controller_spec.rb index ce452b27..6e0a7b3d 100644 --- a/spec/controllers/billing/promotions_controller_spec.rb +++ b/spec/controllers/billing/promotions_controller_spec.rb @@ -10,7 +10,7 @@ describe 'POST #create' do context 'when not authorized' do it 'does not respond' do - post :create, promo: { code: promo_code } + post :create, params: { promo: { code: promo_code } } expect(subject).to redirect_to new_user_session_path end end @@ -20,7 +20,7 @@ context 'promo with such code does not exist' do before do - post :create, promotion: { promo_code: promo_code } + post :create, params: { promotion: { promo_code: promo_code } } end it 'redirects to settings page' do @@ -37,7 +37,7 @@ let!(:promotion) { create(:promotion, user: User.last, promo: promo) } before do - post :create, promotion: { promo_code: promo_code } + post :create, params: { promotion: { promo_code: promo_code } } end it 'redirects to settings page' do @@ -51,7 +51,7 @@ context 'promo exists, promotion not' do let!(:promo) { create(:active_promo, date_from: 1.week.ago, date_to: 1.week.from_now, promo_code: promo_code) } - before { post :create, promotion: { promo_code: promo_code } } + before { post :create, params: { promotion: { promo_code: promo_code } } } it 'redirects to settings page' do expect(subject).to redirect_to settings_path diff --git a/spec/controllers/billing/robokassa_controller_spec.rb b/spec/controllers/billing/robokassa_controller_spec.rb index f96c864a..9505cdc0 100644 --- a/spec/controllers/billing/robokassa_controller_spec.rb +++ b/spec/controllers/billing/robokassa_controller_spec.rb @@ -15,7 +15,7 @@ it 'raises error' do expect do - post :result, attrs + post :result, params: attrs end.to raise_error 'Invalid robokassa notification' end end @@ -25,11 +25,11 @@ let(:attrs) { Hash['OutSum' => '9.99', 'InvId' => '10', 'SignatureValue' => 'D25F8F107E3482EF3CCAFC620CC8BA3E'] } before do - allow_any_instance_of(ActiveMerchant::Billing::Integrations::Robokassa::Notification) + allow_any_instance_of(OffsitePayments::Integrations::Robokassa::Notification) .to receive(:acknowledge) .and_return(true) allow(Payment).to receive(:find).and_return(payment) - post :result, attrs + post :result, params: attrs end it 'returns 200 state' do diff --git a/spec/controllers/billing/servers_controller_spec.rb b/spec/controllers/billing/servers_controller_spec.rb index 0dea13ca..bc607f61 100644 --- a/spec/controllers/billing/servers_controller_spec.rb +++ b/spec/controllers/billing/servers_controller_spec.rb @@ -22,11 +22,11 @@ it 'calls config builder' do allow_any_instance_of(ServerConfigBuilder).to receive(:to_text).and_return(config) - get :download_config, id: server.id + get :download_config, params: { id: server.id } end it 'sends config to download' do - get :download_config, id: server.id + get :download_config, params: { id: server.id } expect(response.header['Content-Type']).to eq 'application/octet-stream' end end diff --git a/spec/controllers/billing/webmoney_controller_spec.rb b/spec/controllers/billing/webmoney_controller_spec.rb index 04e7df24..629a6785 100644 --- a/spec/controllers/billing/webmoney_controller_spec.rb +++ b/spec/controllers/billing/webmoney_controller_spec.rb @@ -14,7 +14,7 @@ context 'key param is not present' do let(:attrs) { Hash[] } - before { post :result, attrs } + before { post :result, params: attrs } it 'renders YES text' do expect(subject.body).to include 'YES' @@ -28,7 +28,7 @@ it 'raises error' do expect do - post :result, attrs + post :result, params: attrs end.to raise_error 'Undefined transaction_item_id' end end @@ -39,7 +39,7 @@ it 'raises error' do expect do - post :result, attrs + post :result, params: attrs end.to raise_error 'Invalid webmoney verification key' end end @@ -64,14 +64,14 @@ end before do - allow_any_instance_of(ActiveMerchant::Billing::Integrations::Webmoney::Notification) + allow_any_instance_of(OffsitePayments::Integrations::Webmoney::Notification) .to receive(:recognizes?) .and_return(true) - allow_any_instance_of(ActiveMerchant::Billing::Integrations::Webmoney::Notification) + allow_any_instance_of(OffsitePayments::Integrations::Webmoney::Notification) .to receive(:acknowledge) .and_return(true) allow(Payment).to receive(:find).and_return(payment) - post :result, attrs + post :result, params: attrs end it 'returns 200 state' do diff --git a/spec/controllers/referrers_controller_spec.rb b/spec/controllers/referrers_controller_spec.rb index baf5c682..f7259096 100644 --- a/spec/controllers/referrers_controller_spec.rb +++ b/spec/controllers/referrers_controller_spec.rb @@ -5,7 +5,7 @@ describe ReferrersController do describe 'GET #set_referrer' do let(:user) { create(:user) } - before { get :set_referrer, code: user.reflink } + before { get :set_referrer, params: { code: user.reflink } } it 'sets reflink to cookie' do expect(response.cookies['reflink']).to eq user.reflink diff --git a/spec/controllers/users/registrations_controller_spec.rb b/spec/controllers/users/registrations_controller_spec.rb index bd98796a..34b65960 100644 --- a/spec/controllers/users/registrations_controller_spec.rb +++ b/spec/controllers/users/registrations_controller_spec.rb @@ -13,7 +13,7 @@ context 'reflink set in params' do before do request.cookies['reflink'] = referrer.reflink - post :create, user: attrs + post :create, params: { user: attrs } end it 'creates user' do @@ -31,7 +31,7 @@ context 'no reflink in params' do before do - post :create, user: attrs + post :create, params: { user: attrs } end it 'creates user' do diff --git a/spec/features/admin/users/manual_payment_spec.rb b/spec/features/admin/users/manual_payment_spec.rb index 932b7f4b..bfee6458 100644 --- a/spec/features/admin/users/manual_payment_spec.rb +++ b/spec/features/admin/users/manual_payment_spec.rb @@ -21,7 +21,7 @@ click_button I18n.t('global.apply') end - expect(page.find('p.user_balance')).to have_content (amount - user.plan.price) + expect(page.find('.user_balance')).to have_content (amount - user.plan.price) expect(page).to have_content I18n.t('admin.users.notices.payment_created') end end diff --git a/spec/mailers/user_connection_config_mailer_spec.rb b/spec/mailers/user_connection_config_mailer_spec.rb index 0c763a91..31dcd70f 100644 --- a/spec/mailers/user_connection_config_mailer_spec.rb +++ b/spec/mailers/user_connection_config_mailer_spec.rb @@ -7,9 +7,14 @@ subject { described_class.notify(user: user) } let!(:user) { create(:user) } let!(:server) { create(:server) } - let!(:plan) { create(:plan, users: [user], servers: [server]) } + let!(:plan) { create(:plan) } let(:server_config) { ServerConfigBuilder.new(server: server).to_text } + before do + plan.users << user + plan.servers << server + end + its(:subject) { is_expected.to eq I18n.t('mailers.user_connection_config_mailer.subject') } its(:to) { is_expected.to eq [user.email] } its(:from) { is_expected.to eq [ENV['EMAIL_FROM']] } diff --git a/spec/models/withdrawal_spec.rb b/spec/models/withdrawal_spec.rb index af985b93..1f008e2f 100644 --- a/spec/models/withdrawal_spec.rb +++ b/spec/models/withdrawal_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' describe Withdrawal do - subject { build(:withdrawal) } + subject { create(:withdrawal) } it { is_expected.to be_valid } it { is_expected.to validate_presence_of(:plan_id) } diff --git a/spec/services/newsletter_manager_spec.rb b/spec/services/newsletter_manager_spec.rb index edb3755b..803e6b70 100644 --- a/spec/services/newsletter_manager_spec.rb +++ b/spec/services/newsletter_manager_spec.rb @@ -12,7 +12,7 @@ let(:list_name) { :all } it 'calls Mailchimp api' do - ::FakeWeb.register_uri(:post, 'https://key.api.mailchimp.com/2.0/lists/subscribe', body: '{}') + FakeWeb.register_uri(:post, 'https://key.api.mailchimp.com/2.0/lists/subscribe', body: '{}') subject.add_to_list(email, list_name) end end diff --git a/spec/services/referrer/rewarder_spec.rb b/spec/services/referrer/rewarder_spec.rb index ed18d9d0..491b6168 100644 --- a/spec/services/referrer/rewarder_spec.rb +++ b/spec/services/referrer/rewarder_spec.rb @@ -40,7 +40,7 @@ context 'withdrawal invalid' do let(:user) { create(:user) } - let(:withdrawal) { Withdrawal.create(user: user) } + let(:withdrawal) { Withdrawal.create(user: user, amount: 0) } it 'does not create reward' do expect do diff --git a/spec/shared_examples/admin_controller_access_spec_shared.rb b/spec/shared_examples/admin_controller_access_spec_shared.rb index 4e71fbf8..bb1b5101 100644 --- a/spec/shared_examples/admin_controller_access_spec_shared.rb +++ b/spec/shared_examples/admin_controller_access_spec_shared.rb @@ -5,7 +5,7 @@ login_user it 'does not allow to be accessed by user' do - send(method, action, params) + send(method, action, params: params) expect(response).to redirect_to new_admin_session_path end end diff --git a/spec/shared_examples/api_call_controller_validation_shared.rb b/spec/shared_examples/api_call_controller_validation_shared.rb index 8d74371c..80fc9a83 100644 --- a/spec/shared_examples/api_call_controller_validation_shared.rb +++ b/spec/shared_examples/api_call_controller_validation_shared.rb @@ -12,7 +12,7 @@ it 'raises error' do expect do - post action, attrs + post action, params: attrs end.to raise_error ApiException, 'Server not found' end end @@ -22,7 +22,7 @@ context 'when pending' do it 'raises error' do expect do - post action, attrs + post action, params: attrs end.to raise_error ApiException, 'Server not active' end end @@ -32,7 +32,7 @@ it 'raises error' do expect do - post action, attrs + post action, params: attrs end.to raise_error ApiException, 'Server not active' end end @@ -51,7 +51,7 @@ it 'raises error' do expect do - post action, attrs + post action, params: attrs end.to raise_error ApiException, 'Invalid api call' end end diff --git a/spec/shared_examples/validates_paysystem_enabled_shared.rb b/spec/shared_examples/validates_paysystem_enabled_shared.rb index afc11873..7ca7ada3 100644 --- a/spec/shared_examples/validates_paysystem_enabled_shared.rb +++ b/spec/shared_examples/validates_paysystem_enabled_shared.rb @@ -8,7 +8,7 @@ it 'raises error' do expect do - post action, payment_id_key => payment.id + post action, params: { payment_id_key => payment.id } end.to raise_error BillingException end end diff --git a/spec/workers/create_user_mail_worker_spec.rb b/spec/workers/create_user_mail_worker_spec.rb index a410df0e..09c88215 100644 --- a/spec/workers/create_user_mail_worker_spec.rb +++ b/spec/workers/create_user_mail_worker_spec.rb @@ -8,9 +8,14 @@ context '#perform' do let(:user) { create(:user) } let(:server) { create(:server) } - let!(:plan) { create(:plan, users: [user], servers: [server]) } + let!(:plan) { create(:plan) } let(:mailer) { double } + before do + plan.users << user + plan.servers << server + end + it 'notifies user by email' do expect { subject.perform(user.id) }.to change(ActionMailer::Base.deliveries, :count).by(1) end