solidus_core 3.0.2 → 3.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of solidus_core might be problematic. Click here for more details.

Files changed (53) hide show
  1. checksums.yaml +4 -4
  2. data/app/helpers/spree/base_helper.rb +1 -1
  3. data/app/helpers/spree/products_helper.rb +1 -1
  4. data/app/models/concerns/spree/default_price.rb +63 -10
  5. data/app/models/spree/adjustment.rb +6 -5
  6. data/app/models/spree/customer_return.rb +3 -2
  7. data/app/models/spree/image/active_storage_attachment.rb +2 -7
  8. data/app/models/spree/image/paperclip_attachment.rb +2 -2
  9. data/app/models/spree/line_item.rb +2 -2
  10. data/app/models/spree/order.rb +11 -6
  11. data/app/models/spree/price.rb +1 -1
  12. data/app/models/spree/product/scopes.rb +5 -5
  13. data/app/models/spree/product.rb +12 -0
  14. data/app/models/spree/promotion/rules/item_total.rb +50 -6
  15. data/app/models/spree/promotion.rb +2 -2
  16. data/app/models/spree/promotion_code.rb +1 -1
  17. data/app/models/spree/shipping_rate_tax.rb +1 -1
  18. data/app/models/spree/stock/availability.rb +11 -3
  19. data/app/models/spree/stock/simple_coordinator.rb +0 -10
  20. data/app/models/spree/stock_location.rb +1 -1
  21. data/app/models/spree/store_credit.rb +6 -1
  22. data/app/models/spree/tax_calculator/shipping_rate.rb +1 -1
  23. data/app/models/spree/taxon/active_storage_attachment.rb +2 -2
  24. data/app/models/spree/taxon/paperclip_attachment.rb +3 -3
  25. data/app/models/spree/variant/price_selector.rb +16 -3
  26. data/app/models/spree/variant.rb +26 -16
  27. data/config/locales/en.yml +2 -0
  28. data/db/migrate/20210312061050_change_column_null_on_prices.rb +7 -0
  29. data/lib/generators/solidus/install/install_generator.rb +1 -1
  30. data/lib/generators/solidus/install/templates/config/initializers/spree.rb.tt +3 -1
  31. data/lib/generators/solidus/update/templates/config/initializers/new_solidus_defaults.rb.tt +30 -0
  32. data/lib/generators/solidus/update/update_generator.rb +112 -0
  33. data/lib/generators/spree/dummy/templates/rails/application.rb.tt +0 -1
  34. data/lib/generators/spree/dummy/templates/rails/database.yml +78 -35
  35. data/lib/spree/app_configuration.rb +62 -0
  36. data/lib/spree/core/engine.rb +10 -11
  37. data/lib/spree/core/product_filters.rb +1 -1
  38. data/lib/spree/core/search/base.rb +1 -1
  39. data/lib/spree/core/state_machines/order.rb +1 -1
  40. data/lib/spree/core/version.rb +5 -1
  41. data/lib/spree/core/versioned_value.rb +75 -0
  42. data/lib/spree/core.rb +17 -0
  43. data/lib/spree/permitted_attributes.rb +1 -1
  44. data/lib/spree/preferences/configuration.rb +62 -0
  45. data/lib/spree/preferences/preferable.rb +8 -0
  46. data/lib/spree/preferences/preferable_class_methods.rb +5 -3
  47. data/lib/spree/preferences/preference_differentiator.rb +28 -0
  48. data/lib/spree/testing_support/dummy_app/database.yml +42 -22
  49. data/lib/spree/testing_support/dummy_app.rb +33 -18
  50. data/lib/tasks/solidus/delete_prices_with_nil_amount.rake +8 -0
  51. metadata +7 -3
  52. data/app/models/spree/tax/shipping_rate_taxer.rb +0 -24
  53. data/lib/tasks/upgrade.rake +0 -15
@@ -19,7 +19,7 @@ module Spree
19
19
  # Get the on_hand stock quantities
