Current state with 6 failures is considered to be better than the previous one

This commit is contained in:
2014-07-31 18:07:06 +02:00
parent 2e7be84a2e
commit c0c25673bf
9 changed files with 50 additions and 13 deletions
@@ -18,6 +18,13 @@ Qsupplier.App.SectionController = Ember.ObjectController.extend
@send 'openModal', 'modal_section_add_tables', @get('model') @send 'openModal', 'modal_section_add_tables', @get('model')
arrangeTables: -> arrangeTables: ->
@send 'openModal', 'modal_section_arrange_tables', @get('model') @send 'openModal', 'modal_section_arrange_tables', @get('model')
editTable: (table)->
@modal 'edit_table',
model: table
ok: ->
table.save()
close: ->
table.rollback()
destroySection: -> destroySection: ->
@send 'openModal', 'modal_confirm', @send 'openModal', 'modal_confirm',
title: t('helpers.links.are_you_sure') title: t('helpers.links.are_you_sure')
@@ -8,7 +8,7 @@ Qsupplier.App.Table = DS.Model.extend
# occupied: attr 'boolean' # occupied: attr 'boolean'
section: DS.belongsTo('section') section: DS.belongsTo('section')
#active_list: DS.belongsTo('list', key: 'active_list') #active_list: DS.belongsTo('list', key: 'active_list')
active_list: DS.belongsTo('list') active_list: DS.belongsTo('list', async: true)
#list: DS.belongsTo('list') #list: DS.belongsTo('list')
#active_list: (-> #active_list: (->
#@get('list') #@get('list')
@@ -4,12 +4,14 @@
span.needs_help span.needs_help
span.active_order span.active_order
if table.active_list if table.active_list
div class="table-actions table-actions-#{unbound table.id}" div.table-actions
.title= table.number .title= table.number
.table-action-row .table-action-row
Qsupplier.App.MarkListHelpedButtonView content=table.active_list Qsupplier.App.MarkListHelpedButtonView content=table.active_list
Qsupplier.App.CloseListButtonView content=table.active_list Qsupplier.App.CloseListButtonView content=table.active_list
.table-action-row=currency table.active_list.total .table-action-row=currency table.active_list.total
/.table-action-row
a{action "editTable" table}: span.fa.fa-lg.fa-wrench
each user in table.active_list.users each user in table.active_list.users
img src=user.facebook_image img src=user.facebook_image
if editmodedisabled if editmodedisabled
-6
View File
@@ -124,12 +124,6 @@ class UserController < Users::ApplicationController
end end
end end
# GET /user/join_occupied_table
def join_occupied_table
#redirect_to user_root_path(message: 'table_not_found') and return unless params[:table_id].present?
#@table = Table.find(params[:table_id])
end
# POST /user/join_occupied_table # POST /user/join_occupied_table
def request_to_join_occupied_table def request_to_join_occupied_table
render json: json_alert('messages.table_not_found') and return unless params[:table_id].present? render json: json_alert('messages.table_not_found') and return unless params[:table_id].present?
+2 -1
View File
@@ -240,7 +240,8 @@ class List
end end
def send_table_join_request_for_user!(requester) def send_table_join_request_for_user!(requester)
unless join_request_user_ids.include?(requester.id) unless join_request_user_ids.include?(requester.id) or user_ids.include?(requester.id)
@join_requests = nil # bust cache
self.join_request_user_ids << requester.id self.join_request_user_ids << requester.id
self.is_dirty self.is_dirty
if save if save
+2
View File
@@ -3,6 +3,7 @@ class JoinRequest
def id def id
"jr-#{user_id}" "jr-#{user_id}"
end end
alias _id id
def initialize(user: nil, list: nil) def initialize(user: nil, list: nil)
@user, @list = user, list @user, @list = user, list
@@ -35,6 +36,7 @@ class JoinRequest
def serializable_hash def serializable_hash
{ {
id: id, id: id,
_id: id,
user_id: user.id, user_id: user.id,
user_facebook_id: user.uid, user_facebook_id: user.uid,
user_email: user.email, user_email: user.email,
+1 -1
View File
@@ -61,7 +61,7 @@ Qwaiter::Application.routes.draw do
post '/user/order_selected_products' => 'user#order_selected_products', as: :user_order_selected_products post '/user/order_selected_products' => 'user#order_selected_products', as: :user_order_selected_products
post '/user/move_table' => 'user#move_table', as: :user_move_table post '/user/move_table' => 'user#move_table', as: :user_move_table
get '/user/table_info' => 'user#table_info', as: :user_table_info get '/user/table_info' => 'user#table_info', as: :user_table_info
get '/user/join_occupied_table' => 'user#join_occupied_table', as: :user_join_occupied_table # get '/user/join_occupied_table' => 'user#join_occupied_table', as: :user_join_occupied_table
post '/user/join_occupied_table' => 'user#request_to_join_occupied_table' post '/user/join_occupied_table' => 'user#request_to_join_occupied_table'
post '/user/reject_join_request' => 'user#reject_join_request' post '/user/reject_join_request' => 'user#reject_join_request'
post '/user/approve_join_request' => 'user#approve_join_request' post '/user/approve_join_request' => 'user#approve_join_request'
+31
View File
@@ -163,4 +163,35 @@ describe List do
describe 'product order creation' describe 'product order creation'
end end
describe 'join requests' do
describe '#send_table_join_request_for_user' do
it "does not add an existing user to join_request_user_ids" do
list.send_table_join_request_for_user! user
expect(list.join_request_user_ids).not_to include user.id
end
it "adds a user to join_request_user_ids" do
other_user = create :user
list.send_table_join_request_for_user! other_user
# test through persistance
list.reload
expect(list.join_request_user_ids).to eq [other_user.id]
end
it "does not add a user multiple times" do
other_user = create :user
2.times { list.send_table_join_request_for_user! other_user }
expect(list.join_request_user_ids).to eq [other_user.id]
end
it "broadcasts it to the user" do
other_user = create :user
expect{
list.send_table_join_request_for_user! other_user
}.to broadcast_to_user(user.id).message('user_join_request').with(
hash_including(:users, :join_request)
)
end
end
end
end end
@@ -25,7 +25,7 @@ module Matchers
relevant_broadcasts = test_broadcaster.broadcasts.select{|b| b[:channel] =~ /^\/user\/#{@user_id}/ && b[:data][:event] == @message} relevant_broadcasts = test_broadcaster.broadcasts.select{|b| b[:channel] =~ /^\/user\/#{@user_id}/ && b[:data][:event] == @message}
@failure_debug_content = "was #{relevant_broadcasts.map{|b| b[:data][:data].inspect}.join(" and ")}" @failure_debug_content = "was #{relevant_broadcasts.map{|b| b[:data][:data].inspect}.join(" and ")}"
relevant_broadcasts.any?{|b| b[:data][:data] == @target_object} relevant_broadcasts.any?{|b| @target_object === b[:data][:data]}
end end
def message(msg) def message(msg)