Permalink
Browse files

MyAccount should not include incomplete orders. Fixed this along plus…

… verified with new test.

[#541 state:resolved]
  • Loading branch information...
1 parent f3a312b commit c3e75ebe849303b8435a908ad6cab3b62182f98c @schof schof committed Jul 1, 2009
Showing with 24 additions and 1 deletion.
  1. +1 −1 app/controllers/users_controller.rb
  2. +23 −0 test/functional/users_controller_test.rb
View
2 app/controllers/users_controller.rb
@@ -17,7 +17,7 @@ class UsersController < Spree::BaseController
end
show.before do
- @orders = Order.checkout_complete.find_all_by_user_id(current_user.id)
+ @orders = @user.orders.checkout_complete
end
def update
View
23 test/functional/users_controller_test.rb
@@ -0,0 +1,23 @@
+require 'test_helper'
+
+class UsersControllerTest < ActionController::TestCase
+ context "on get to :show" do
+ setup do
+ @complete_checkout = Factory(:checkout)
+ @incomplete_checkout = Factory(:incomplete_checkout)
+ user = Factory(:user, :orders => [@complete_checkout.order, @incomplete_checkout.order])
+ @controller.stub!(:current_user, :return => user)
+ get :show, :id => user.id
+ end
+ should_respond_with :success
+ should_assign_to :orders
+ context "@orders" do
+ should "include complete orders" do
+ assert assigns(:orders).include?(@complete_checkout.order)
+ end
+ should "not include incomplete orders" do
+ assert !assigns(:orders).include?(@incomplete_checkout.order)
+ end
+ end
+ end
+end

0 comments on commit c3e75eb

Please sign in to comment.