spree_core 0.40.4 → 0.50.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +6 -1
- data/app/controllers/admin/base_controller.rb +0 -57
- data/app/controllers/admin/configurations_controller.rb +1 -1
- data/app/controllers/admin/general_settings_controller.rb +1 -1
- data/app/controllers/admin/images_controller.rb +18 -8
- data/app/controllers/admin/inventory_settings_controller.rb +1 -1
- data/app/controllers/admin/mail_settings_controller.rb +1 -1
- data/app/controllers/admin/option_types_controller.rb +11 -0
- data/app/controllers/admin/orders_controller.rb +16 -20
- data/app/controllers/admin/overview_controller.rb +1 -1
- data/app/controllers/admin/payment_methods_controller.rb +6 -6
- data/app/controllers/admin/product_groups_controller.rb +10 -11
- data/app/controllers/admin/product_properties_controller.rb +5 -5
- data/app/controllers/admin/product_scopes_controller.rb +12 -4
- data/app/controllers/admin/products_controller.rb +17 -12
- data/app/controllers/admin/properties_controller.rb +7 -7
- data/app/controllers/admin/prototypes_controller.rb +15 -15
- data/app/controllers/admin/reports_controller.rb +12 -11
- data/app/controllers/admin/shipments_controller.rb +0 -5
- data/app/controllers/admin/shipping_categories_controller.rb +6 -6
- data/app/controllers/admin/shipping_methods_controller.rb +1 -2
- data/app/controllers/admin/states_controller.rb +12 -12
- data/app/controllers/admin/tax_categories_controller.rb +2 -2
- data/app/controllers/admin/tax_rates_controller.rb +8 -8
- data/app/controllers/admin/tax_settings_controller.rb +1 -1
- data/app/controllers/admin/taxonomies_controller.rb +3 -3
- data/app/controllers/admin/taxons_controller.rb +1 -8
- data/app/controllers/admin/trackers_controller.rb +1 -1
- data/app/controllers/admin/users_controller.rb +6 -9
- data/app/controllers/admin/variants_controller.rb +13 -2
- data/app/controllers/admin/zones_controller.rb +9 -9
- data/app/controllers/checkout_controller.rb +5 -5
- data/app/controllers/products_controller.rb +1 -1
- data/app/controllers/taxons_controller.rb +3 -1
- data/app/helpers/admin/navigation_helper.rb +36 -19
- data/app/helpers/admin/payments_helper.rb +1 -1
- data/app/helpers/admin/product_groups_helper.rb +1 -1
- data/app/helpers/admin/product_properties_helper.rb +5 -5
- data/app/helpers/admin/products_helper.rb +2 -2
- data/app/helpers/admin/users_helper.rb +5 -2
- data/app/helpers/hook_helper.rb +3 -3
- data/app/helpers/products_helper.rb +0 -19
- data/app/helpers/spree/base_helper.rb +33 -2
- data/app/helpers/taxons_helper.rb +3 -3
- data/app/mailers/order_mailer.rb +2 -2
- data/app/mailers/shipment_mailer.rb +2 -2
- data/app/models/address.rb +42 -9
- data/app/models/adjustment.rb +8 -8
- data/app/models/app_configuration.rb +0 -6
- data/app/models/billing_integration.rb +1 -1
- data/app/models/calculator/sales_tax.rb +3 -3
- data/app/models/configuration.rb +1 -1
- data/app/models/country.rb +4 -5
- data/app/models/creditcard.rb +38 -31
- data/app/models/gateway.rb +14 -14
- data/app/models/gateway/beanstream.rb +4 -4
- data/app/models/gateway/bogus.rb +6 -6
- data/app/models/gateway/braintree.rb +88 -0
- data/app/models/gateway/eway.rb +3 -3
- data/app/models/image.rb +5 -4
- data/app/models/option_type.rb +1 -0
- data/app/models/order.rb +60 -21
- data/app/models/payment.rb +5 -32
- data/app/models/preference.rb +7 -7
- data/app/models/product.rb +22 -7
- data/app/models/product_group.rb +22 -26
- data/app/models/product_property.rb +5 -5
- data/app/models/product_scope.rb +26 -6
- data/app/models/property.rb +1 -1
- data/app/models/state.rb +2 -3
- data/app/models/tax_category.rb +1 -0
- data/app/models/tax_rate.rb +1 -2
- data/app/models/taxon.rb +12 -10
- data/app/models/taxonomy.rb +7 -4
- data/app/models/tracker.rb +1 -1
- data/app/models/user.rb +4 -0
- data/app/models/variant.rb +1 -1
- data/app/models/zone.rb +1 -1
- data/app/models/zone_member.rb +3 -3
- data/app/views/admin/{shared → adjustments}/_adjustments_table.html.erb +7 -4
- data/app/views/admin/adjustments/edit.html.erb +1 -1
- data/app/views/admin/adjustments/index.html.erb +2 -2
- data/app/views/admin/adjustments/new.html.erb +2 -1
- data/app/views/admin/general_settings/edit.html.erb +4 -12
- data/app/views/admin/general_settings/show.html.erb +0 -5
- data/app/views/admin/images/index.html.erb +8 -5
- data/app/views/admin/inventory_settings/show.html.erb +1 -1
- data/app/views/admin/mail_methods/index.html.erb +4 -4
- data/app/views/admin/option_types/_form.html.erb +4 -4
- data/app/views/admin/option_types/_option_value_fields.html.erb +2 -2
- data/app/views/admin/option_types/edit.html.erb +4 -2
- data/app/views/admin/option_types/index.html.erb +5 -5
- data/app/views/admin/orders/_line_item.html.erb +2 -1
- data/app/views/admin/orders/history.html.erb +6 -2
- data/app/views/admin/orders/index.html.erb +22 -19
- data/app/views/admin/orders/show.html.erb +1 -1
- data/app/views/admin/orders/user.html.erb +1 -1
- data/app/views/admin/payment_methods/index.html.erb +7 -5
- data/app/views/admin/payments/_list.html.erb +3 -3
- data/app/views/admin/payments/index.html.erb +1 -1
- data/app/views/admin/payments/show.html.erb +2 -2
- data/app/views/admin/product_groups/edit.html.erb +7 -7
- data/app/views/admin/product_groups/index.html.erb +5 -3
- data/app/views/admin/product_groups/update.js.erb +4 -3
- data/app/views/admin/product_properties/_product_property_fields.html.erb +3 -3
- data/app/views/admin/product_properties/index.html.erb +10 -5
- data/app/views/admin/product_scopes/destroy.js.erb +1 -0
- data/app/views/admin/products/index.html.erb +32 -33
- data/app/views/admin/properties/_form.html.erb +2 -2
- data/app/views/admin/properties/index.html.erb +4 -4
- data/app/views/admin/prototypes/index.html.erb +4 -4
- data/app/views/admin/shared/_address_form.html.erb +1 -1
- data/app/views/admin/shared/_calculator_fields.html.erb +1 -1
- data/app/views/admin/shared/_destroy.js.erb +15 -2
- data/app/views/admin/shared/_order_tabs.html.erb +1 -1
- data/app/views/admin/shared/_report_criteria.html.erb +1 -1
- data/app/views/admin/shipments/_form.html.erb +6 -2
- data/app/views/admin/shipments/edit.html.erb +1 -1
- data/app/views/admin/shipments/index.html.erb +4 -2
- data/app/views/admin/shipping_methods/_form.html.erb +2 -0
- data/app/views/admin/shipping_methods/index.html.erb +3 -2
- data/app/views/admin/states/_state_list.html.erb +11 -5
- data/app/views/admin/tax_categories/index.html.erb +9 -4
- data/app/views/admin/tax_settings/show.html.erb +2 -2
- data/app/views/admin/taxonomies/_list.html.erb +4 -2
- data/app/views/admin/taxonomies/index.html.erb +2 -2
- data/app/views/admin/taxons/_form.html.erb +1 -1
- data/app/views/admin/trackers/index.html.erb +5 -5
- data/app/views/admin/users/_form.html.erb +3 -4
- data/app/views/admin/users/index.html.erb +7 -6
- data/app/views/admin/users/show.html.erb +3 -3
- data/app/views/admin/variants/index.html.erb +21 -6
- data/app/views/admin/zones/_form.html.erb +9 -9
- data/app/views/admin/zones/_member_type.html.erb +5 -5
- data/app/views/admin/zones/index.html.erb +7 -5
- data/app/views/checkout/_address.html.erb +2 -2
- data/app/views/checkout/_payment.html.erb +3 -6
- data/app/views/layouts/admin.html.erb +3 -9
- data/app/views/layouts/spree_application.html.erb +2 -1
- data/app/views/orders/_line_item.html.erb +1 -1
- data/app/views/orders/edit.html.erb +17 -16
- data/app/views/orders/show.html.erb +1 -1
- data/app/views/shared/_admin_head.html.erb +1 -1
- data/app/views/shared/_error_messages.html.erb +2 -2
- data/app/views/shared/_filters.html.erb +4 -4
- data/app/views/shared/_head.html.erb +2 -2
- data/app/views/shared/_nav_bar.html.erb +2 -2
- data/app/views/shared/_products.html.erb +4 -2
- data/app/views/shared/_taxonomies.html.erb +15 -8
- data/app/views/shipment_mailer/shipped_email.text.erb +2 -2
- data/config/cucumber.yml +10 -0
- data/config/initializers/form_builder.rb +1 -5
- data/config/initializers/workarounds_for_ruby19.rb +5 -5
- data/config/locales/en.yml +33 -6
- data/config/routes.rb +18 -13
- data/db/migrate/20090923100315_add_count_on_hand_to_variants_and_products.rb +5 -5
- data/db/migrate/20091213222815_creditcard_last_four_digits.rb +5 -5
- data/db/migrate/20100105132138_shipment_id_for_inventory_units.rb +2 -2
- data/db/migrate/20100209025806_create_payment_methods.rb +3 -3
- data/db/migrate/20100209144531_polymorphic_payments.rb +1 -1
- data/db/migrate/20100214212536_assign_creditcard_txns_to_payment.rb +2 -2
- data/db/migrate/20100224153127_deleted_at_for_payment_methods.rb +1 -1
- data/db/migrate/20100506185838_add_description_to_taxons.rb +1 -1
- data/db/migrate/20100816212146_shipping_method_id_for_orders.rb +1 -1
- data/db/migrate/20101026184808_migrate_checkout_to_orders.rb +2 -2
- data/db/migrate/20101223215658_add_position_to_variants.rb +9 -0
- data/db/migrate/20110110130847_add_next_state_to_state_events.rb +9 -0
- data/db/migrate/20110111122537_add_position_to_option_types.rb +9 -0
- data/db/migrate/20110314192118_remove_trailing_slashes_in_taxon_permalinks.rb +17 -0
- data/lib/custom_fixtures.rb +1 -1
- data/lib/{seo_assist.rb → middleware/seo_assist.rb} +14 -8
- data/lib/product_filters.rb +49 -43
- data/lib/redirect_legacy_product_url.rb +5 -5
- data/lib/scopes.rb +2 -2
- data/lib/scopes/dynamic.rb +9 -16
- data/lib/scopes/product.rb +33 -16
- data/lib/scopes/variant.rb +4 -3
- data/lib/spree/calculated_adjustments.rb +5 -2
- data/lib/spree/config.rb +2 -0
- data/lib/spree/current_order.rb +4 -4
- data/lib/spree/mail_settings.rb +3 -2
- data/lib/spree/search/base.rb +9 -10
- data/lib/spree_base.rb +22 -23
- data/lib/spree_core.rb +10 -69
- data/lib/spree_core/authorize_net_cim_hack.rb +1 -1
- data/lib/spree_core/delegate_belongs_to.rb +18 -24
- data/lib/spree_core/enumerable_constants.rb +38 -38
- data/lib/spree_core/find_by_param.rb +8 -6
- data/lib/spree_core/preferences/preference_definition.rb +7 -7
- data/lib/spree_core/railtie.rb +58 -0
- data/lib/spree_core/ssl_requirement.rb +4 -3
- data/lib/spree_core/testing_support/factories.rb +13 -0
- data/lib/spree_core/testing_support/factories/address_factory.rb +20 -0
- data/lib/spree_core/testing_support/factories/adjustment_factory.rb +6 -0
- data/lib/spree_core/testing_support/factories/calculator_factory.rb +5 -0
- data/lib/spree_core/testing_support/factories/configuraion_factory.rb +4 -0
- data/lib/spree_core/testing_support/factories/country_factory.rb +7 -0
- data/lib/spree_core/testing_support/factories/creditcard_factory.rb +11 -0
- data/lib/spree_core/testing_support/factories/inventory_unit_factory.rb +7 -0
- data/lib/spree_core/testing_support/factories/line_item_factory.rb +8 -0
- data/lib/spree_core/testing_support/factories/mail_method_factory.rb +4 -0
- data/lib/spree_core/testing_support/factories/options_factory.rb +10 -0
- data/lib/spree_core/testing_support/factories/order_factory.rb +18 -0
- data/lib/spree_core/testing_support/factories/payment_factory.rb +26 -0
- data/lib/spree_core/testing_support/factories/payment_method_factory.rb +17 -0
- data/lib/spree_core/testing_support/factories/product_factory.rb +16 -0
- data/lib/spree_core/testing_support/factories/product_group_factory.rb +3 -0
- data/lib/spree_core/testing_support/factories/product_option_type_factory.rb +4 -0
- data/lib/spree_core/testing_support/factories/product_property_factory.rb +4 -0
- data/lib/spree_core/testing_support/factories/product_scope_factory.rb +6 -0
- data/lib/spree_core/testing_support/factories/property_factory.rb +4 -0
- data/lib/spree_core/testing_support/factories/prototype_factory.rb +4 -0
- data/lib/spree_core/testing_support/factories/return_authorization_factory.rb +8 -0
- data/lib/spree_core/testing_support/factories/role_factory.rb +9 -0
- data/lib/spree_core/testing_support/factories/shipment_factory.rb +9 -0
- data/lib/spree_core/testing_support/factories/shipping_category_factory.rb +5 -0
- data/lib/spree_core/testing_support/factories/shipping_method_factory.rb +7 -0
- data/lib/spree_core/testing_support/factories/state_factory.rb +11 -0
- data/lib/spree_core/testing_support/factories/tax_category_factory.rb +8 -0
- data/lib/spree_core/testing_support/factories/tax_rate_factory.rb +5 -0
- data/lib/spree_core/testing_support/factories/taxon_factory.rb +5 -0
- data/lib/spree_core/testing_support/factories/taxonomy_factory.rb +3 -0
- data/lib/spree_core/testing_support/factories/tracker_factory.rb +5 -0
- data/lib/spree_core/testing_support/factories/user_factory.rb +15 -0
- data/lib/spree_core/testing_support/factories/variant_factory.rb +14 -0
- data/lib/spree_core/testing_support/factories/zone_factory.rb +18 -0
- data/lib/spree_core/theme_support/hook.rb +1 -1
- data/lib/spree_core/theme_support/more_patches.rb +20 -20
- data/lib/spree_core/version.rb +5 -0
- data/lib/tasks/common.rb +30 -0
- data/lib/tasks/install.rake +1 -1
- data/lib/tasks/rake_util.rb +19 -0
- data/lib/tasks/taxon.rake +14 -0
- data/public/images/reorder.jpg +0 -0
- data/public/javascripts/admin.js +0 -6
- data/public/javascripts/admin/unobtrusive_handlers.js +28 -0
- data/public/javascripts/checkout.js +3 -3
- data/public/stylesheets/admin/admin-forms.css +1 -6
- data/public/stylesheets/admin/admin.css +0 -28
- data/public/stylesheets/screen.css +0 -280
- metadata +81 -43
- data/app/controllers/countries_controller.rb +0 -11
- data/app/models/spree/alert.rb +0 -13
- data/app/models/state_monitor.rb +0 -25
- data/app/views/admin/shared/_alert.html.erb +0 -6
- data/app/views/countries/index.js.erb +0 -1
- data/app/views/shared/_doc_and_xmlns.html.erb +0 -2
- data/app/views/users/edit.html.erb +0 -9
- data/app/views/users/show.html.erb +0 -46
- data/lib/spree_core/validation_group.rb +0 -143
- data/public/stylesheets/scaffold.css +0 -54
@@ -0,0 +1,18 @@
|
|
1
|
+
Factory.define(:order) do |record|
|
2
|
+
# associations:
|
3
|
+
record.association(:user, :factory => :user)
|
4
|
+
record.association(:bill_address, :factory => :address)
|
5
|
+
record.completed_at nil
|
6
|
+
record.bill_address_id nil
|
7
|
+
record.ship_address_id nil
|
8
|
+
end
|
9
|
+
|
10
|
+
Factory.define :order_with_totals, :parent => :order do |f|
|
11
|
+
f.after_create { |order| Factory(:line_item, :order => order) }
|
12
|
+
end
|
13
|
+
|
14
|
+
Factory.define :order_with_inventory_unit_shipped, :parent => :order do |f|
|
15
|
+
f.after_create do |order|
|
16
|
+
Factory(:inventory_unit, :order => order, :state => 'shipped')
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
Factory.define :payment do |f|
|
2
|
+
f.amount 45.75
|
3
|
+
f.payment_method { Factory(:bogus_payment_method) }
|
4
|
+
f.source { Factory.build(:creditcard) }
|
5
|
+
f.order { Factory(:order) }
|
6
|
+
f.state 'pending'
|
7
|
+
f.response_code '12345'
|
8
|
+
|
9
|
+
# limit the payment amount to order's remaining balance, to avoid over-pay exceptions
|
10
|
+
f.after_create do |pmt|
|
11
|
+
#pmt.update_attribute(:amount, [pmt.amount, pmt.order.outstanding_balance].min)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
# Factory.define :creditcard_txn do |f|
|
16
|
+
# f.association :payment
|
17
|
+
# f.amount 45.75
|
18
|
+
# f.response_code 12345
|
19
|
+
# f.txn_type CreditcardTxn::TxnType::AUTHORIZE
|
20
|
+
#
|
21
|
+
# # match the payment amount to the payment's value
|
22
|
+
# f.after_create do |txn|
|
23
|
+
# # txn.update_attribute(:amount, [txn.amount, txn.payment.payment].min)
|
24
|
+
# txn.update_attribute(:amount, txn.payment.amount)
|
25
|
+
# end
|
26
|
+
# end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
Factory.define :payment_method, :class => 'PaymentMethod::Check' do |f|
|
2
|
+
f.name 'Check'
|
3
|
+
f.environment 'cucumber'
|
4
|
+
#f.display_on :front_end
|
5
|
+
end
|
6
|
+
|
7
|
+
Factory.define :bogus_payment_method, :class => Gateway::Bogus do |f|
|
8
|
+
f.name 'Credit Card'
|
9
|
+
f.environment 'cucumber'
|
10
|
+
#f.display_on :front_end
|
11
|
+
end
|
12
|
+
|
13
|
+
Factory.define :authorize_net_payment_method, :class => Gateway::AuthorizeNet do |f|
|
14
|
+
f.name 'Credit Card'
|
15
|
+
f.environment 'cucumber'
|
16
|
+
#f.display_on :front_end
|
17
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
Factory.sequence(:product_sequence) {|n| "Product ##{n} - #{rand(9999)}"}
|
2
|
+
|
3
|
+
Factory.define :product do |f|
|
4
|
+
f.name { Factory.next(:product_sequence) }
|
5
|
+
f.description { Faker::Lorem.paragraphs(rand(5)+1).join("\n") }
|
6
|
+
|
7
|
+
# associations:
|
8
|
+
f.tax_category {|r| TaxCategory.find(:first) || r.association(:tax_category)}
|
9
|
+
f.shipping_category {|r| ShippingCategory.find(:first) || r.association(:shipping_category)}
|
10
|
+
|
11
|
+
f.price 19.99
|
12
|
+
f.cost_price 17.00
|
13
|
+
f.sku "ABC"
|
14
|
+
f.available_on { 1.year.ago }
|
15
|
+
f.deleted_at nil
|
16
|
+
end
|
@@ -0,0 +1,7 @@
|
|
1
|
+
Factory.define :shipping_method do |f|
|
2
|
+
f.zone {|a| Zone.find_by_name("GlobalZone") || a.association(:global_zone) }
|
3
|
+
f.name 'UPS Ground'
|
4
|
+
#f.display_on :back_end
|
5
|
+
f.after_create {|shipping_method| shipping_method.calculator = Factory(:calculator,
|
6
|
+
:calculable => shipping_method) }
|
7
|
+
end
|
@@ -0,0 +1,8 @@
|
|
1
|
+
Factory.sequence(:tax_category_sequence) {|n| "TaxCategory ##{n}"}
|
2
|
+
|
3
|
+
Factory.define(:tax_category) do |record|
|
4
|
+
record.name { "TaxCategory - #{rand(999999)}" }
|
5
|
+
record.description { Faker::Lorem.sentence }
|
6
|
+
|
7
|
+
record.tax_rates {[TaxRate.new(:amount => 0.05, :calculator => Calculator::Vat.new, :zone => Zone.global)]}
|
8
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
unless Factory.factories.keys.include?(:user)
|
2
|
+
Factory.define(:user) do |f|
|
3
|
+
f.email { Faker::Internet.email }
|
4
|
+
f.password "spree123"
|
5
|
+
f.password_confirmation "spree123"
|
6
|
+
end
|
7
|
+
end
|
8
|
+
|
9
|
+
Factory.define(:admin_user, :parent => :user) do |u|
|
10
|
+
u.roles { [Role.find_by_name("admin") || Factory(:role, :name => "admin")]}
|
11
|
+
end
|
12
|
+
|
13
|
+
Factory.sequence :login do |n|
|
14
|
+
Faker::Internet.user_name + n.to_s
|
15
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
Factory.define(:variant) do |f|
|
2
|
+
f.price 19.99
|
3
|
+
f.cost_price 17.00
|
4
|
+
f.sku { Faker::Lorem.sentence }
|
5
|
+
f.weight { BigDecimal.new("#{rand(200)}.#{rand(99)}") }
|
6
|
+
f.height { BigDecimal.new("#{rand(200)}.#{rand(99)}") }
|
7
|
+
f.width { BigDecimal.new("#{rand(200)}.#{rand(99)}") }
|
8
|
+
f.depth { BigDecimal.new("#{rand(200)}.#{rand(99)}") }
|
9
|
+
|
10
|
+
# associations:
|
11
|
+
f.product { |p| p.association(:product) }
|
12
|
+
f.option_values { [Factory(:option_value)] }
|
13
|
+
end
|
14
|
+
|
@@ -0,0 +1,18 @@
|
|
1
|
+
Factory.sequence(:zone_sequence) {|n| "Zone ##{n}"}
|
2
|
+
|
3
|
+
Factory.define(:global_zone, :class => Zone) do |record|
|
4
|
+
record.name "GlobalZone"
|
5
|
+
record.description { Faker::Lorem.sentence }
|
6
|
+
record.zone_members {|proxy|
|
7
|
+
zone = proxy.instance_eval{@instance}
|
8
|
+
Country.find(:all).map{|c| ZoneMember.create({:zoneable => c, :zone => zone})}
|
9
|
+
}
|
10
|
+
end
|
11
|
+
|
12
|
+
Factory.define(:zone) do |f|
|
13
|
+
f.name { Faker::Lorem.words }
|
14
|
+
f.description { Faker::Lorem.sentence }
|
15
|
+
f.zone_members do |member|
|
16
|
+
[ZoneMember.create(:zoneable => Factory(:country) )]
|
17
|
+
end
|
18
|
+
end
|
@@ -36,7 +36,7 @@ module Spree
|
|
36
36
|
def render_hook(hook_name, content, context, locals = {})
|
37
37
|
modifiers_for_hook(hook_name).inject(content) { |result, modifier| modifier.apply_to(result, context, locals) }
|
38
38
|
end
|
39
|
-
|
39
|
+
|
40
40
|
# All the HookModifier instances that are associated with this hook_name in extension load order and order they were defined
|
41
41
|
def modifiers_for_hook(hook_name)
|
42
42
|
@@hook_modifiers[hook_name] ||= listeners.map {|l| l.modifiers_for_hook(hook_name)}.flatten
|
@@ -7,16 +7,16 @@
|
|
7
7
|
|
8
8
|
#RAILS3 TODO - deal with extension load path and whether or not we even need the More stuff
|
9
9
|
# class Less::More
|
10
|
-
#
|
10
|
+
#
|
11
11
|
# class << self
|
12
|
-
#
|
12
|
+
#
|
13
13
|
# def source_paths
|
14
14
|
# @source_paths || [source_path]
|
15
15
|
# end
|
16
16
|
# def source_paths=(paths_array)
|
17
17
|
# @source_paths = paths_array.map{|p| Pathname.new(p.to_s)}
|
18
18
|
# end
|
19
|
-
#
|
19
|
+
#
|
20
20
|
# # Override because this method would only generate if .css file didnt exist for path_as_array
|
21
21
|
# # and we want to force re-compilation of a less file, overwriting css
|
22
22
|
# def generate(path_as_array)
|
@@ -28,7 +28,7 @@
|
|
28
28
|
# end
|
29
29
|
# css
|
30
30
|
# end
|
31
|
-
#
|
31
|
+
#
|
32
32
|
# def generate_css(source)
|
33
33
|
# engine = File.open(source) {|f| Less::Engine.new(f) }
|
34
34
|
# css = engine.to_css
|
@@ -36,15 +36,15 @@
|
|
36
36
|
# css = (HEADER % [source.to_s]) << css if self.header?
|
37
37
|
# css
|
38
38
|
# end
|
39
|
-
#
|
40
|
-
#
|
39
|
+
#
|
40
|
+
#
|
41
41
|
# # If .less file, compile CSS for same directory as a cache
|
42
42
|
# def compile(path_as_array)
|
43
43
|
# source = pathname_from_filename(path_as_array.to_s + '.less')
|
44
44
|
# return if source.nil?
|
45
45
|
# unless source.extname == ".css"
|
46
46
|
# destination = Pathname.new(source.to_s.gsub(/.less$/, '.css'))
|
47
|
-
#
|
47
|
+
#
|
48
48
|
# if !File.exists?(destination) || source.mtime > destination.mtime
|
49
49
|
# css = Less::More.generate_css(source)
|
50
50
|
# if page_cache?
|
@@ -55,8 +55,8 @@
|
|
55
55
|
# end
|
56
56
|
# end
|
57
57
|
# end
|
58
|
-
#
|
59
|
-
#
|
58
|
+
#
|
59
|
+
#
|
60
60
|
# # Array of Pathname instances for all the less source files.
|
61
61
|
# def all_less_files
|
62
62
|
# #Dir[Less::More.source_path.join("**", "*.{css,less,lss}")].map! {|f| Pathname.new(f) }
|
@@ -64,12 +64,12 @@
|
|
64
64
|
# all_less_files_in_path(pathname)
|
65
65
|
# end.flatten
|
66
66
|
# end
|
67
|
-
#
|
67
|
+
#
|
68
68
|
# def all_less_files_in_path(pathname)
|
69
69
|
# Dir[pathname.join("**", "*.{css,less,lss}").to_s].map! {|f| Pathname.new(f) }
|
70
70
|
# end
|
71
|
-
#
|
72
|
-
#
|
71
|
+
#
|
72
|
+
#
|
73
73
|
# # Generates all the .css files.
|
74
74
|
# # Override to iterate through all source paths
|
75
75
|
# def parse
|
@@ -79,22 +79,22 @@
|
|
79
79
|
# relative_path = path.relative_path_from(source_path)
|
80
80
|
# path_as_array = relative_path.to_s.split(File::SEPARATOR)
|
81
81
|
# path_as_array[-1] = File.basename(path_as_array[-1], File.extname(path_as_array[-1]))
|
82
|
-
#
|
82
|
+
#
|
83
83
|
# # Generate CSS
|
84
84
|
# css = Less::More.generate(path_as_array)
|
85
|
-
#
|
85
|
+
#
|
86
86
|
# # Store CSS
|
87
87
|
# path_as_array[-1] = path_as_array[-1] + ".css"
|
88
88
|
# destination = Pathname.new(Rails.root.join("public", Less::More.destination_path)).join(*path_as_array)
|
89
89
|
# destination.dirname.mkpath
|
90
|
-
#
|
90
|
+
#
|
91
91
|
# File.open(destination, "w") {|f|
|
92
92
|
# f.puts css
|
93
93
|
# }
|
94
94
|
# end
|
95
95
|
# end
|
96
96
|
# end
|
97
|
-
#
|
97
|
+
#
|
98
98
|
# # Override to look in each of the source paths. Return pathname for first source path that contains this file
|
99
99
|
# def pathname_from_array(array)
|
100
100
|
# path_spec = array.dup
|
@@ -103,16 +103,16 @@
|
|
103
103
|
# Pathname.glob(File.join(source_path.to_s, *path_spec))[0]
|
104
104
|
# end.compact.first
|
105
105
|
# end
|
106
|
-
#
|
106
|
+
#
|
107
107
|
# # Find pathname for specific filename in each of the source paths
|
108
108
|
# def pathname_from_filename(filename)
|
109
109
|
# self.source_paths.map do |source_path|
|
110
110
|
# Pathname.glob(File.join(source_path.to_s, filename))[0]
|
111
111
|
# end.compact.first
|
112
112
|
# end
|
113
|
-
#
|
113
|
+
#
|
114
114
|
# end
|
115
|
-
#
|
115
|
+
#
|
116
116
|
# end
|
117
|
-
#
|
117
|
+
#
|
118
118
|
# $LESS_LOAD_PATH = Less::More.source_paths = Spree::ExtensionLoader.stylesheet_source_paths.reverse
|
data/lib/tasks/common.rb
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
require File.expand_path('../rake_util', __FILE__)
|
2
|
+
|
3
|
+
gemfile = File.expand_path('../spec/test_app/Gemfile', ENV['SPREE_GEM_PATH'])
|
4
|
+
if File.exists?(gemfile) && (%w(spec cucumber).include?(ARGV.first.to_s) || ARGV.size == 0)
|
5
|
+
require 'bundler'
|
6
|
+
ENV['BUNDLE_GEMFILE'] = gemfile
|
7
|
+
Bundler.setup
|
8
|
+
|
9
|
+
require 'rspec/core/rake_task'
|
10
|
+
RSpec::Core::RakeTask.new
|
11
|
+
|
12
|
+
require 'cucumber/rake/task'
|
13
|
+
Cucumber::Rake::Task.new do |t|
|
14
|
+
t.cucumber_opts = %w{--format pretty}
|
15
|
+
end
|
16
|
+
|
17
|
+
desc "Run specs with RCov"
|
18
|
+
RSpec::Core::RakeTask.new(:rcov) do |t|
|
19
|
+
t.rcov = true
|
20
|
+
t.rcov_opts = %w{ --exclude gems\/,spec\/,features\/}
|
21
|
+
t.verbose = true
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
namespace :test_app do
|
26
|
+
desc 'Rebuild test and cucumber databases'
|
27
|
+
task :rebuild_dbs do
|
28
|
+
system("cd spec/test_app && rake db:drop db:migrate RAILS_ENV=test && rake db:drop db:migrate RAILS_ENV=cucumber")
|
29
|
+
end
|
30
|
+
end
|