Order product user spec green

This commit is contained in:
2014-06-25 17:23:43 +02:00
parent 58f0937570
commit 10bc926e87
10 changed files with 41 additions and 11 deletions
@@ -7,5 +7,5 @@ App.ActiveListController = Ember.ObjectController.extend
#@get('controllers.application.list') #@get('controllers.application.list')
#).property('controllers.application.list') #).property('controllers.application.list')
displayTotal: (-> @get('model.orders.length') and @get('model.orders.length') > 1 ).property('model.orders.length') showTotal: (-> @get('model.orders.length') and @get('model.orders.length') > 1 ).property('model.orders.length')
list: (-> @get('controllers.application.list') ).property('controllers.application.list') list: (-> @get('controllers.application.list') ).property('controllers.application.list')
@@ -3,10 +3,7 @@ each user in list.users
if list.orders if list.orders
.list-orders-container .list-orders-container
each order in list.sorted_orders each order in list.sorted_orders
.list-order-container class=order.state App.ListOrderView contentBinding="order"
= order.display
span.currency= currency order.total
span.created_at= time order.created_at
if showTotal if showTotal
.list-orders-total.total .list-orders-total.total
= t 'total' = t 'total'
@@ -1,5 +1,5 @@
.row .row
h2=t 'models.list' h2=t 'models.list'
partial "list_content" partial "list_content"
link-to 'lists' link-to 'lists' class="button"
span Go to lists span Go to lists
@@ -0,0 +1,3 @@
= order.display
span.currency= currency order.total
span.created_at= time order.created_at
@@ -0,0 +1,17 @@
App.ListOrderView = Ember.View.extend
classNames: 'list-order-container'
classNameBindings: ['content.state', 'contentWrapClass']
templateName: 'list_order_row'
contentWrapClass: (-> "order-row-#{@get('content.id')}").property('content.id')
#click: ->
#if @route_param
#@get('controller').transitionToRoute(@route, @route_param)
#else
#@get('controller').transitionToRoute(@route)
#active: (->
#if @get('controller.currentPath') == @route then 'active' else ''
#).property('controller.currentPath')
#init: ->
#@templateName = "menu_item_#{@route}"
#@_super()
+1 -1
View File
@@ -3,7 +3,7 @@ module Users
def index def index
#lists = current_user.lists.include_relation(:supplier, :table) #lists = current_user.lists.include_relation(:supplier, :table)
lists = List.for_user(current_user, page: params[:page], per_page: 2).include_relation(:supplier, :table) lists = List.for_user(current_user, page: params[:page], per_page: params[:per_page].presence || 25).include_relation(:supplier, :table)
#lists.include_relation(:supplier) #lists.include_relation(:supplier)
render json: lists, each_serializer: UserListSerializer, meta: {total_pages: lists.total_pages, page: lists.current_page} #, root: :lists render json: lists, each_serializer: UserListSerializer, meta: {total_pages: lists.total_pages, page: lists.current_page} #, root: :lists
end end
+5 -2
View File
@@ -20,11 +20,14 @@ step "the user is on the homepage" do
end end
step "the user should be redirected to the user order overview page" do step "the user should be redirected to the user order overview page" do
route_should_be 'user#active_list' #route_should_be 'user#active_list'
ember_route_should_be "/active_list"
end end
step "the user should be redirected to the archived list path" do step "the user should be redirected to the archived list path" do
route_should_be 'user#history_list' #route_should_be 'user#history_list'
sleep 1
ember_route_should_be "/lists/#{@order.list_id}"
page.should have_selector ".order-row-#{@order.id}" page.should have_selector ".order-row-#{@order.id}"
end end
+3 -1
View File
@@ -16,7 +16,9 @@ step "the user order should be created as a new order" do
@order = Order.last @order = Order.last
row = find(".order-row-#{@order.id}") row = find(".order-row-#{@order.id}")
row['class'].should include 'placed' row['class'].should include 'placed'
page.should have_content 'Apple pie (1), Heineken beer (2)' #page.should have_content 'Apple pie (1), Heineken beer (2)'
page.should have_content '1 x Apple pie'
page.should have_content '2 x Heineken beer'
page.should have_content '€ 8.96' page.should have_content '€ 8.96'
end end
@@ -1,7 +1,7 @@
step "the user clicks on the order :product_name twice" do |product_name| step "the user clicks on the order :product_name twice" do |product_name|
@last_product = instance_variable_get product_name.underscore.gsub(/\s/, '_').prepend('@') @last_product = instance_variable_get product_name.underscore.gsub(/\s/, '_').prepend('@')
button = find ".order-product-#{@last_product.id}" button = find ".order-product-#{@last_product.id} .add-product-to-list"
2.times { button.click } 2.times { button.click }
end end
+8
View File
@@ -13,4 +13,12 @@ module SpecRouteHelpers
route_hash.merge! options route_hash.merge! options
Rails.application.routes.recognize_path(page.current_path).should include route_hash Rails.application.routes.recognize_path(page.current_path).should include route_hash
end end
def ember_route_should_be(route_def)
ember_route.should == route_def
end
def ember_route
page.evaluate_script %|App.__container__.lookup('router:main').location.lastSetURL|
end
end end