20
20
  # @return [Hash<Integer=>Spree::StockQuantities>] A map of stock_location_ids to the stock quantities available in that location
21
21
  def on_hand_by_stock_location_id
22
- counts_on_hand.to_a.group_by do |(_, stock_location_id), _|
22
+ quantities_by_location_id = counts_on_hand.to_a.group_by do |(_, stock_location_id), _|
23
23
  stock_location_id
24
24
  end.transform_values do |values|
25
25
  Spree::StockQuantities.new(
@@ -31,12 +31,13 @@ module Spree
31
31
  end.to_h
32
32
  )
33
33
  end
34
+ restore_location_order(quantities_by_location_id)
34
35
  end
35
36
 
36
- # Get the on_hand stock quantities
37
+ # Get the backorderable stock quantities
37
38
  # @return [Hash<Integer=>Spree::StockQuantities>] A map of stock_location_ids to the stock quantities available in that location
38
39
  def backorderable_by_stock_location_id
39
- backorderables.group_by(&:second).transform_values do |variant_ids|
40
+ quantities_by_location_id = backorderables.group_by(&:second).transform_values do |variant_ids|
40
41
  Spree::StockQuantities.new(
41
42
  variant_ids.map do |variant_id, _|
42
43
  variant = @variant_map[variant_id]
@@ -44,6 +45,7 @@ module Spree
44
45
  end.to_h
45
46
  )
46
47
  end
48
+ restore_location_order(quantities_by_location_id)
47
49
  end
48
50
 
49
51
  private
@@ -67,6 +69,12 @@ module Spree
67
69
  where(variant_id: @variants).
68
70
  where(stock_location_id: @stock_locations)
69
71
  end
72
+
73
+ def restore_location_order(quantities_by_location_id)
74
+ sorted_location_ids = @stock_locations.map(&:id)
75
+
76
+ quantities_by_location_id.sort_by { |key, _value| sorted_location_ids.index(key) }.to_h
77
+ end
70
78
  end
71
79
  end
72
80
  end
@@ -92,16 +92,6 @@ module Spree
92
92
  end
93
93
  end
94
94
 
95
- def sort_availability(availability)
96
- sorted_availability = availability.sort_by do |stock_location_id, _|
97
- @stock_locations.find_index do |stock_location|
98
- stock_location.id == stock_location_id
99
- end
100
- end
101
-
102
- Hash[sorted_availability]
103
- end
104
-
105
95
  def get_units(quantities)
106
96
  # Change our raw quantities back into inventory units
107
97
  quantities.flat_map do |variant, quantity|
@@ -26,7 +26,7 @@ module Spree
26
26
  validates_uniqueness_of :code, allow_blank: true, case_sensitive: false
27
27
 
28
28
  scope :active, -> { where(active: true) }
29
- scope :order_default, -> { order(default: :desc, name: :asc) }
29
+ scope :order_default, -> { order(default: :desc, position: :asc) }
30
30
 
31
31
  after_create :create_stock_items, if: :propagate_all_variants?
32
32
  after_save :ensure_one_default
@@ -150,7 +150,12 @@ class Spree::StoreCredit < Spree::PaymentSource
150
150
  end
151
151
 
152
152
  def generate_authorization_code
153
- "#{id}-SC-#{Time.current.utc.strftime('%Y%m%d%H%M%S%6N')}"
153
+ [
154
+ id,
155
+ 'SC',
156
+ Time.current.utc.strftime('%Y%m%d%H%M%S%6N'),
157
+ SecureRandom.uuid
158
+ ].join('-')
154
159
  end
155
160
 
156
161
  def editable?
@@ -9,7 +9,7 @@ module Spree
9
9
  # looking to provide their own calculator should adhere to the API of this
10
10
  # class.
11
11
  #
12
- # @see Spree::Tax::ShippingRateTaxer
12
+ # @see Spree::Stock::Estimator
13
13
  class ShippingRate
14
14
  include Spree::Tax::TaxHelpers
