diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000..1ad899d Binary files /dev/null and b/.DS_Store differ diff --git a/Gemfile b/Gemfile index 2202551..7514cd5 100644 --- a/Gemfile +++ b/Gemfile @@ -15,19 +15,23 @@ gemspec ruby '2.5.8' -gem 'dotenv-rails', require: 'dotenv/rails-now' +gem 'dotenv-rails', '~> 2.7', require: 'dotenv/rails-now' # gem 'jquery-rails' gem 'puma' gem 'pg', '0.20' gem 'rails_12factor', group: :production -gem 'devise', '>= 4.6.0' +gem 'devise', '~> 4.7' group :test do - gem 'rspec-rails' - gem 'cucumber-rails', '~> 1.4.4', require: false + gem 'rspec-rails', '~> 4.0.1' + gem 'cucumber-rails', '~> 2.1', require: false gem 'factory_bot_rails' gem 'database_cleaner' gem 'stripe-ruby-mock', '~> 2.5.2', require: 'stripe_mock' gem 'poltergeist' - gem "codeclimate-test-reporter", require: nil + gem 'codeclimate-test-reporter', require: nil + + # assigns is deprecated - TODO: move to request specs + # see https://stackoverflow.com/questions/42001517/rspec-rails-controller-testing-with-assertions-and-assigns + gem 'rails-controller-testing' end \ No newline at end of file diff --git a/Gemfile.lock b/Gemfile.lock index 534785c..b8cd74b 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -8,7 +8,7 @@ PATH jquery-rails (~> 4.2) mini_racer (~> 0.3) paper_trail (~> 4.2) - rails (~> 4.2) + rails (~> 5.2) rails-assets-tether (>= 1.1) sass-rails (~> 5.0) stripe (~> 3.9) @@ -21,46 +21,52 @@ GEM specs: aasm (4.12.3) concurrent-ruby (~> 1.0) - actionmailer (4.2.11) - actionpack (= 4.2.11) - actionview (= 4.2.11) - activejob (= 4.2.11) + actioncable (5.2.4.3) + actionpack (= 5.2.4.3) + nio4r (~> 2.0) + websocket-driver (>= 0.6.1) + actionmailer (5.2.4.3) + actionpack (= 5.2.4.3) + actionview (= 5.2.4.3) + activejob (= 5.2.4.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.4.3) + actionview (= 5.2.4.3) + activesupport (= 5.2.4.3) + rack (~> 2.0, >= 2.0.8) + 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.4.3) + activesupport (= 5.2.4.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) - activejob (4.2.11) - activesupport (= 4.2.11) - globalid (>= 0.3.0) - activemodel (4.2.11) - activesupport (= 4.2.11) - 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) + activejob (5.2.4.3) + activesupport (= 5.2.4.3) + globalid (>= 0.3.6) + activemodel (5.2.4.3) + activesupport (= 5.2.4.3) + activerecord (5.2.4.3) + activemodel (= 5.2.4.3) + activesupport (= 5.2.4.3) + arel (>= 9.0) + activestorage (5.2.4.3) + actionpack (= 5.2.4.3) + activerecord (= 5.2.4.3) + marcel (~> 0.3.1) + activesupport (5.2.4.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.5.2) public_suffix (>= 2.0.2, < 4.0) - arel (6.0.4) + arel (9.0.0) autoprefixer-rails (9.8.6.3) execjs - backports (3.11.1) bcrypt (3.1.13) bootstrap (4.5.2) autoprefixer-rails (>= 9.1.0) @@ -87,32 +93,47 @@ GEM coffee-script-source execjs coffee-script-source (1.12.2) - concurrent-ruby (1.1.6) + concurrent-ruby (1.1.7) crass (1.0.6) - cucumber (3.1.0) - builder (>= 2.1.2) - cucumber-core (~> 3.1.0) - cucumber-expressions (~> 5.0.4) - cucumber-wire (~> 0.0.1) - diff-lcs (~> 1.3) - gherkin (~> 5.0) - multi_json (>= 1.7.5, < 2.0) - multi_test (>= 0.1.2) - cucumber-core (3.1.0) - backports (>= 3.8.0) - cucumber-tag_expressions (~> 1.1.0) - gherkin (>= 5.0.0) - cucumber-expressions (5.0.13) - cucumber-rails (1.4.5) - capybara (>= 1.1.2, < 3) - cucumber (>= 1.3.8, < 4) - mime-types (>= 1.16, < 4) - nokogiri (~> 1.5) - railties (>= 3, < 5.1) - cucumber-tag_expressions (1.1.1) - cucumber-wire (0.0.1) + cucumber (4.1.0) + builder (~> 3.2, >= 3.2.3) + cucumber-core (~> 7.1, >= 7.1.0) + cucumber-create-meta (~> 1.0.0, >= 1.0.0) + cucumber-cucumber-expressions (~> 10.1, >= 10.1.0) + cucumber-gherkin (~> 14.0, >= 14.0.1) + cucumber-html-formatter (~> 7.0, >= 7.0.0) + cucumber-messages (~> 12.2, >= 12.2.0) + cucumber-wire (~> 3.1, >= 3.1.0) + diff-lcs (~> 1.3, >= 1.3, < 1.4) + multi_test (~> 0.1, >= 0.1.2) + sys-uname (~> 1.0, >= 1.0.2) + cucumber-core (7.1.0) + cucumber-gherkin (~> 14.0, >= 14.0.1) + cucumber-messages (~> 12.2, >= 12.2.0) + cucumber-tag-expressions (~> 2.0, >= 2.0.4) + cucumber-create-meta (1.0.0) + cucumber-messages (~> 12.2, >= 12.2.0) + sys-uname (~> 1.2, >= 1.2.1) + cucumber-cucumber-expressions (10.3.0) + cucumber-gherkin (14.2.0) + cucumber-messages (~> 12.4, >= 12.4.0) + cucumber-html-formatter (7.2.0) + cucumber-messages (~> 12.4, >= 12.4.0) + cucumber-messages (12.4.0) + protobuf-cucumber (~> 3.10, >= 3.10.8) + cucumber-rails (2.1.0) + capybara (>= 2.12, < 4) + cucumber (>= 3.0.2, < 5) + mime-types (>= 2.0, < 4) + nokogiri (~> 1.8) + rails (>= 4.2, < 7) + cucumber-tag-expressions (2.0.4) + cucumber-wire (3.1.0) + cucumber-core (~> 7.1, >= 7.1.0) + cucumber-cucumber-expressions (~> 10.1, >= 10.1.0) + cucumber-messages (~> 12.2, >= 12.2.0) dante (0.2.0) - database_cleaner (1.6.2) + database_cleaner (1.8.5) devise (4.7.1) bcrypt (~> 3.0) orm_adapter (~> 0.1) @@ -121,10 +142,11 @@ GEM warden (~> 1.2.3) diff-lcs (1.3) docile (1.1.5) - dotenv (2.2.1) - dotenv-rails (2.2.1) - dotenv (= 2.2.1) - railties (>= 3.2, < 5.2) + dotenv (2.7.6) + dotenv-rails (2.7.6) + dotenv (= 2.7.6) + railties (>= 3.2) + erubi (1.9.0) erubis (2.7.0) execjs (2.7.0) factory_bot (4.8.2) @@ -135,35 +157,39 @@ GEM faraday (0.14.0) multipart-post (>= 1.2, < 3) ffi (1.13.1) - gherkin (5.0.0) globalid (0.4.2) activesupport (>= 4.2.0) - i18n (0.9.5) + i18n (1.8.5) concurrent-ruby (~> 1.0) jquery-rails (4.4.0) rails-dom-testing (>= 1, < 3) railties (>= 4.2.0) thor (>= 0.14, < 2.0) json (2.3.1) - libv8 (8.4.255.0-x86_64-darwin-19) - loofah (2.4.0) + libv8 (8.4.255.0) + loofah (2.7.0) crass (~> 1.0.2) nokogiri (>= 1.5.9) mail (2.7.1) mini_mime (>= 0.1.1) - mime-types (3.1) + marcel (0.3.3) + mimemagic (~> 0.3.2) + method_source (1.0.0) + middleware (0.1.0) + mime-types (3.3.1) mime-types-data (~> 3.2015) - mime-types-data (3.2016.0521) - mini_mime (1.0.1) + mime-types-data (3.2020.0512) + mimemagic (0.3.5) + mini_mime (1.0.2) mini_portile2 (2.4.0) mini_racer (0.3.1) libv8 (~> 8.4.255) - minitest (5.14.0) + minitest (5.14.2) multi_json (1.13.1) multi_test (0.1.2) multipart-post (2.0.0) nio4r (2.5.2) - nokogiri (1.10.9) + nokogiri (1.10.10) mini_portile2 (~> 2.4.0) orm_adapter (0.5.0) paper_trail (4.2.0) @@ -176,30 +202,38 @@ GEM cliver (~> 0.3.1) websocket-driver (>= 0.2.0) popper_js (1.16.0) + protobuf-cucumber (3.10.8) + activesupport (>= 3.2) + middleware + thor + thread_safe public_suffix (3.0.2) puma (4.3.5) nio4r (~> 2.0) - rack (1.6.13) - 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 + rack (2.2.3) + rack-test (1.1.0) + rack (>= 1.0, < 3) + rails (5.2.4.3) + actioncable (= 5.2.4.3) + actionmailer (= 5.2.4.3) + actionpack (= 5.2.4.3) + actionview (= 5.2.4.3) + activejob (= 5.2.4.3) + activemodel (= 5.2.4.3) + activerecord (= 5.2.4.3) + activestorage (= 5.2.4.3) + activesupport (= 5.2.4.3) + bundler (>= 1.3.0) + railties (= 5.2.4.3) + sprockets-rails (>= 2.0.0) rails-assets-tether (1.1.1) - 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) + rails-controller-testing (1.0.5) + actionpack (>= 5.0.1.rc1) + actionview (>= 5.0.1.rc1) + activesupport (>= 5.0.1.rc1) + rails-dom-testing (2.0.3) + activesupport (>= 4.2.0) + nokogiri (>= 1.6) rails-html-sanitizer (1.3.0) loofah (~> 2.3) rails_12factor (0.0.3) @@ -215,11 +249,12 @@ GEM ruby-progressbar rails_serve_static_assets (0.0.5) rails_stdout_logging (0.0.5) - railties (4.2.11) - actionpack (= 4.2.11) - activesupport (= 4.2.11) + railties (5.2.4.3) + actionpack (= 5.2.4.3) + activesupport (= 5.2.4.3) + method_source rake (>= 0.8.7) - thor (>= 0.18.1, < 2.0) + thor (>= 0.19.0, < 2.0) rake (13.0.1) rb-fsevent (0.10.4) rb-inotify (0.10.1) @@ -230,31 +265,31 @@ GEM responders (2.4.1) actionpack (>= 4.2.0, < 6.0) railties (>= 4.2.0, < 6.0) - rspec-core (3.7.1) - rspec-support (~> 3.7.0) - rspec-expectations (3.7.0) + rspec-core (3.9.2) + rspec-support (~> 3.9.3) + rspec-expectations (3.9.2) diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.7.0) - rspec-mocks (3.7.0) + rspec-support (~> 3.9.0) + rspec-mocks (3.9.1) diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.7.0) - rspec-rails (3.7.2) - actionpack (>= 3.0) - activesupport (>= 3.0) - railties (>= 3.0) - rspec-core (~> 3.7.0) - rspec-expectations (~> 3.7.0) - rspec-mocks (~> 3.7.0) - rspec-support (~> 3.7.0) - rspec-support (3.7.1) + rspec-support (~> 3.9.0) + rspec-rails (4.0.1) + actionpack (>= 4.2) + activesupport (>= 4.2) + railties (>= 4.2) + rspec-core (~> 3.9) + rspec-expectations (~> 3.9) + rspec-mocks (~> 3.9) + rspec-support (~> 3.9) + rspec-support (3.9.3) ruby-progressbar (1.9.0) sass (3.7.4) 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.7) - railties (>= 4.0.0, < 6) + sass-rails (5.1.0) + railties (>= 5.2.0) sass (~> 3.1) sprockets (>= 2.8, < 4.0) sprockets-rails (>= 2.0, < 4.0) @@ -289,10 +324,12 @@ GEM stripe_event (2.3.1) activesupport (>= 3.1) stripe (>= 2.8, < 6) + sys-uname (1.2.1) + ffi (>= 1.0.0) thor (1.0.1) thread_safe (0.3.6) tilt (2.0.10) - tzinfo (1.2.6) + tzinfo (1.2.7) thread_safe (~> 0.1) uglifier (2.7.2) execjs (>= 0.3.0) @@ -312,17 +349,18 @@ PLATFORMS DEPENDENCIES brakeman (~> 3.3) codeclimate-test-reporter - cucumber-rails (~> 1.4.4) + cucumber-rails (~> 2.1) database_cleaner - devise (>= 4.6.0) - dotenv-rails + devise (~> 4.7) + dotenv-rails (~> 2.7) factory_bot_rails pg (= 0.20) poltergeist puma + rails-controller-testing rails_12factor rails_best_practices (~> 1.17) - rspec-rails + rspec-rails (~> 4.0.1) stripe-ruby-mock (~> 2.5.2) tang! diff --git a/app/models/tang/coupon.rb b/app/models/tang/coupon.rb index ae5cb0a..c316a26 100644 --- a/app/models/tang/coupon.rb +++ b/app/models/tang/coupon.rb @@ -11,12 +11,12 @@ class Coupon < ActiveRecord::Base validates :stripe_id, uniqueness: true # , if: "deleted_at.nil?" validates :duration, inclusion: { in: %w(once repeating forever) } validates :amount_off, numericality: { only_integer: true, greater_than: 0 }, allow_nil: true - validates :currency, presence: true, if: "amount_off.present?" + validates :currency, presence: true, if: -> { amount_off.present? } validates :duration_in_months, presence: true, numericality: { only_integer: true, greater_than: 0 }, if: :repeating? validates :max_redemptions, numericality: { only_integer: true, greater_than: 0 }, allow_nil: true validates :percent_off, numericality: { only_integer: true, greater_than_or_equal_to: 1, less_than_or_equal_to: 100 }, - presence: true, if: "amount_off.nil?" - validates :redeem_by, future: true, if: "redeem_by.present?" + presence: true, if: -> { amount_off.nil? } + validates :redeem_by, future: true, if: -> { redeem_by.present? } before_create :create_stripe_coupon before_update :update_stripe_coupon diff --git a/app/models/tang/plan.rb b/app/models/tang/plan.rb index f183c68..32cf47d 100644 --- a/app/models/tang/plan.rb +++ b/app/models/tang/plan.rb @@ -11,10 +11,10 @@ class Plan < ActiveRecord::Base validates :amount, numericality: { only_integer: true, greater_than_or_equal_to: 0 } validates :currency, length: { is: 3 } validates :interval, inclusion: { in: %w(day week month year) } - validates :interval_count, numericality: { only_integer: true, greater_than: 0, less_than_or_equal_to: 1 }, allow_nil: true, if: "interval == 'year'" - validates :interval_count, numericality: { only_integer: true, greater_than: 0, less_than_or_equal_to: 12 }, allow_nil: true, if: "interval == 'month'" - validates :interval_count, numericality: { only_integer: true, greater_than: 0, less_than_or_equal_to: 52 }, allow_nil: true, if: "interval == 'week'" - validates :interval_count, numericality: { only_integer: true, greater_than: 0, less_than_or_equal_to: 365 }, allow_nil: true, if: "interval == 'day'" + validates :interval_count, numericality: { only_integer: true, greater_than: 0, less_than_or_equal_to: 1 }, allow_nil: true, if: -> { interval == 'year' } + validates :interval_count, numericality: { only_integer: true, greater_than: 0, less_than_or_equal_to: 12 }, allow_nil: true, if: -> { interval == 'month' } + validates :interval_count, numericality: { only_integer: true, greater_than: 0, less_than_or_equal_to: 52 }, allow_nil: true, if: -> { interval == 'week' } + validates :interval_count, numericality: { only_integer: true, greater_than: 0, less_than_or_equal_to: 365 }, allow_nil: true, if: -> { interval == 'day' } validates :trial_period_days, numericality: { only_integer: true, greater_than: 0 }, allow_nil: true validates :statement_descriptor, length: { maximum: 22 }, format: { without: /[<>"']/ }, allow_nil: true diff --git a/bin/rails b/bin/rails index a0a4415..64b5a04 100755 --- a/bin/rails +++ b/bin/rails @@ -1,11 +1,13 @@ #!/usr/bin/env ruby -# This command will automatically be run when you run "rails" with Rails 4 gems installed from the root of your application. +# This command will automatically be run when you run "rails" with Rails gems +# installed from the root of your application. -ENGINE_ROOT = File.expand_path('../..', __FILE__) -ENGINE_PATH = File.expand_path('../../lib/tang/engine', __FILE__) +ENGINE_ROOT = File.expand_path('..', __dir__) +ENGINE_PATH = File.expand_path('../lib/tang/engine', __dir__) +APP_PATH = File.expand_path('../test/dummy/config/application', __dir__) # Set up gems listed in the Gemfile. -ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__) +ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__) require 'bundler/setup' if File.exist?(ENV['BUNDLE_GEMFILE']) require 'rails/all' diff --git a/config/cucumber.yml b/config/cucumber.yml index 19b288d..74fb114 100644 --- a/config/cucumber.yml +++ b/config/cucumber.yml @@ -1,8 +1,8 @@ <% rerun = File.file?('rerun.txt') ? IO.read('rerun.txt') : "" rerun_opts = rerun.to_s.strip.empty? ? "--format #{ENV['CUCUMBER_FORMAT'] || 'progress'} features" : "--format #{ENV['CUCUMBER_FORMAT'] || 'pretty'} #{rerun}" -std_opts = "--format #{ENV['CUCUMBER_FORMAT'] || 'pretty'} --strict --tags ~@wip" +std_opts = "--format #{ENV['CUCUMBER_FORMAT'] || 'pretty'} --strict --tags not @wip" %> default: <%= std_opts %> features wip: --tags @wip:3 --wip features -rerun: <%= rerun_opts %> --format rerun --out rerun.txt --strict --tags ~@wip +rerun: <%= rerun_opts %> --format rerun --out rerun.txt --strict --tags not @wip diff --git a/features/support/env.rb b/features/support/env.rb index 6e01fd4..656aa8c 100644 --- a/features/support/env.rb +++ b/features/support/env.rb @@ -42,7 +42,7 @@ # Remove/comment out the lines below if your app doesn't have a database. # For some databases (like MongoDB and CouchDB) you may need to use :truncation instead. begin - DatabaseCleaner.strategy = :transaction + DatabaseCleaner.strategy = :transaction #, except: %w(ar_internal_metadata) rescue NameError raise "You need to add database_cleaner to your Gemfile (in the :test group) if you wish to use it." end diff --git a/lib/tang/version.rb b/lib/tang/version.rb index c032f44..53568fd 100644 --- a/lib/tang/version.rb +++ b/lib/tang/version.rb @@ -1,3 +1,3 @@ module Tang - VERSION = "0.0.7" + VERSION = "0.0.8" end diff --git a/spec/controllers/tang/admin/customers_controller_spec.rb b/spec/controllers/tang/admin/customers_controller_spec.rb index 8d86858..9f8a917 100644 --- a/spec/controllers/tang/admin/customers_controller_spec.rb +++ b/spec/controllers/tang/admin/customers_controller_spec.rb @@ -55,7 +55,7 @@ module Tang describe "GET #show" do it "assigns the requested customer as @customer" do customer = User.create! valid_attributes - get :show, {id: customer.to_param}, session: valid_session + get :show, params: {id: customer.to_param}, session: valid_session expect(assigns(:customer)).to eq(customer) end end @@ -63,7 +63,7 @@ module Tang describe "GET #edit" do it "assigns the requested customer as @customer" do customer = User.create! valid_attributes - get :edit, {id: customer.to_param}, session: valid_session + get :edit, params: {id: customer.to_param}, session: valid_session expect(assigns(:customer)).to eq(customer) end end @@ -77,7 +77,7 @@ module Tang it "updates the requested customer" do customer = User.create! valid_attributes - put :update, {id: customer.to_param, user: new_attributes}, session: valid_session + put :update, params: {id: customer.to_param, user: new_attributes}, session: valid_session customer.reload # skip("Add assertions for updated state") expect(customer.email).to eq('new@email.com') @@ -85,13 +85,13 @@ module Tang it "assigns the requested customer as @customer" do customer = User.create! valid_attributes - put :update, {id: customer.to_param, user: valid_attributes}, session: valid_session + put :update, params: {id: customer.to_param, user: valid_attributes}, session: valid_session expect(assigns(:customer)).to eq(customer) end it "redirects to the customer" do customer = User.create! valid_attributes - put :update, {id: customer.to_param, user: valid_attributes}, session: valid_session + put :update, params: {id: customer.to_param, user: valid_attributes}, session: valid_session expect(response).to redirect_to(admin_customer_url(customer)) end end @@ -99,13 +99,13 @@ module Tang context "with invalid params" do it "assigns the customer as @customer" do customer = User.create! valid_attributes - put :update, {id: customer.to_param, user: invalid_attributes}, session: valid_session + put :update, params: {id: customer.to_param, user: invalid_attributes}, session: valid_session expect(assigns(:customer)).to eq(customer) end it "re-renders the 'edit' template" do customer = User.create! valid_attributes - put :update, {id: customer.to_param, user: invalid_attributes}, session: valid_session + put :update, params: {id: customer.to_param, user: invalid_attributes}, session: valid_session expect(response).to render_template("edit") end end @@ -115,13 +115,13 @@ module Tang it "destroys the requested customer" do customer = User.create! valid_attributes expect { - delete :destroy, {id: customer.to_param}, session: valid_session + delete :destroy, params: {id: customer.to_param}, session: valid_session }.to change(User, :count).by(-1) end it "redirects to the customers list" do customer = User.create! valid_attributes - delete :destroy, {id: customer.to_param}, session: valid_session + delete :destroy, params: {id: customer.to_param}, session: valid_session expect(response).to redirect_to(admin_customers_url) end end diff --git a/spec/controllers/tang/admin/plans_controller_spec.rb b/spec/controllers/tang/admin/plans_controller_spec.rb index 02130e3..796e452 100644 --- a/spec/controllers/tang/admin/plans_controller_spec.rb +++ b/spec/controllers/tang/admin/plans_controller_spec.rb @@ -55,7 +55,7 @@ module Tang describe "GET #show" do it "assigns the requested plan as @plan" do plan = Plan.create! valid_attributes - get :show, {id: plan.to_param}, session: valid_session + get :show, params: {id: plan.to_param}, session: valid_session expect(assigns(:plan)).to eq(plan) end end @@ -70,7 +70,7 @@ module Tang describe "GET #edit" do it "assigns the requested plan as @plan" do plan = Plan.create! valid_attributes - get :edit, {id: plan.to_param}, session: valid_session + get :edit, params: {id: plan.to_param}, session: valid_session expect(assigns(:plan)).to eq(plan) end end @@ -79,30 +79,30 @@ module Tang context "with valid params" do it "creates a new Plan" do expect { - post :create, {plan: valid_attributes}, session: valid_session + post :create, params: {plan: valid_attributes}, session: valid_session }.to change(Plan, :count).by(1) end it "assigns a newly created plan as @plan" do - post :create, {plan: valid_attributes}, session: valid_session + post :create, params: {plan: valid_attributes}, session: valid_session expect(assigns(:plan)).to be_a(Plan) expect(assigns(:plan)).to be_persisted end it "redirects to the created plan" do - post :create, {plan: valid_attributes}, session: valid_session + post :create, params: {plan: valid_attributes}, session: valid_session expect(response).to redirect_to(admin_plan_url(Plan.last)) end end context "with invalid params" do it "assigns a newly created but unsaved plan as @plan" do - post :create, {plan: invalid_attributes}, session: valid_session + post :create, params: {plan: invalid_attributes}, session: valid_session expect(assigns(:plan)).to be_a_new(Plan) end it "re-renders the 'new' template" do - post :create, {plan: invalid_attributes}, session: valid_session + post :create, params: {plan: invalid_attributes}, session: valid_session expect(response).to render_template("new") end end @@ -117,7 +117,7 @@ module Tang it "updates the requested plan" do plan = Plan.create! valid_attributes - put :update, {id: plan.to_param, plan: new_attributes}, session: valid_session + put :update, params: {id: plan.to_param, plan: new_attributes}, session: valid_session plan.reload # skip("Add assertions for updated state") expect(plan.name).to eq('Changed Plan') @@ -125,13 +125,13 @@ module Tang it "assigns the requested plan as @plan" do plan = Plan.create! valid_attributes - put :update, {id: plan.to_param, plan: valid_attributes}, session: valid_session + put :update, params: {id: plan.to_param, plan: valid_attributes}, session: valid_session expect(assigns(:plan)).to eq(plan) end it "redirects to the plan" do plan = Plan.create! valid_attributes - put :update, {id: plan.to_param, plan: valid_attributes}, session: valid_session + put :update, params: {id: plan.to_param, plan: valid_attributes}, session: valid_session expect(response).to redirect_to(admin_plan_url(plan)) end end @@ -139,13 +139,13 @@ module Tang context "with invalid params" do it "assigns the plan as @plan" do plan = Plan.create! valid_attributes - put :update, {id: plan.to_param, plan: invalid_attributes}, session: valid_session + put :update, params: {id: plan.to_param, plan: invalid_attributes}, session: valid_session expect(assigns(:plan)).to eq(plan) end it "re-renders the 'edit' template" do plan = Plan.create! valid_attributes - put :update, {id: plan.to_param, plan: invalid_attributes}, session: valid_session + put :update, params: {id: plan.to_param, plan: invalid_attributes}, session: valid_session expect(response).to render_template("edit") end end @@ -155,13 +155,13 @@ module Tang it "destroys the requested plan" do plan = Plan.create! valid_attributes expect { - delete :destroy, {id: plan.to_param}, session: valid_session + delete :destroy, params: {id: plan.to_param}, session: valid_session }.to change(Plan, :count).by(-1) end it "redirects to the plans list" do plan = Plan.create! valid_attributes - delete :destroy, {id: plan.to_param}, session: valid_session + delete :destroy, params: {id: plan.to_param}, session: valid_session expect(response).to redirect_to(admin_plans_url) end end diff --git a/spec/controllers/tang/admin/subscriptions_controller_spec.rb b/spec/controllers/tang/admin/subscriptions_controller_spec.rb index 839171d..c2395a7 100644 --- a/spec/controllers/tang/admin/subscriptions_controller_spec.rb +++ b/spec/controllers/tang/admin/subscriptions_controller_spec.rb @@ -57,7 +57,7 @@ module Tang it "assigns the requested subscription as @subscription" do # subscription = Subscription.create! valid_attributes subscription = FactoryBot.create(:subscription) - get :show, {id: subscription.to_param}, session: valid_session + get :show, params: {id: subscription.to_param}, session: valid_session expect(assigns(:subscription)).to eq(subscription) end end @@ -66,7 +66,7 @@ module Tang it "assigns the requested subscription as @subscription" do # subscription = Subscription.create! valid_attributes subscription = FactoryBot.create(:subscription) - get :edit, {id: subscription.to_param}, session: valid_session + get :edit, params: {id: subscription.to_param}, session: valid_session expect(assigns(:subscription)).to eq(subscription) end end @@ -81,7 +81,7 @@ module Tang it "updates the requested subscription" do # subscription = Subscription.create! valid_attributes subscription = FactoryBot.create(:subscription) - put :update, {id: subscription.to_param, subscription: new_attributes}, session: valid_session + put :update, params: {id: subscription.to_param, subscription: new_attributes}, session: valid_session subscription.reload # skip("Add assertions for updated state") expect(subscription.quantity).to eq(2) @@ -90,14 +90,14 @@ module Tang it "assigns the requested subscription as @subscription" do # subscription = Subscription.create! valid_attributes subscription = FactoryBot.create(:subscription) - put :update, {id: subscription.to_param, subscription: valid_attributes}, session: valid_session + put :update, params: {id: subscription.to_param, subscription: valid_attributes}, session: valid_session expect(assigns(:subscription)).to eq(subscription) end it "redirects to the subscription" do # subscription = Subscription.create! valid_attributes subscription = FactoryBot.create(:subscription) - put :update, {id: subscription.to_param, subscription: valid_attributes}, session: valid_session + put :update, params: {id: subscription.to_param, subscription: valid_attributes}, session: valid_session expect(response).to redirect_to(admin_subscription_url(subscription)) end end @@ -106,14 +106,14 @@ module Tang it "assigns the subscription as @subscription" do # subscription = Subscription.create! valid_attributes subscription = FactoryBot.create(:subscription) - put :update, {id: subscription.to_param, subscription: invalid_attributes}, session: valid_session + put :update, params: {id: subscription.to_param, subscription: invalid_attributes}, session: valid_session expect(assigns(:subscription)).to eq(subscription) end it "re-renders the 'edit' template" do # subscription = Subscription.create! valid_attributes subscription = FactoryBot.create(:subscription) - put :update, {id: subscription.to_param, subscription: invalid_attributes}, session: valid_session + put :update, params: {id: subscription.to_param, subscription: invalid_attributes}, session: valid_session expect(response).to render_template("edit") end end @@ -124,14 +124,14 @@ module Tang # subscription = Subscription.create! valid_attributes subscription = FactoryBot.create(:subscription) expect { - delete :destroy, {id: subscription.to_param}, session: valid_session + delete :destroy, params: {id: subscription.to_param}, session: valid_session }.to change(Subscription.where.not(status: :canceled), :count).by(-1) end it "redirects to the subscriptions list" do # subscription = Subscription.create! valid_attributes subscription = FactoryBot.create(:subscription) - delete :destroy, {id: subscription.to_param}, session: valid_session + delete :destroy, params: {id: subscription.to_param}, session: valid_session expect(response).to redirect_to(admin_subscriptions_url) end end diff --git a/spec/requests/stripe_event_spec.rb b/spec/requests/stripe_event_spec.rb index e78ca9a..0058757 100644 --- a/spec/requests/stripe_event_spec.rb +++ b/spec/requests/stripe_event_spec.rb @@ -20,7 +20,7 @@ def bypass_event_signature(payload) deliveries = Tang::StripeMailer.deliveries.length - post '/stripe_event', id: event.id + post '/stripe_event', params: { id: event.id } expect(response.code).to eq('200') expect(Tang::StripeMailer.deliveries.length).to eq(deliveries + 1) @@ -36,7 +36,7 @@ def bypass_event_signature(payload) dispute_object = event.data.object bypass_event_signature(event.to_json) - post '/stripe_event', id: event.id + post '/stripe_event', params: { id: event.id } expect(response.code).to eq('200') expect(dispute_object.id).to_not be_nil @@ -50,7 +50,7 @@ def bypass_event_signature(payload) dispute_object = event.data.object bypass_event_signature(event.to_json) - post '/stripe_event', id: event.id + post '/stripe_event', params: { id: event.id } expect(response.code).to eq('200') expect(dispute_object.id).to_not be_nil @@ -64,7 +64,7 @@ def bypass_event_signature(payload) invoice_object = event.data.object bypass_event_signature(event.to_json) - post '/stripe_event', id: event.id + post '/stripe_event', params: { id: event.id } expect(response.code).to eq('200') expect(invoice_object.id).to_not be_nil @@ -98,7 +98,7 @@ def bypass_event_signature(payload) deliveries = Tang::StripeMailer.deliveries.length - post '/stripe_event', id: event.id + post '/stripe_event', params: { id: event.id } expect(response.code).to eq('200') expect(Tang::StripeMailer.deliveries.length).to eq(deliveries + 2) @@ -136,7 +136,7 @@ def bypass_event_signature(payload) deliveries = Tang::StripeMailer.deliveries.length - post '/stripe_event', id: event.id + post '/stripe_event', params: { id: event.id } expect(response.code).to eq('200') expect(Tang::StripeMailer.deliveries.length).to eq(deliveries + 2) @@ -155,7 +155,7 @@ def bypass_event_signature(payload) subscription_object = event.data.object bypass_event_signature(event.to_json) - post '/stripe_event', id: event.id + post '/stripe_event', params: { id: event.id } expect(response.code).to eq('200') expect(subscription_object.id).to_not be_nil diff --git a/spec/tang_app/config/application.rb b/spec/tang_app/config/application.rb index ec4fdd6..7c2c59f 100644 --- a/spec/tang_app/config/application.rb +++ b/spec/tang_app/config/application.rb @@ -30,7 +30,7 @@ class Application < Rails::Application # config.i18n.default_locale = :de # Do not swallow errors in after_commit/after_rollback callbacks. - config.active_record.raise_in_transactional_callbacks = true + # config.active_record.raise_in_transactional_callbacks = true config.action_mailer.preview_path = File.expand_path('../../../../spec/mailers/previews', __FILE__) end diff --git a/spec/tang_app/config/environments/production.rb b/spec/tang_app/config/environments/production.rb index 641aacb..7a8696a 100644 --- a/spec/tang_app/config/environments/production.rb +++ b/spec/tang_app/config/environments/production.rb @@ -67,7 +67,7 @@ # Enable locale fallbacks for I18n (makes lookups for any locale fall back to # the I18n.default_locale when a translation cannot be found). - config.i18n.fallbacks = true + config.i18n.fallbacks = [I18n.default_locale] # Send deprecation notices to registered listeners. config.active_support.deprecation = :notify diff --git a/tang.gemspec b/tang.gemspec index 8d8623c..fe22c21 100644 --- a/tang.gemspec +++ b/tang.gemspec @@ -18,7 +18,7 @@ Gem::Specification.new do |s| s.test_files = Dir["spec/**/*"] - s.add_dependency "rails", "~> 4.2" + s.add_dependency "rails", "~> 5.2" s.add_dependency 'stripe', '~> 3.9' s.add_dependency 'stripe_event', '~> 2.1' s.add_dependency 'paper_trail', '~> 4.2'