end of train commit
This commit is contained in:
@@ -37,7 +37,7 @@ class Employee
|
||||
end
|
||||
end
|
||||
|
||||
def to_hash
|
||||
def object_attributes
|
||||
attributes.merge(settings.as_json).merge("id" => id)
|
||||
end
|
||||
|
||||
@@ -48,6 +48,7 @@ class Employee
|
||||
|
||||
def enrich_with_settings(settings)
|
||||
@settings = settings
|
||||
self
|
||||
end
|
||||
alias_method :settings=, :enrich_with_settings
|
||||
|
||||
|
||||
+6
-2
@@ -238,7 +238,11 @@ class List
|
||||
end
|
||||
# user performs a client side refresh
|
||||
broadcast_users 'list_changed_table', list_id: id, from_table_id: from_table_id, to_table_id: to_table.id
|
||||
broadcast_supplier supplier_id, 'list_changed_table', ListSerializer.new(self).as_json
|
||||
broadcast_supplier supplier_id, 'list_changed_table',
|
||||
list_id: id,
|
||||
from_table_id: from_table_id,
|
||||
to_table_id: to_table.id,
|
||||
payload: JSONAPI::Serializer.serialize(self, serializer: Suppliers::ListSerializer)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -308,7 +312,7 @@ class List
|
||||
|
||||
if first_order
|
||||
# broadcast_users 'orders_placed_count', count: orders_placed_count
|
||||
broadcast_supplier supplier.id, 'list_update', Supplier::ListSerializer.new(self).as_json.merge(new_order_id: order.id)
|
||||
broadcast_supplier supplier.id, 'list_update', Suppliers::ListSerializer.new(self).as_json.merge(new_order_id: order.id)
|
||||
supplier_payload = JSONAPI::Serializer.serialize(self, serializer: Suppliers::ListSerializer, include: %w[
|
||||
orders
|
||||
orders.list
|
||||
|
||||
@@ -64,6 +64,10 @@ class SupplierEmployeesSettings
|
||||
nil # this time we will raise on further invocation, since then there is something wrong
|
||||
end
|
||||
end
|
||||
|
||||
def as_json
|
||||
{}
|
||||
end
|
||||
end
|
||||
|
||||
def initialize(all_employees_settings, employee, settings = {})
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
//var $locale = '<%= I18n.locale %>';
|
||||
//var supplier_id = '<%= current_supplier.id %>';
|
||||
var supplier_object=<%= {id: current_supplier.id}.to_json.html_safe %>;
|
||||
var employee_object=<%=raw current_employee.to_json %>;
|
||||
var employee_object=<%=raw current_employee.object_attributes.to_json %>;
|
||||
var data_host = '';
|
||||
var $asset_path = '/assets/';
|
||||
var event_host = '<%= Qwaiter.event_host %>';
|
||||
|
||||
@@ -2,7 +2,6 @@ step 'there is a confirmed and open supplier' do
|
||||
@supplier_password = 'secret1'
|
||||
@employee_password = @supplier_password
|
||||
@employee = create :employee, email: 'supplier@mozo.bar', password: @supplier_password
|
||||
binding.pry
|
||||
@supplier = build :supplier, open: true
|
||||
@supplier.add_manager @employee
|
||||
@section = create :section, title: 'Room', supplier: @supplier, width: 8, height: 8
|
||||
|
||||
@@ -128,7 +128,6 @@ describe Suppliers::ListsController, type: :controller do
|
||||
context "invalid attributes", broken: true do
|
||||
it "returns an error response" do
|
||||
put :update, id: @list, format: :json, list: invalid_params
|
||||
binding.pry
|
||||
expect( JSON.parse( response.body )['errors']).to be_present
|
||||
end
|
||||
end
|
||||
|
||||
@@ -13,4 +13,14 @@ describe Employee do
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe '#object_attributes' do
|
||||
let(:supplier){ create :supplier, employee_ids: [employee.id], employee_settings_storage: {employee.id => {manager: true}}}
|
||||
let(:employee){ create :employee }
|
||||
subject { employee.enrich_with_settings(supplier.settings_for(employee)).object_attributes }
|
||||
its(:keys){ should include 'id'}
|
||||
its(:keys){ should_not include '_id'}
|
||||
its(['id']){ should eq employee.id }
|
||||
its(['manager']){ should be true }
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user