15
15
 
@@ -6,8 +6,8 @@ module Spree::Taxon::ActiveStorageAttachment
6
6
 
7
7
  included do
8
8
  has_attachment :icon,
9
- styles: { mini: '32x32>', normal: '128x128>' },
10
- default_style: :mini
9
+ styles: Spree::Config.taxon_image_styles,
10
+ default_style: Spree::Config.taxon_image_style_default
11
11
  validate :icon_is_an_image
12
12
  end
13
13
  end
@@ -5,14 +5,14 @@ module Spree::Taxon::PaperclipAttachment
5
5
 
6
6
  included do
7
7
  has_attached_file :icon,
8
- styles: { mini: '32x32>', normal: '128x128>' },
9
- default_style: :mini,
8
+ styles: Spree::Config.taxon_image_styles,
9
+ default_style: Spree::Config.taxon_image_style_default,
10
10
  url: '/spree/taxons/:id/:style/:basename.:extension',
11
11
  path: ':rails_root/public/spree/taxons/:id/:style/:basename.:extension',
12
12
  default_url: '/assets/default_taxon.png'
13
13
 
14
14
  validates_attachment :icon,
15
- content_type: { content_type: %w[image/jpg image/jpeg image/png image/gif] }
15
+ content_type: { content_type: Spree::Config.allowed_image_mime_types }
16
16
  end
17
17
 
18
18
  def icon_present?
@@ -26,11 +26,24 @@ module Spree
26
26
  # @param [Spree::Variant::PricingOptions] price_options Pricing Options to abide by
27
27
  # @return [Spree::Money, nil] The most specific price for this set of pricing options.
28
28
  def price_for(price_options)
29
+ Spree::Deprecation.warn(
30
+ "price_for is deprecated and will be removed. The price_for method
31
+ should return a Spree::Price as described. Please use
32
+ #price_for_options and adjust your frontend code to explicitly call
33
+ &.money where required"
34
+ )
35
+ price_for_options(price_options)&.money
36
+ end
37
+
38
+ # The variant's Spree::Price record, given a set of pricing options
39
+ # @param [Spree::Variant::PricingOptions] price_options Pricing Options to abide by
40
+ # @return [Spree::Price, nil] The most specific price for this set of pricing options.
41
+ def price_for_options(price_options)
29
42
  variant.currently_valid_prices.detect do |price|
