Current state with 6 failures is considered to be better than the previous one
This commit is contained in:
@@ -18,6 +18,13 @@ Qsupplier.App.SectionController = Ember.ObjectController.extend
|
||||
@send 'openModal', 'modal_section_add_tables', @get('model')
|
||||
arrangeTables: ->
|
||||
@send 'openModal', 'modal_section_arrange_tables', @get('model')
|
||||
editTable: (table)->
|
||||
@modal 'edit_table',
|
||||
model: table
|
||||
ok: ->
|
||||
table.save()
|
||||
close: ->
|
||||
table.rollback()
|
||||
destroySection: ->
|
||||
@send 'openModal', 'modal_confirm',
|
||||
title: t('helpers.links.are_you_sure')
|
||||
|
||||
@@ -8,7 +8,7 @@ Qsupplier.App.Table = DS.Model.extend
|
||||
# occupied: attr 'boolean'
|
||||
section: DS.belongsTo('section')
|
||||
#active_list: DS.belongsTo('list', key: 'active_list')
|
||||
active_list: DS.belongsTo('list')
|
||||
active_list: DS.belongsTo('list', async: true)
|
||||
#list: DS.belongsTo('list')
|
||||
#active_list: (->
|
||||
#@get('list')
|
||||
|
||||
@@ -4,12 +4,14 @@
|
||||
span.needs_help
|
||||
span.active_order
|
||||
if table.active_list
|
||||
div class="table-actions table-actions-#{unbound table.id}"
|
||||
div.table-actions
|
||||
.title= table.number
|
||||
.table-action-row
|
||||
Qsupplier.App.MarkListHelpedButtonView content=table.active_list
|
||||
Qsupplier.App.CloseListButtonView content=table.active_list
|
||||
.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
|
||||
img src=user.facebook_image
|
||||
if editmodedisabled
|
||||
|
||||
@@ -124,12 +124,6 @@ class UserController < Users::ApplicationController
|
||||
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
|
||||
def request_to_join_occupied_table
|
||||
render json: json_alert('messages.table_not_found') and return unless params[:table_id].present?
|
||||
|
||||
+2
-1
@@ -240,7 +240,8 @@ class List
|
||||
end
|
||||
|
||||
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.is_dirty
|
||||
if save
|
||||
|
||||
@@ -3,6 +3,7 @@ class JoinRequest
|
||||
def id
|
||||
"jr-#{user_id}"
|
||||
end
|
||||
alias _id id
|
||||
|
||||
def initialize(user: nil, list: nil)
|
||||
@user, @list = user, list
|
||||
@@ -35,6 +36,7 @@ class JoinRequest
|
||||
def serializable_hash
|
||||
{
|
||||
id: id,
|
||||
_id: id,
|
||||
user_id: user.id,
|
||||
user_facebook_id: user.uid,
|
||||
user_email: user.email,
|
||||
|
||||
+1
-1
@@ -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/move_table' => 'user#move_table', as: :user_move_table
|
||||
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/reject_join_request' => 'user#reject_join_request'
|
||||
post '/user/approve_join_request' => 'user#approve_join_request'
|
||||
|
||||
@@ -163,4 +163,35 @@ describe List do
|
||||
|
||||
describe 'product order creation'
|
||||
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
|
||||
|
||||
@@ -25,7 +25,7 @@ module Matchers
|
||||
|
||||
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 ")}"
|
||||
relevant_broadcasts.any?{|b| b[:data][:data] == @target_object}
|
||||
relevant_broadcasts.any?{|b| @target_object === b[:data][:data]}
|
||||
end
|
||||
|
||||
def message(msg)
|
||||
|
||||
Reference in New Issue
Block a user