Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
238 commits
Select commit Hold shift + click to select a range
6279f07
Bump to 2.2.3.beta
radar May 15, 2014
7b4e359
Set CreditCard#confirmation_value when reusing cards
huoxito May 19, 2014
f568c90
Add I18n.locale for views cache
BGuimberteau May 13, 2014
9a35abb
Fix FA class for picture
davekiss May 19, 2014
873a2eb
fix typo in data-hook.
peterberkenbosch May 21, 2014
69ffd46
Add data-hooks to admin/products/new and admin/products/_form
brchristian May 13, 2014
28ddee2
use fa-check since fa-ok is no longer available.
peterberkenbosch May 21, 2014
ba5cbb7
updated ga snippet
BrianTheCoder Apr 11, 2014
25ef0af
Always pass currency to Spree::Money for multi-currency.
May 22, 2014
bcee71d
Need to only try specifying currency in case order doesnt exist yet.
May 22, 2014
05b930a
Update Rails Version in README.md
buck3000 May 22, 2014
8df72b9
make sure we only build the year when it's there. Validtion error oth…
peterberkenbosch May 22, 2014
bae24e9
Reorder short circuit evaluation of Estimator#shipping_methods
Senjai May 22, 2014
79e24ff
Changing currency variable according to google analytics docs
tiagoamaro May 26, 2014
726b3db
add configurable option to clone products without copying original im…
May 27, 2014
f4ef9c5
Loosen friendly_id restriction.
May 29, 2014
4f3ac57
Fix recalculating included tax adjustments. Fixes spree/spree#4671
May 29, 2014
c84e2d5
Fix html safe when cart is empty
ddomingues May 30, 2014
2f56faa
Use the payments currency rather than config for multi-currency.
May 31, 2014
a5a5178
Added data-hooks where values were empty and fixed some repeated ids.
richardnuno May 30, 2014
9a92428
Fix broken cache on api/orders
huoxito Jun 1, 2014
fe4b981
Populate Order#shipment_total for users upgrading
huoxito Jun 1, 2014
ad1d11f
Fall back to name on CreditCard#to_active_merchant
huoxito May 27, 2014
437707a
handle credit card names with spaces
jordan-brough Jun 2, 2014
d20c54a
Fixes entering localized amounts for payments
Daan- May 30, 2014
39c06b8
Add top level rake task to run all tests
Jun 3, 2014
71f50a8
remove reference to shipment.adjustment
Jun 2, 2014
92e3fa7
Add spec for overriding order token
huoxito Jun 6, 2014
86b7b4f
check_authorization should use params token first
wuboy0307 Jun 4, 2014
d55dafe
Refactor stock transfers variant select JS - Allow user to search for…
LBRapid Jun 5, 2014
743b98b
update the default email template to include all the proper taxes, sh…
peterberkenbosch Jun 6, 2014
75775c2
Update payment risk assessment, and fix broken specs. Fixes spree/spr…
Jun 6, 2014
ac01ce1
Ensure shipments are also destroyed when the order is emptied.
Senjai Jun 6, 2014
3682622
Payments with a cvv_response_message are not necessarily risky.
Jun 9, 2014
46698f1
Remove defunkt spec that's no longer true.
Jun 10, 2014
4ae9d6a
Use permitted_option_value_attributes instead of permitted_option_typ…
iwano Jun 3, 2014
a75af02
[api] Ensure order ids are ordered in orders_controller_spec
radar Jun 10, 2014
38611fb
Include sample in top level rake test and test_app
jhawthorn Jun 10, 2014
b1b19fa
Fixes an issue where entering 30.49 would preauthorize 3049$.
Jan 27, 2014
ee79c55
Pagination and search in property list
Willianvdv Feb 25, 2014
3efe643
make sure we fail fast and exit when a spec fails
peterberkenbosch Jun 11, 2014
763331e
Javascript fixes for IE8.
Jun 12, 2014
3027233
Update backends adjustments controller to fix order.update! call.
Jun 13, 2014
7232ca9
Fixes receiving RMA's when inventory tracking is turned off.
Jun 13, 2014
6cd7827
Fix broken spec.
Jun 13, 2014
1f289b2
Dont destroy all order payments in api/checkouts
huoxito Jun 14, 2014
b3cda2c
Improving performance of migration add_line_item_id_to_spree_inventor…
brchristian Jun 14, 2014
4ca432c
Adding data-hooks to search results header
brchristian Jun 14, 2014
5ce1fe3
Fixes Zone #contains? n+1 query performance.
mtomov Jun 17, 2014
13ac43f
fix permalink handling to force uniqueueness and rename on product de…
Jun 9, 2014
58b8008
Make migration more tolerant of deleted Variants
brchristian Jun 14, 2014
0c108c0
Don't assume default variant in JS. Let this be controlled by HTML ma…
shopjoy Jun 22, 2014
50550cb
Downcasing locale for jquery.validate i18n messages
tiagoamaro Jun 25, 2014
88101a2
Set extract first and last name from CreditCard#name
huoxito Jun 28, 2014
e5579f7
Fix pagination for taxons
frankiek3 Jun 25, 2014
7d8b6b9
Bump Rails to 4.0.6
radar Jul 1, 2014
61eefa3
Bump to 2.2.3
radar Jul 1, 2014
b94b175
Bump to 2.2.4.beta
radar Jul 1, 2014
4cb3271
Fix typo in add_line_item_id_to_spree_inventory_units migration
radar Jul 1, 2014
9e2a218
Bump to 2.2.4
radar Jul 1, 2014
55c8908
Bump to 2.2.5.beta
radar Jul 1, 2014
9f54ea9
Clean changelogs
radar Jul 1, 2014
b9b6c47
Add Jersey to the default list of countries
oguzcanhuner Jun 30, 2014
6f72148
Lock jquery-rails to 3.1.0 as 3.1.1 breaks data-confirm.
Jul 1, 2014
07b9598
make incl/excl in ShippingRate#display_price translatable
valpackett Jul 1, 2014
7e5dcc7
make click_and_drag_on_the_products_to_sort_them in spree/admin/taxon…
valpackett Jul 1, 2014
4238727
Only destroy tax adjustment for open order when the associated tax ra…
ifan-godaddy Jun 16, 2014
043990a
Merge pull request spree/spree#4900 from reinaris/patch-3
huoxito Jul 6, 2014
b63d190
Update shipment in proper chronological order
huoxito Jun 29, 2014
91d10a3
When creating shipment assign orders shipping address.
Jul 7, 2014
aa2bb67
Payment methods should be scoped to available.
Jul 8, 2014
976e0b1
Bump to Rails 4.0.8
radar Jul 3, 2014
cc6aae7
Added without_children = true in taxon autocomplete API Call
Jul 2, 2014
716af5f
Optimize available_countries
jhawthorn Jul 2, 2014
a30d82c
Add blank to ShippingMethod's TaxCategory select
brchristian Jul 10, 2014
9c3673a
[api] Convert payment_method_id to string in CheckoutsController
radar Jul 10, 2014
1a057e1
[api] Do not wrap parameters in OrdersController
radar Jul 10, 2014
454d38f
Fix typo in Spree::ReturnAuthorization model
Jul 10, 2014
d32b4a8
Destroy asocaited adjustments when order is changed to move out of ta…
ifan-godaddy Jun 18, 2014
be50f5c
Allow token-based payment sources in Payment::Processing
radar Jul 10, 2014
bb5844b
Avoid name clashing when including modules
Jun 20, 2014
a4bcc77
Merge pull request spree/spree#4923 from jordan-brough/fix-order-reload
huoxito Jul 11, 2014
97354f8
Move set_shipments_cost call to Order#update_from_params
radar Jul 2, 2014
ba6e76e
Shipment cost is now included in spec totals.
Jul 15, 2014
60fefba
Revert "Add pry and pry debuggers to common spree dependencies"
huoxito Jul 13, 2014
fd17f71
Use prepend_before_filter to try calling before apply_coupon_code. re…
Jul 16, 2014
5172e58
Added missing translation for back_to_shipping_categories_list
Jul 16, 2014
93ba97e
Do not blindly accept just any month for CreditCard expiry
radar Jul 17, 2014
3741e94
Silence two warnings
jordan-brough Jul 15, 2014
f4676d2
Revert "Use prepend_before_filter to try calling before apply_coupon_…
Jul 17, 2014
ed3fa55
Improvements to API performance.
BMorearty Jul 17, 2014
7a499c8
More code coverage.
BMorearty Jul 17, 2014
bbb7dc1
Reduce the number of cascading touches.
BMorearty Jul 17, 2014
67c5165
Fix simple_current_order to not conflict with order.
Jul 18, 2014
30f4936
make unique SKU for sample data
peterberkenbosch Jul 19, 2014
f792ef2
Order history should be reverse chronological. Fixes spree/spree#5024
magnusvk Jul 21, 2014
084500d
Use the proper flash
Jul 22, 2014
037f05d
use the variant_full_price on the product show page so the correct cu…
peterberkenbosch Jul 24, 2014
3a6e682
Reduce unnecessary DB round-trips.
BMorearty Jul 24, 2014
0a86ca7
fix failing specs with variant price
peterberkenbosch Jul 25, 2014
50b4b08
refactor the variant price for product.js.coffee. Thanks gmacdougall
peterberkenbosch Jul 25, 2014
49ad1da
Wait ajax request a bit for backend spec fix
huoxito Jul 23, 2014
ed7e474
Validate uniqueness of order numbers... Why was this FIXME never fixe…
Aug 1, 2014
4a320d4
changed generate_order_number method for insure that generated number…
sanchojaf Aug 1, 2014
1fecd29
Fix broken specs from order number refactoring, and improve performan…
Aug 1, 2014
3775888
Fix payment state in order importer. Fixes spree/spree#5109
Aug 1, 2014
9d829c8
Use rand(10) to cover all digits 0-9. Fixes spree/spree#5113
Aug 2, 2014
4a897a0
Calculate tax total correctly which depends on the item that could be…
ifan-godaddy Jun 13, 2014
09cc3fa
Speed up rename_adjustment_fields migration
brchristian Aug 4, 2014
b7e0af7
Make Shipment.cost default to 0
brchristian Aug 4, 2014
0b4ea1d
Dont advance order state when adding an item to cart
huoxito May 4, 2014
c37877b
Update Google Analytics
ymek Jul 24, 2014
a47b10d
Allow assigning shipped_at to shipments.
Aug 5, 2014
eac78b7
Merge pull request spree/spree#5101 from themetric/fix-api-custom-tem…
huoxito Aug 6, 2014
f1d7073
add validation to verify that count_on_hand of backorderable should n…
Oct 2, 2013
8b4d277
add a before_transition to verify if order is resumed only if there a…
Oct 3, 2013
f8479a8
Fix conflict.
Aug 6, 2014
4b00740
Reload to make sure shipment.inventory_units have the latest status s…
ifan-godaddy Aug 7, 2014
079db37
Fix line item proper currency check
huoxito Jul 11, 2014
e0c1875
Fix shipment persistence on order importer
huoxito Aug 3, 2014
8633da2
Test to see if a better coupon exists already
Jun 4, 2014
63ee863
Revert "Fix Spree::Promotion not applying all of the time."
Aug 8, 2014
77936cf
Use rspec-retry to get past random phantomjs failures (turn off by de…
ifan-godaddy Aug 9, 2014
e8a76df
Create tax adjustment label with inclusive information if applicable
ifan-godaddy Aug 19, 2014
a2138d5
Change order updater to refresh shipment rates and amounts on change
dkubb Aug 19, 2014
9c21a1a
Finally fixes last backend spec.
Aug 22, 2014
8cd9492
Fix using check payment method in admin.
Aug 27, 2014
4e2b5e3
Add state_text to StockLocation
brchristian Jun 26, 2014
3cc6bc3
Bump version.
Aug 29, 2014
f095626
Bump for next beta.
Aug 29, 2014
56065a0
Fix item_adjustment_spec.rb
deodad Sep 4, 2014
8858f26
Allow partial emails when searching for orders
bbuchalter Sep 3, 2014
70e22dc
addi18n to prom index
Paveltarno Sep 8, 2014
dab9287
Update jquery dep. refs spree/spree#3203
Sep 9, 2014
94e35a7
RSpec 3.1 support & Fix a couple Rails 4.0.10 regressions.
Sep 11, 2014
afca15d
Use email regex from Devise. Fixes spree/spree#5368
Sep 16, 2014
61bb3d9
Implemented fix for duplicate addresses being created in checkout
ericsaupe Sep 16, 2014
792481f
Added failed state to the admin variables
reinaris Sep 17, 2014
3450bb4
Fix variable css.
Sep 17, 2014
ea481a6
add select2 call after loading new images
BenMorganIO Sep 18, 2014
6eefeed
we fixed mail validator.
Sep 19, 2014
36e802b
change precision for amount to 10
May 9, 2014
136a54d
Bump version.
Sep 19, 2014
c16e041
bump next beta
Sep 19, 2014
b65ceaa
Close a table in variant autocomplete
reinaris Sep 22, 2014
ad0f658
Show line items for orders that have not advanced to delivery state yet.
Sep 24, 2014
ed128eb
Dont let order import fail silently on bad line items.
Sep 25, 2014
a815f76
Fix my mistakes from 933c773a234048b72fbd7cb4fccce8810ec55c83 :(
Sep 25, 2014
35419ca
fix user address default user spec.
peterberkenbosch Sep 26, 2014
a2f1834
add more logic to outstancing balance and order updater to set the co…
peterberkenbosch Aug 11, 2014
88663a6
Touch Adjustment#adjustable, and fix some rspec deprecations.
Sep 26, 2014
534bf0d
Standardizing use of colons in checkout summary
brchristian Sep 25, 2014
5620a1d
User store location when signing in
marcosteixeira Sep 25, 2014
3028967
Fix specs broken by 09ccf8a
Sep 30, 2014
f160bf2
refactoing code to call find_adjustment in before_action rather than …
Sep 28, 2014
7774ba4
Fix db:bootstrap task
hnatt Sep 24, 2014
0f3f266
Regression spec for 'stack level too deep' spree/spree#5384
andrzejpolis Sep 19, 2014
6a43638
Add in fix from andrzejpolis Fixes spree/spree#5384 Fixes spree/spree…
Oct 3, 2014
95ea9f0
create proposed shipments if is no shippment data
peterberkenbosch Oct 6, 2014
3a7e296
Fix example to contain expectation
mbj Oct 6, 2014
68ba38a
allow guests to use the payments api for their orders
pdamer Oct 6, 2014
6e1a6bf
Improve localization of stock_locations/_form
hnatt Oct 7, 2014
c845fa0
Fix broken rspec.
ifan-godaddy Oct 8, 2014
b2cdc06
Remove 'disabled' from inputs in payments
ericsaupe Oct 8, 2014
fca9d78
Ignore guides.
Oct 8, 2014
22b3f2d
Make best-promotion query more deterministic
jordan-brough Jul 9, 2014
e67f5c0
Fix running just rake for specs.
Oct 9, 2014
a9a1aaf
Fix rerunning sample specs without new dummy app.
Oct 9, 2014
41e1abe
Check payment method should respond to cancel. Fixes spree/spree#5307
Oct 10, 2014
9c2e755
Improve the presentation during creating prototypes. Fixes spree/spre…
Oct 10, 2014
1e6a1e3
Use slower but robust ActiveRecord for migration
brchristian Jun 14, 2014
02e6063
No need for partial. Fixes spree/spree#5475
Oct 13, 2014
c798130
Looking up stock location by the admin name as well
alexstoick Oct 14, 2014
f066437
Add spec for looking up stock location by admin name.
Oct 14, 2014
fc772b3
Do not allow leading or trailing dot(.) in the first part of email ad…
ifan-godaddy Oct 14, 2014
bb9af4e
Add inverse_of for more associations involved in cart processing
dkubb Mar 24, 2014
bccc780
remove extra dependent destroy
Oct 16, 2014
73b1513
Fix timecop spec.
Oct 16, 2014
34ba024
Fixes messaging after applying coupon code promo with CreateLineItems…
Oct 20, 2014
a0fabb5
Refactor Spree::ProductHelper#variant_price_diff
dkubb Nov 13, 2013
3dcd551
Add required attributes to required product admin form fields
dkubb Jul 30, 2014
9f12514
make bogus gateway match actual gateways. ie. don't assign profile id…
pdamer Oct 17, 2014
5bf39d6
Depend on factory_girl_rails 4.5.0
Oct 20, 2014
dd767e1
We need to be more restrictive with factory girl updates.
Oct 20, 2014
f0d61de
Implement a state lock version to prevent race conditions in checkout…
Oct 21, 2014
8d3d7c4
fix specs
Oct 22, 2014
96034be
include option values when loading option values from option types
BenMorganIO Oct 22, 2014
16f70be
Refactor the duplicate request prevention code ( order.with_lock )
DangerDawson Oct 24, 2014
7037b84
Adds editorConfig.
Oct 16, 2014
1ff174f
Add spec for updating version.
Oct 28, 2014
1a73e80
add table name for order/line_item association
kennyadsl Oct 26, 2014
acbe625
refactor code to follow DRY in zone model
Oct 26, 2014
f660d9a
Update generated robots.txt
alepore Oct 26, 2014
6f6903b
Removes redundant closing li
Oct 27, 2014
20910c5
Make email field in admin orders#index link to the customer's account…
Oct 27, 2014
35de32b
Fix optimistic lock to not revert incremented version.
Oct 28, 2014
a103954
Fix pagination in /api/taxons/products
KentoMoriwaki Nov 3, 2014
6d24097
Allow tax categories to be destroyed with proper callback order. Fixe…
Nov 5, 2014
bc78664
Make conditional read nicer.
Nov 7, 2014
350171e
Fix Asset position for different viewables.
mtomov Nov 10, 2014
5439459
Test latest 2.1.5
Nov 14, 2014
278eab4
Give spec correct title.
iangreenleaf Nov 14, 2014
b234e72
set the order#payment_state to the correct state when order is canceled
peterberkenbosch Sep 15, 2014
038fd8b
Fix specs and update syntax.
Nov 16, 2014
7cfd857
[backend] Hiding option values handle if object is not persisted
tiagoamaro Nov 16, 2014
978c7c1
Bump rails.
Nov 19, 2014
2a1fea2
Bump version
Nov 20, 2014
c465c61
Bump to beta
Nov 20, 2014
52542bb
Added gif to valid icon types
richardhartme Nov 26, 2014
e5ab60d
Bump version
Dec 5, 2014
e8c1833
Bump to next beta.
Dec 5, 2014
6248ef0
Update i18n.
Dec 5, 2014
a593031
Revert "Update i18n."
Dec 5, 2014
1ffdb79
fix handling of credit cards expiring in current month
pdamer Oct 8, 2014
d426f42
Filter params on api/checkouts_controller#update
huoxito Dec 20, 2014
ab7b826
Lockdown monetize to fix specs for now.
Dec 23, 2014
35f95a4
Update ruble symbol.
Dec 23, 2014
8c354cd
Bump version.
Dec 23, 2014
bcab12d
Next beta.
Dec 23, 2014
cce8839
Require latest monetize.
Dec 23, 2014
77b8b2c
Fix payment sample card for 2015
jhawthorn Jan 2, 2015
e584d6d
Fix expiration year.
Jan 2, 2015
cca244d
Do not trigger full order update when fulfilling a backordered order
ifan-godaddy Dec 30, 2014
cdcd6ba
Fix to payment_spec
allisonlarson Jan 9, 2015
98f1ae5
Fix authorization check. Fixes spree/spree#5624
Jan 13, 2015
c1b01d4
translate hardcoded strings on cc payment form
alepore Jan 14, 2015
e5dd414
JS fix for admin resource destroy success message
MattDunbar Jan 26, 2015
1365215
Fix td element to be within conditional block.
Jan 27, 2015
c83978f
Adjustments upgrade migration should fail on save / destroy fail
MattDunbar Feb 1, 2015
f6ef5f7
Adjustments upgrade migration efficiency improvement.
MattDunbar Jan 30, 2015
74f966e
Remove specs from checkout controller.
Feb 24, 2015
150a934
Revert "Allow payments with invalid sources to be invalidated"
Feb 24, 2015
b51fd37
Revert "Make update_item_count get called inside updater#update"
Feb 24, 2015
36b7110
update_attributes is now update_attributes!
Feb 25, 2015
2ed26f6
Don't pass id in to the API endpoints for address.
Feb 25, 2015
92f77f9
Remove check alerts spec.
Feb 25, 2015
d4c4fa4
2-2-dev fix for ReimbursementMailer
jordan-brough Aug 11, 2014
d410bb2
Add ensure_line_item_in_stock method.
Feb 25, 2015
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# http://EditorConfig.org
# https://github.com/editorconfig/editorconfig/wiki/EditorConfig-Properties

root = true

[*]
charset = utf-8
end_of_line = lf
indent_size = 2
indent_style = space
insert_final_newline = true
trim_trailing_whitespace = true
tab_width = 2

[**.rb]
max_line_length = 80

[**.js, **.coffee]
max_line_length = 120

[*.md]
trim_trailing_whitespace = false
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,4 @@ test_app
**/coverage
*/.sass-cache
.localeapp
guides
4 changes: 1 addition & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,4 @@ script:
- bundle exec rake test_app
- bundle exec rake spec
rvm:
- 1.9.3
- 2.0.0
- 2.1.0
- 2.1.5
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ The fastest way to get started is by using the spree command line tool
available in the spree gem which will add Spree to an existing Rails application.

```shell
gem install rails -v 4.0.4
gem install rails -v 4.0.12
gem install spree
rails _4.0.4_ new my_store
rails _4.0.12_ new my_store
spree install my_store
```

Expand Down Expand Up @@ -293,7 +293,7 @@ bash build.sh

Further Documentation
------------
Spree has a number of really useful guides online at [http://guides.spreecommerce.com](http://guides.spreecommerce.com).
Spree has a number of really useful guides online at [http://guides.spreecommerce.com](http://guides.spreecommerce.com).

Contributing
------------
Expand Down
14 changes: 13 additions & 1 deletion Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,22 @@ Gem::PackageTask.new(spec) do |pkg|
pkg.gem_spec = spec
end

task :default => :test

desc "Runs all tests in all Spree engines"
task :test do
Rake::Task['test_app'].invoke
%w(api backend core frontend).each do |gem_name|
Dir.chdir("#{File.dirname(__FILE__)}/#{gem_name}") do
system("rspec --fail-fast") or exit!(1)
end
end
end

desc "Generates a dummy app for testing for every Spree engine"
task :test_app do
require File.expand_path('../core/lib/generators/spree/install/install_generator', __FILE__)
%w(api backend core frontend).each do |engine|
%w(api backend core frontend sample).each do |engine|
ENV['LIB_NAME'] = File.join('spree', engine)
ENV['DUMMY_PATH'] = File.expand_path("../#{engine}/spec/dummy", __FILE__)
Rake::Task['common:test_app'].execute
Expand Down
2 changes: 1 addition & 1 deletion SPREE_VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.2.2
2.2.10.beta
10 changes: 1 addition & 9 deletions api/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,9 +1 @@
## Spree 2.2.2 (unreleased) ##

* refactor the api to use a general importer in core gem.

* Peter Berkenbosch

* Allow for linking of users to orders by admins

* Ryan Bigg
## Spree 2.2.5 (unreleased) ##
15 changes: 10 additions & 5 deletions api/app/controllers/spree/api/base_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -123,22 +123,27 @@ def find_product(id)
end

def product_scope
variants_associations = [{ option_values: :option_type }, :default_price, :prices, :images]
if current_api_user.has_spree_role?("admin")
scope = Product.with_deleted.accessible_by(current_ability, :read)
.includes(:properties, :option_types, variants: variants_associations, master: variants_associations)
scope = Product.with_deleted.accessible_by(current_ability, :read).includes(*product_includes)

unless params[:show_deleted]
scope = scope.not_deleted
end
else
scope = Product.accessible_by(current_ability, :read).active
.includes(:properties, :option_types, variants: variants_associations, master: variants_associations)
scope = Product.accessible_by(current_ability, :read).active.includes(*product_includes)
end

scope
end

def variants_associations
[{ option_values: :option_type }, :default_price, :images]
end

def product_includes
[ :option_types, variants: variants_associations, master: variants_associations ]
end

def order_id
params[:order_id] || params[:checkout_id] || params[:order_number]
end
Expand Down
46 changes: 46 additions & 0 deletions api/app/controllers/spree/api/checkouts_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,51 @@ def load_order
raise_insufficient_quantity and return if @order.insufficient_stock_lines.present?
end

def object_params
modify_payment_attributes params[:order] || {}

protected_params = if params[:order]
params.require(:order).permit(permitted_checkout_attributes)
else
{}
end

map_nested_attributes_keys Order, protected_params
end

def user_id
params[:order][:user_id] if params[:order]
end

# For payment step, filter order parameters to produce the expected
# nested attributes for a single payment and its source, discarding
# attributes for payment methods other than the one selected
#
# respond_to check is necessary due to issue described in #2910
def modify_payment_attributes(object_params)
if @order.has_checkout_step?('payment') && @order.payment?
if object_params[:payments_attributes].is_a?(Hash)
object_params[:payments_attributes] = [object_params[:payments_attributes]]
end
if object_params[:payment_source].present? && source_params = object_params.delete(:payment_source)[object_params[:payments_attributes].first[:payment_method_id].to_s]
object_params[:payments_attributes].first[:source_attributes] = source_params
end
if object_params[:payments_attributes]
object_params[:payments_attributes].first[:amount] = @order.total.to_s
end
end
end

def nested_params
map_nested_attributes_keys Order, params[:order] || {}
end

# Should be overriden if you have areas of your checkout that don't match
# up to a step within checkout_steps, such as a registration step
def skip_state_validation?
false
end

def update_order_state
@order.state = params[:state] if params[:state]
state_callback(:before)
Expand All @@ -58,6 +103,7 @@ def state_callback(before_or_after = :before)
send(method_name) if respond_to?(method_name, true)
end

# This is used in cancan
def order_id
super || params[:id]
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ class InventoryUnitsController < Spree::Api::BaseController

def show
@inventory_unit = inventory_unit
respond_with(@inventory_unit)
end

def update
Expand Down
4 changes: 2 additions & 2 deletions api/app/controllers/spree/api/option_types_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ module Api
class OptionTypesController < Spree::Api::BaseController
def index
if params[:ids]
@option_types = Spree::OptionType.accessible_by(current_ability, :read).where(:id => params[:ids].split(','))
@option_types = Spree::OptionType.includes(:option_values).accessible_by(current_ability, :read).where(id: params[:ids].split(','))
else
@option_types = Spree::OptionType.accessible_by(current_ability, :read).load.ransack(params[:q]).result
@option_types = Spree::OptionType.includes(:option_values).accessible_by(current_ability, :read).load.ransack(params[:q]).result
end
respond_with(@option_types)
end
Expand Down
2 changes: 1 addition & 1 deletion api/app/controllers/spree/api/option_values_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def scope
end

def option_value_params
params.require(:option_value).permit(permitted_option_type_attributes)
params.require(:option_value).permit(permitted_option_value_attributes)
end
end
end
Expand Down
2 changes: 2 additions & 0 deletions api/app/controllers/spree/api/orders_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ class OrdersController < Spree::Api::BaseController
class_attribute :admin_order_attributes
self.admin_order_attributes = [:import, :number, :completed_at, :locked_at, :channel]

wrap_parameters false

skip_before_filter :check_for_user_or_api_key, only: :apply_coupon_code
skip_before_filter :authenticate_user, only: :apply_coupon_code

Expand Down
2 changes: 1 addition & 1 deletion api/app/controllers/spree/api/payments_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def index
end

def new
@payment_methods = Spree::PaymentMethod.where(environment: Rails.env)
@payment_methods = Spree::PaymentMethod.available
respond_with(@payment_method)
end

Expand Down
2 changes: 2 additions & 0 deletions api/app/controllers/spree/api/products_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,15 @@ def index
@products = @products.distinct.page(params[:page]).per(params[:per_page])
expires_in 15.minutes, :public => true
headers['Surrogate-Control'] = "max-age=#{15.minutes}"
respond_with(@products)
end

def show
@product = find_product(params[:id])
expires_in 15.minutes, :public => true
headers['Surrogate-Control'] = "max-age=#{15.minutes}"
headers['Surrogate-Key'] = "product_id=1"
respond_with(@product)
end

# Takes besides the products attributes either an array of variants or
Expand Down
17 changes: 2 additions & 15 deletions api/app/controllers/spree/api/shipments_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,27 +29,14 @@ def create
@shipment = @order.shipments.create(stock_location_id: params[:stock_location_id])
@order.contents.add(variant, quantity, nil, @shipment)

@shipment.refresh_rates
@shipment.save!

respond_with(@shipment.reload, default_template: :show)
end

def update
unlock = params[:shipment].delete(:unlock)

if unlock == 'yes'
@shipment.adjustment.open
end

@shipment.update_attributes(shipment_params)

if unlock == 'yes'
@shipment.adjustment.close
end

@shipment.reload
respond_with(@shipment, default_template: :show)
@shipment.update_attributes_and_order(shipment_params)
respond_with(@shipment.reload, default_template: :show)
end

def ready
Expand Down
2 changes: 1 addition & 1 deletion api/app/controllers/spree/api/taxons_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ def products
# Products#index does not do the sorting.
taxon = Spree::Taxon.find(params[:id])
@products = taxon.products.ransack(params[:q]).result
@products = @products.page(params[:page]).per(500 || params[:per_page])
@products = @products.page(params[:page]).per(params[:per_page] || 500)
render "spree/api/products/index"
end

Expand Down
2 changes: 1 addition & 1 deletion api/app/views/spree/api/addresses/show.v1.rabl
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
object @address
cache @address
cache [I18n.locale, root_object]
attributes *address_attributes

child(:country) do |address|
Expand Down
4 changes: 2 additions & 2 deletions api/app/views/spree/api/adjustments/show.v1.rabl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
object @adjustment
cache @adjustment
cache [I18n.locale, root_object]
attributes *adjustment_attributes
node(:display_amount) { |a| a.display_amount.to_s }
node(:display_amount) { |a| a.display_amount.to_s }
4 changes: 2 additions & 2 deletions api/app/views/spree/api/credit_cards/show.v1.rabl
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
object @credit_card
cache @credit_card
attributes *creditcard_attributes
cache [I18n.locale, root_object]
attributes *creditcard_attributes
2 changes: 1 addition & 1 deletion api/app/views/spree/api/line_items/show.v1.rabl
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
object @line_item
cache @line_item
cache [I18n.locale, root_object]
attributes *line_item_attributes
node(:single_display_amount) { |li| li.single_display_amount.to_s }
node(:display_amount) { |li| li.display_amount.to_s }
Expand Down
2 changes: 1 addition & 1 deletion api/app/views/spree/api/orders/order.v1.rabl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cache @order
cache [I18n.locale, root_object]
attributes *order_attributes
node(:display_item_total) { |o| o.display_item_total.to_s }
node(:total_quantity) { |o| o.line_items.sum(:quantity) }
Expand Down
2 changes: 1 addition & 1 deletion api/app/views/spree/api/products/show.v1.rabl
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
object @product
cache [current_currency, root_object]
cache [I18n.locale, current_currency, root_object]
attributes *product_attributes
node(:display_price) { |p| p.display_price.to_s }
node(:has_variants) { |p| p.has_variants? }
Expand Down
2 changes: 1 addition & 1 deletion api/app/views/spree/api/shipments/show.v1.rabl
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
object @shipment
cache @shipment
cache [I18n.locale, root_object]
attributes *shipment_attributes
node(:order_id) { |shipment| shipment.order.number }
node(:stock_location_name) { |shipment| shipment.stock_location.name }
Expand Down
2 changes: 1 addition & 1 deletion api/app/views/spree/api/variants/big.v1.rabl
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
object @variant
attributes *variant_attributes

cache ['big_variant', root_object]
cache [I18n.locale, 'big_variant', root_object]

extends "spree/api/variants/small"

Expand Down
2 changes: 1 addition & 1 deletion api/app/views/spree/api/variants/show.v1.rabl
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
object @variant
cache ['show', root_object]
cache [I18n.locale, 'show', root_object]
extends "spree/api/variants/big"
2 changes: 1 addition & 1 deletion api/app/views/spree/api/variants/small.v1.rabl
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
attributes *variant_attributes
cache ['small_variant', root_object]
cache [I18n.locale, 'small_variant', root_object]

node(:display_price) { |p| p.display_price.to_s }
node(:options_text) { |v| v.options_text }
Expand Down
3 changes: 3 additions & 0 deletions api/spec/controllers/spree/api/base_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -101,4 +101,7 @@ def index
end
end

it "lets a subclass override the product associations that are eager-loaded" do
controller.respond_to?(:product_includes, true).should be
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,13 @@ def check_option_values(option_values)
option_value.name.should == "Option Value"
end

it "permits the correct attributes" do
controller.should_receive(:permitted_option_value_attributes)
api_put :update, :id => option_value.id, :option_value => {
:name => ""
}
end

it "cannot update an option value with invalid attributes" do
api_put :update, :id => option_value.id, :option_value => {
:name => ""
Expand Down
Loading