Order product user spec green
This commit is contained in:
@@ -7,5 +7,5 @@ App.ActiveListController = Ember.ObjectController.extend
|
||||
#@get('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')
|
||||
|
||||
@@ -3,10 +3,7 @@ each user in list.users
|
||||
if list.orders
|
||||
.list-orders-container
|
||||
each order in list.sorted_orders
|
||||
.list-order-container class=order.state
|
||||
= order.display
|
||||
span.currency= currency order.total
|
||||
span.created_at= time order.created_at
|
||||
App.ListOrderView contentBinding="order"
|
||||
if showTotal
|
||||
.list-orders-total.total
|
||||
= t 'total'
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
.row
|
||||
h2=t 'models.list'
|
||||
partial "list_content"
|
||||
link-to 'lists'
|
||||
link-to 'lists' class="button"
|
||||
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()
|
||||
|
||||
@@ -3,7 +3,7 @@ module Users
|
||||
|
||||
def index
|
||||
#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)
|
||||
render json: lists, each_serializer: UserListSerializer, meta: {total_pages: lists.total_pages, page: lists.current_page} #, root: :lists
|
||||
end
|
||||
|
||||
@@ -20,11 +20,14 @@ step "the user is on the homepage" do
|
||||
end
|
||||
|
||||
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
|
||||
|
||||
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}"
|
||||
end
|
||||
|
||||
|
||||
@@ -16,7 +16,9 @@ step "the user order should be created as a new order" do
|
||||
@order = Order.last
|
||||
row = find(".order-row-#{@order.id}")
|
||||
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'
|
||||
end
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
|
||||
step "the user clicks on the order :product_name twice" do |product_name|
|
||||
@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 }
|
||||
end
|
||||
|
||||
|
||||
@@ -13,4 +13,12 @@ module SpecRouteHelpers
|
||||
route_hash.merge! options
|
||||
Rails.application.routes.recognize_path(page.current_path).should include route_hash
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user