And mock the preference value, rather than setting it. Before, the set preference could have leaked to other tests.
(I noticed that it was already like this in product_import_spec.rb)
We know if the values are too long, so let's provide a useful message rather than generating an unhandled database error.
This code seems rather repetetive, it would be good to use a shared module. I wonder if there's a gem for that.
Note that the existing /products/*/edit screen doesn't even handle validation errors yet, but that's something for another day..
We want to keep the voucher adjustment associated with the Voucher
event when the voucher as been soft deleted, as we use this
functionality as activate/deactivate feature
An error was apparent in specs when trying to assign a string as the price. It's not a problem when submitting the form in the browser, I don't know why.
But in any case, it shouldn't be trying to modify a variable passed as a parameter.
Inspecting 1483 files
..............................................................................................................................................................C.............................................................................................................................................................................CC.............................................................................................................................................................................C.................................................................................................................................................................................................................................................................................................................................................................C.................................................................................C..............................................................................................................................................................................................C.....................................................................................................................................................................................................................................C......................................................................................................................
Offenses:
app/helpers/discourse_helper.rb:9:5: C: [Corrected] Style/FetchEnvVar: Use ENV.fetch('DISCOURSE_URL') or ENV.fetch('DISCOURSE_URL', nil) instead of ENV['DISCOURSE_URL'].
ENV['DISCOURSE_URL']
^^^^^^^^^^^^^^^^^^^^
app/models/spree/preferences/configuration.rb:35:10: C: [Corrected] Style/FetchEnvVar: Use ENV.fetch('RAILS_CACHE_ID') or ENV.fetch('RAILS_CACHE_ID', nil) instead of ENV['RAILS_CACHE_ID'].
[ENV['RAILS_CACHE_ID'], self.class.name, name].flatten.join('::').underscore
^^^^^^^^^^^^^^^^^^^^^
app/models/spree/preferences/preferable.rb:84:10: C: [Corrected] Style/FetchEnvVar: Use ENV.fetch("RAILS_CACHE_ID") or ENV.fetch("RAILS_CACHE_ID", nil) instead of ENV["RAILS_CACHE_ID"].
[ENV["RAILS_CACHE_ID"], self.class.name, name, id].join('::').underscore
^^^^^^^^^^^^^^^^^^^^^
app/services/default_country.rb:13:40: C: [Corrected] Style/FetchEnvVar: Use ENV.fetch("DEFAULT_COUNTRY_CODE") or ENV.fetch("DEFAULT_COUNTRY_CODE", nil) instead of ENV["DEFAULT_COUNTRY_CODE"].
Spree::Country.cached_find_by(iso: ENV["DEFAULT_COUNTRY_CODE"]) || Spree::Country.first
^^^^^^^^^^^^^^^^^^^^^^^^^^^
app/services/default_country.rb:13:73: C: [Corrected] Layout/TrailingWhitespace: Trailing whitespace detected.
Spree::Country.cached_find_by(iso: ENV.fetch("DEFAULT_COUNTRY_CODE",
^
app/services/default_country.rb:13:101: C: [Corrected] Layout/LineLength: Line is too long. [102/100]
Spree::Country.cached_find_by(iso: ENV.fetch("DEFAULT_COUNTRY_CODE", nil)) || Spree::Country.first
^^
app/services/default_country.rb:14:1: C: [Corrected] Layout/ArgumentAlignment: Align the arguments of a method call if they span more than one line.
nil)) || Spree::Country.first
^^^
spec/base_spec_helper.rb:51:49: C: [Corrected] Style/FetchEnvVar: Use ENV.fetch("SITE_URL") or ENV.fetch("SITE_URL", nil) instead of ENV["SITE_URL"].
ActionMailer::Base.default_url_options[:host] = ENV["SITE_URL"]
^^^^^^^^^^^^^^^
spec/controllers/spree/credit_cards_controller_spec.rb:8:20: C: [Corrected] Style/FetchEnvVar: Use ENV.fetch('STRIPE_SECRET_TEST_API_KEY') or ENV.fetch('STRIPE_SECRET_TEST_API_KEY', nil) instead of ENV['STRIPE_SECRET_TEST_API_KEY'].
let(:secret) { ENV['STRIPE_SECRET_TEST_API_KEY'] }
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
spec/models/order_balance_spec.rb:48:70: C: [Corrected] Layout/TrailingWhitespace: Trailing whitespace detected.
expect(order_balance.display_amount).to eq(Spree::Money.new(20,
^
spec/models/order_balance_spec.rb:48:81: C: [Corrected] Style/FetchEnvVar: Use ENV.fetch('currency') or ENV.fetch('currency', nil) instead of ENV['currency'].
expect(order_balance.display_amount).to eq(Spree::Money.new(20, currency: ENV['currency']))
^^^^^^^^^^^^^^^
spec/models/order_balance_spec.rb:48:101: C: [Corrected] Layout/LineLength: Line is too long. [108/100]
expect(order_balance.display_amount).to eq(Spree::Money.new(20, currency: ENV.fetch('currency', nil)))
^^^^^^^^
spec/models/order_balance_spec.rb:49:1: C: [Corrected] Layout/ArgumentAlignment: Align the arguments of a method call if they span more than one line.
currency: ENV.fetch('currency', nil)))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
spec/models/order_balance_spec.rb:49:98: C: [Corrected] Layout/TrailingWhitespace: Trailing whitespace detected.
currency: ENV.fetch('currency',
^
spec/models/order_balance_spec.rb:49:101: C: [Corrected] Layout/LineLength: Line is too long. [104/100]
currency: ENV.fetch('currency', nil)))
^^^^
spec/models/order_balance_spec.rb:50:1: C: [Corrected] Layout/ArgumentAlignment: Align the arguments of a method call if they span more than one line.
nil)))
^^^
spec/support/vcr_setup.rb:10:50: C: [Corrected] Style/FetchEnvVar: Use ENV.fetch('STRIPE_SECRET_TEST_API_KEY') or ENV.fetch('STRIPE_SECRET_TEST_API_KEY', nil) instead of ENV['STRIPE_SECRET_TEST_API_KEY'].
config.filter_sensitive_data('<HIDDEN_KEY>') { ENV['STRIPE_SECRET_TEST_API_KEY'] }
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
spec/support/vcr_setup.rb:11:55: C: [Corrected] Style/FetchEnvVar: Use ENV.fetch('STRIPE_CUSTOMER') or ENV.fetch('STRIPE_CUSTOMER', nil) instead of ENV['STRIPE_CUSTOMER'].
config.filter_sensitive_data('<HIDDEN_CUSTOMER>') { ENV['STRIPE_CUSTOMER'] }
^^^^^^^^^^^^^^^^^^^^^^
1483 files inspected, 18 offenses detected, 18 offenses corrected