30
- ( price.country_iso == price_options.desired_attributes[:country_iso] ||
31
- price.country_iso.nil?
43
+ (price.country_iso == price_options.desired_attributes[:country_iso] ||
44
+ price.country_iso.nil?
32
45
  ) && price.currency == price_options.desired_attributes[:currency]
33
- end.try!(:money)
46
+ end
34
47
  end
35
48
  end
36
49
  end
@@ -24,7 +24,6 @@ module Spree
24
24
  stock_items.discard_all
25
25
  images.destroy_all
26
26
  prices.discard_all
27
- currently_valid_prices.discard_all
28
27
  end
29
28
 
30
29
  attr_writer :rebuild_vat_prices
@@ -58,13 +57,6 @@ module Spree
58
57
  inverse_of: :variant,
59
58
  autosave: true
60
59
 
61
- has_many :currently_valid_prices,
62
- -> { currently_valid },
63
- class_name: 'Spree::Price',
64
- dependent: :destroy,
65
- inverse_of: :variant,
66
- autosave: true
67
-
68
60
  before_validation :set_cost_currency
69
61
  before_validation :set_price, if: -> { product && product.master }
70
62
  before_validation :build_vat_prices, if: -> { rebuild_vat_prices? || new_record? && product }
@@ -276,16 +268,17 @@ module Spree
276
268
  end
277
269
 
278
270
  # Chooses an appropriate price for the given pricing options
271
+ # This has been deprecated in favor of #price_for_options.
279
272
  #
280
- # @see Spree::Variant::PriceSelector#price_for
273
+ # @see Spree::Variant::PriceSelector#price_for_options
281
274
  delegate :price_for, to: :price_selector
282
275
 
283
276
  # Returns the difference in price from the master variant
284
277
  def price_difference_from_master(pricing_options = Spree::Config.default_pricing_options)
285
- master_price = product.master.price_for(pricing_options)
286
- variant_price = price_for(pricing_options)
278
+ master_price = product.master.price_for_options(pricing_options)
279
+ variant_price = price_for_options(pricing_options)
287
280
  return unless master_price && variant_price
288
- variant_price - master_price
281
+ Spree::Money.new(variant_price.amount - master_price.amount, currency: pricing_options.currency)
289
282
  end
290
283
 
291
284
  def price_same_as_master?(pricing_options = Spree::Config.default_pricing_options)
@@ -293,6 +286,17 @@ module Spree
293
286
  diff && diff.zero?
294
287
  end
295
288
 
289
+ def price_for_options(price_options)
290
+ if price_selector.respond_to?(:price_for_options)
291
+ price_selector.price_for_options(price_options)
292
+ else
293
+ money = price_for(price_options)
294
+ return if money.nil?
295
+
296
+ Spree::Price.new(amount: money.to_d, variant: self, currency: price_options.currency)
297
+ end
298
+ end
299
+
296
300
  # Generates a friendly name and sku string.
297
301
  #
298
302
  # @return [String]
@@ -315,16 +319,22 @@ module Spree
315
319
  end
316
320
 
317
321
  # @param quantity [Fixnum] how many are desired
322
+ # @param stock_location [Spree::StockLocation] Optionally restrict stock
323
+ # quantity check to a specific stock location. If unspecified it will
324
+ # check inventory in all available StockLocations.
318
325
  # @return [Boolean] true if the desired quantity can be supplied
319
- def can_supply?(quantity = 1)
320
- Spree::Stock::Quantifier.new(self).can_supply?(quantity)
326
+ def can_supply?(quantity = 1, stock_location = nil)
327
+ Spree::Stock::Quantifier.new(self, stock_location).can_supply?(quantity)
321
328
  end
322
329
 
323
330
  # Fetches the on-hand quantity of the variant.
324
331
  #
332
+ # @param stock_location [Spree::StockLocation] Optionally restrict stock
333
+ # quantity check to a specific stock location. If unspecified it will
334
+ # check inventory in all available StockLocations.
325
335
  # @return [Fixnum] the number currently on-hand
326
- def total_on_hand
327
- Spree::Stock::Quantifier.new(self).total_on_hand
336
+ def total_on_hand(stock_location = nil)
337
+ Spree::Stock::Quantifier.new(self, stock_location).total_on_hand
328
338
  end
329
339
 
330
340
  # Shortcut method to determine if inventory tracking is enabled for this
@@ -1288,6 +1288,8 @@ en:
1288
1288
  %{amount}.
1289
1289
  item_total_less_than_or_equal: This coupon code can't be applied to orders
1290
1290
  less than or equal to %{amount}.
1291
+ item_total_doesnt_match_with_operator: This coupon code can't be applied to
1292
+ orders %{operator} %{amount}.
1291
1293
  limit_once_per_user: This coupon code can only be used once per user.
1292
1294
  missing_product: This coupon code can't be applied because you don't have
1293
1295
  all of the necessary products in your cart.
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ class ChangeColumnNullOnPrices < ActiveRecord::Migration[5.2]
4
+ def change
5
+ change_column_null(:spree_prices, :amount, false)
6
+ end
7
+ end
@@ -132,7 +132,7 @@ module Solidus
132
132
  Solidus has a default authentication extension that uses Devise.
133
133
  You can find more info at https://github.com/solidusio/solidus_auth_devise.
134
134
 
135
- Would you like to install it? (y/n)"))
135
+ Would you like to install it? (Y/n)"))
136
136
 
137
137
  @plugins_to_be_installed << 'solidus_auth_devise'
138
138
  @plugin_generators_to_run << 'solidus:auth:install'
@@ -1,9 +1,11 @@
1
1
  # Configure Solidus Preferences
2
2
  # See http://docs.solidus.io/Spree/AppConfiguration.html for details
3
3
 
4
+ # Solidus version defaults for preferences that are not overridden
5
+ Spree.load_defaults '<%= Spree.solidus_version %>'
6
+
4
7
  Spree.config do |config|
5
8
  # Core:
6
-
7
9
  # Default currency for new sites
8
10
  config.currency = "USD"
9
11
 
@@ -0,0 +1,30 @@
1
+ # This initializer lets you preview the defaults that have changed on the new
2
+ # Solidus version.
3
+ #
4
+ # It allows you to enable them one by one while you adapt your application.
5
+ # When you're done with all of them, you can safely remove this file and add
6
+ # the updated `load_defaults` calls to the top of the config blocks in your
7
+ # Solidus main initializer. You can also call `Spree.load_defaults(version)` to
8
+ # target all components at once.
9
+
10
+ Spree.config do |config|
11
+ <%= @core_changes %>
12
+ end
13
+
14
+ <% if defined?(Spree::Frontend::Engine) -%>
15
+ Spree::Frontend::Config.configure do |config|
16
+ <%= @frontend_changes %>
17
+ end
18
+ <% end -%>
19
+
20
+ <% if defined?(Spree::Backend::Engine) -%>
21
+ Spree::Backend::Config.configure do |config|
22
+ <%= @backend_changes %>
23
+ end
24
+ <% end -%>
25
+
26
+ <% if defined?(Spree::Api::Engine) -%>
27
+ Spree::Api::Config.configure do |config|
28
+ <%= @api_changes %>
29
+ end
30
+ <% end -%>
@@ -0,0 +1,112 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'spree/preferences/preference_differentiator'
4
+ require 'rails/generators'
5
+
6
+ module Solidus
7
+ # @private
8
+ class UpdateGenerator < ::Rails::Generators::Base
9
+ FROM = Spree.previous_solidus_minor_version
10
+
11
+ desc 'Generates a new initializer to preview the new defaults for current Solidus version'
12
+
13
+ source_root File.expand_path('templates', __dir__)
14
+
15
+ class_option :initializer_basename,
16
+ type: :string,
17
+ default: 'new_solidus_defaults',
18
+ banner: 'The name for the new initializer'
19
+
20
+ class_option :previous_version_prompt,
21
+ type: :boolean,
22
+ default: true,
23
+ banner: 'Prompt to warn about only previous version support'
24
+
25
+ class_option :from,
26
+ type: :string,
27
+ default: FROM,
28
+ banner: 'Solidus version from which you are upgrading'
29
+
30
+ class_option :to,
31
+ type: :string,
32
+ default: Spree.solidus_version,
33
+ hide: true
34
+
35
+ class_option :initializer_directory,
36
+ type: :string,
37
+ default: 'config/initializers/',
38
+ hide: true
39
+
40
+ def create_new_defaults_initializer
41
+ previous_version_prompt = options[:previous_version_prompt]
42
+ return if previous_version_prompt && !yes?(<<~MSG, :red)
43
+ The update process is only supported if you are coming from version #{FROM}. If this is not the case, please, skip it and update your application to use Solidus #{FROM} before retrying.
44
+ If you are confident you want to upgrade from a previous version, you must rerun the generator with the "--from={OLD_VERSION}" argument.
45
+ Are you sure you want to continue? (y/N)
46
+ MSG
47
+
48
+ from = options[:from]
49
+ to = options[:to]
50
+ @from = from
51
+ @core_changes = core_changes_template(from, to)
52
+ @frontend_changes = frontend_changes_template(from, to)
53
+ @backend_changes = backend_changes_template(from, to)
54
+ @api_changes = api_changes_template(from, to)
55
+
56
+ template 'config/initializers/new_solidus_defaults.rb.tt',
57
+ File.join(options[:initializer_directory], "#{options[:initializer_basename]}.rb")
58
+ end
59
+
60
+ def print_message
61
+ say <<~MSG
62
+
63
+ ***********************************************************************
64
+
65
+ Other tasks may be needed to update to the new Solidus version. Please,
66
+ check https://github.com/solidusio/solidus/blob/v#{options[:to]}/CHANGELOG.md
67
+ for details.
68
+
69
+ Thanks for using Solidus!
70
+
71
+ ***********************************************************************
72
+
73
+ MSG
74
+ end
75
+
76
+ private
77
+
78
+ def core_changes_template(from, to)
79
+ changes_template_for(Spree::AppConfiguration, from, to)
80
+ end
81
+
82
+ def frontend_changes_template(from, to)
83
+ return '' unless defined?(Spree::Frontend::Engine)
84
+
85
+ changes_template_for(Spree::FrontendConfiguration, from, to)
86
+ end
87
+
88
+ def backend_changes_template(from, to)
89
+ return '' unless defined?(Spree::Backend::Engine)
90
+
91
+ changes_template_for(Spree::BackendConfiguration, from, to)
92
+ end
93
+
94
+ def api_changes_template(from, to)
95
+ return '' unless defined?(Spree::Api::Engine)
96
+
97
+ changes_template_for(Spree::ApiConfiguration, from, to)
98
+ end
99
+
100
+ def changes_template_for(klass, from, to)
101
+ changes = Spree::Preferences::PreferenceDifferentiator.new(klass).call(from: from, to: to)
102
+ return '# No changes' if changes.empty?
103
+
104
+ [
105
+ ["config.load_defaults('#{from}')"] +
106
+ changes.map do |pref_key, change|
107
+ " # config.#{pref_key} = #{change[:to]}"
108
+ end.flatten
109
+ ].join("\n")
110
+ end
111
+ end
112
+ end
@@ -7,4 +7,3 @@ Bundler.require(*Rails.groups(assets: %w(development test)))
7
7
  require '<%= lib_name %>'
8
8
 
9
9
  <%= application_definition %>
10
-
@@ -1,66 +1,111 @@
1
1
  <% if agent_number = ENV['TC_AGENT_NUMBER']
2
2
  database_prefix = agent_number + '_'
3
3
  end %>
4
+ <% db = case ENV['DB']
5
+ when 'mysql'
6
+ 'mysql'
7
+ when 'postgres', 'postgresql'
8
+ 'postgres'
9
+ when 'sqlite', '', nil
10
+ 'sqlite'
11
+ else
12
+ raise "Invalid DB specified: #{ENV['DB']}"
13
+ end %>
14
+ <% db_host = case db
15
+ when 'mysql'
16
+ ENV['DB_MYSQL_HOST'] || ENV['DB_HOST']
17
+ when 'postgres'
18
+ ENV['DB_POSTGRES_HOST'] || ENV['DB_HOST']
19
+ else
20
+ ENV['DB_HOST']
21
+ end %>
22
+ <% db_username = ENV['DB_USERNAME'] %>
23
+ <% db_password = ENV['DB_PASSWORD'] %>
24
+
25
+
26
+
27
+
4
28
  <% case ENV['DB']
5
- when 'sqlite' %>
6
- development:
7
- adapter: sqlite3
8
- database: db/solidus_development.sqlite3
9
- test:
10
- adapter: sqlite3
11
- database: db/solidus_test.sqlite3
12
- timeout: 10000
13
- production:
14
- adapter: sqlite3
15
- database: db/solidus_production.sqlite3
16
- <% when 'mysql' %>
29
+ when 'mysql' %>
17
30
  development:
18
31
  adapter: mysql2
19
32
  database: <%= database_prefix %><%= options[:lib_name] %>_solidus_development
33
+ <% unless db_username.blank? %>
34
+ username: <%= db_username %>
35
+ <% end %>
36
+ <% unless db_password.blank? %>
37
+ password: <%= db_password %>
38
+ <% end %>
39
+ <% unless db_host.blank? %>
40
+ host: <%= db_host %>
41
+ <% end %>
20
42
  encoding: utf8
21
43
  test:
22
44
  adapter: mysql2
23
- <% if ENV['TRAVIS'] %>
24
- username: root
25
- password:
26
- <% end %>
27
45
  database: <%= database_prefix %><%= options[:lib_name] %>_solidus_test
46
+ <% unless db_username.blank? %>
47
+ username: <%= db_username %>
48
+ <% end %>
49
+ <% unless db_password.blank? %>
50
+ password: <%= db_password %>
51
+ <% end %>
52
+ <% unless db_host.blank? %>
53
+ host: <%= db_host %>
54
+ <% end %>
28
55
  encoding: utf8
29
56
  production:
30
57
  adapter: mysql2
31
58
  database: <%= database_prefix %><%= options[:lib_name] %>_solidus_production
59
+ <% unless db_username.blank? %>
60
+ username: <%= db_username %>
61
+ <% end %>
62
+ <% unless db_password.blank? %>
63
+ password: <%= db_password %>
64
+ <% end %>
65
+ <% unless db_host.blank? %>
66
+ host: <%= db_host %>
67
+ <% end %>
32
68
  encoding: utf8
33
69
  <% when 'postgres', 'postgresql' %>
34
- <% db_host = ENV['DB_HOST'] -%>
35
- <% db_username = ENV['DB_USERNAME'] -%>
36
- <% db_password = ENV['DB_PASSWORD'] -%>
37
70
  development:
38
71
  adapter: postgresql
39
72
  database: <%= database_prefix %><%= options[:lib_name] %>_solidus_development
40
- username: postgres
41
- min_messages: warning
42
- <% unless db_host.blank? %>
73
+ <% unless db_username.blank? %>
74
+ username: <%= db_username %>
75
+ <% end %>
76
+ <% unless db_password.blank? %>
77
+ password: <%= db_password %>
78
+ <% end %>
79
+ <% unless db_host.blank? %>
43
80
  host: <%= db_host %>
44
- <% end %>
81
+ <% end %>
82
+ min_messages: warning
45
83
  test:
46
84
  adapter: postgresql
47
85
  database: <%= database_prefix %><%= options[:lib_name] %>_solidus_test
48
- username: <%= db_username || 'postgres' %>
49
- <% unless db_password.blank? %>
86
+ <% unless db_username.blank? %>
87
+ username: <%= db_username %>
88
+ <% end %>
89
+ <% unless db_password.blank? %>
50
90
  password: <%= db_password %>
51
- <% end %>
52
- min_messages: warning
53
- <% unless db_host.blank? %>
91
+ <% end %>
92
+ <% unless db_host.blank? %>
54
93
  host: <%= db_host %>
55
- <% end %>
94
+ <% end %>
95
+ min_messages: warning
56
96
  production:
57
97
  adapter: postgresql
58
98
  database: <%= database_prefix %><%= options[:lib_name] %>_solidus_production
59
- username: postgres
60
- min_messages: warning
61
- <% unless db_host.blank? %>
99
+ <% unless db_username.blank? %>
100
+ username: <%= db_username %>
101
+ <% end %>
102
+ <% unless db_password.blank? %>
103
+ password: <%= db_password %>
104
+ <% end %>
105
+ <% unless db_host.blank? %>
62
106
  host: <%= db_host %>
63
- <% end %>
107
+ <% end %>
108
+ min_messages: warning
64
109
  <% when 'sqlite', '', nil %>
65
110
  development:
66
111
  adapter: sqlite3
@@ -71,6 +116,4 @@ test:
71
116
  production:
72
117
  adapter: sqlite3
73
118
  database: db/solidus_production.sqlite3
74
- <% else %>
75
- <% raise "Invalid DB specified: #{ENV['DB']}" %>
76
119
  <% end %>