serializer stuff
This commit is contained in:
@@ -122,6 +122,7 @@ group :test do
|
||||
#gem 'capybara-webkit' #, '~>0.14.2' # version 1.1.0 does not yet compile in mavericks
|
||||
#gem 'selenium-webdriver', '~> 2.45.0.dev3'
|
||||
gem 'selenium-webdriver'
|
||||
gem 'hashie'
|
||||
#gem 'poltergeist'
|
||||
#gem 'capybara-webkit'
|
||||
gem 'capybara-screenshot'
|
||||
|
||||
@@ -497,6 +497,7 @@ DEPENDENCIES
|
||||
foreman
|
||||
foundation-rails
|
||||
fuubar
|
||||
hashie
|
||||
iso_country_codes
|
||||
jquery-rails
|
||||
jquery-ui-rails
|
||||
|
||||
@@ -4,3 +4,17 @@
|
||||
# "Accept": "application/json, text/javascript; q=0.01"
|
||||
App.ApplicationAdapter = DS.JSONAPIAdapter.extend
|
||||
namespace: 'supplier'
|
||||
pathForType: (type)->
|
||||
type.underscore().pluralize()
|
||||
createRecord: (store, type, snapshot)->
|
||||
data = {}
|
||||
#var serializer = store.serializerFor(type.modelName);
|
||||
serializer = Ember.get(snapshot.record, 'store').serializerFor('creation')
|
||||
url = @buildURL(type.modelName, null, snapshot, 'createRecord')
|
||||
|
||||
serializer.serializeIntoHash data, type, snapshot, includeId: true
|
||||
|
||||
@ajax url, "POST", data: data
|
||||
#debugger
|
||||
#Ember.get(snapshot.record, 'store').serializerFor('creation').serialize(snapshot)
|
||||
#3
|
||||
|
||||
@@ -2,29 +2,23 @@ App.IndexController = Ember.Controller.extend
|
||||
show_lists: true
|
||||
show_orders: true
|
||||
lists: (-> @store.peekAll('list')).property()
|
||||
orders: (-> @store.peekAll('order')).property()
|
||||
orders: Ember.computed -> @store.peekAll('order')
|
||||
sections: (-> @store.peekAll('section')).property()
|
||||
active_section: Ember.computed.alias 'globals.active_section'
|
||||
active_lists: (->
|
||||
active_lists: Ember.computed 'lists.@each.state', 'active_section.id', ->
|
||||
@get('orders') # trigger orders, otherwise observers are not initialized/triggered (active_orders)
|
||||
if section_id = @get('active_section.id')
|
||||
lists = @get('lists').filter (l)=>( l.get('section.id') == section_id && l.get('state') == 'active' )
|
||||
else
|
||||
lists = @get('lists').filterBy('state', 'active')
|
||||
lists.sortBy('created_at') # Not reversed, oldest on top, start with oldest order first :-) Customer happyness
|
||||
).property('lists.@each.state', 'active_section.id')
|
||||
lists.sortBy('created_at') # Not reversed, oldest on top, start with oldest order first, work your way down :-) Customer happyness
|
||||
|
||||
active_orders: Ember.computed 'active_lists.[]', 'active_orders.@each.state', ->
|
||||
active_orders: Ember.computed 'active_lists.[]', 'orders.@each.state', ->
|
||||
orders = Ember.A()
|
||||
@get('active_lists').forEach (list)->
|
||||
list.get('orders').filterBy('needs_supplier_attention').forEach (order)->
|
||||
orders.push order
|
||||
return orders
|
||||
#if @get('active_section.id')
|
||||
# orders = @get('orders').filter (o)=>( o.get('section.id') == @get('active_section.id') && o.get('needs_supplier_attention') )
|
||||
#else
|
||||
# orders = @get('orders').filter (o)->( o.get('needs_supplier_attention') )
|
||||
#orders.sortBy('created_at') # Not reversed, oldest on top, start with oldest order first :-) Customer happyness
|
||||
#).property('orders.@each.state', 'active_section.id')
|
||||
orders.sortBy('created_at') # Not reversed, oldest on top, start with oldest order first, work your way down :-) Customer happyness
|
||||
|
||||
show_lists_table: Ember.computed 'show_lists', 'active_lists.[]', ->
|
||||
@get('show_lists') and @get('active_lists.length')
|
||||
|
||||
@@ -2,8 +2,9 @@ attr = DS.attr
|
||||
App.EmployeeShift = DS.Model.extend
|
||||
start_from: attr('moment')
|
||||
end_on: attr('moment')
|
||||
employee: DS.belongsTo 'employee'
|
||||
description: attr('string')
|
||||
employee: DS.belongsTo 'employee', async: false
|
||||
supplier: DS.belongsTo 'supplier', async: false
|
||||
calendar_event: (->
|
||||
id: @id
|
||||
title: @get('title')
|
||||
@@ -11,7 +12,6 @@ App.EmployeeShift = DS.Model.extend
|
||||
end: @get('end_on')
|
||||
color: @get('employee.color')
|
||||
).property('start_from', 'end_on', 'title')
|
||||
supplier: DS.belongsTo('supplier')
|
||||
|
||||
title: Ember.computed 'employee.name', 'description', ->
|
||||
if @get('description')
|
||||
|
||||
@@ -5,18 +5,17 @@ App.List = DS.Model.extend
|
||||
needs_payment: attr 'boolean'
|
||||
user_requests_closing: attr('boolean')
|
||||
# users: DS.hasMany('user', async: true)
|
||||
users: DS.hasMany('user')
|
||||
is_paid: attr 'boolean'
|
||||
price: attr 'number'
|
||||
#has_active_orders: attr 'boolean'
|
||||
|
||||
price: attr 'number'
|
||||
closed_at: DS.attr('date')
|
||||
users: DS.hasMany('user', async: false)
|
||||
#table_number: attr 'number'
|
||||
table: DS.belongsTo('table', inverse: 'active_list', async: true)
|
||||
table: DS.belongsTo('table', inverse: 'active_list', async: false) # should be async, but synchroneously loading now fails with JSONAPI, this seems to work
|
||||
#users: DS.hasMany('user', inverse: 'active_list')
|
||||
orders: DS.hasMany('order')
|
||||
section: DS.belongsTo('section')
|
||||
section_id: attr('string')
|
||||
orders: DS.hasMany('order', async: false)
|
||||
section: DS.belongsTo('section', async: false) # should be async, but synchroneously loading now fails with JSONAPI, this seems to work
|
||||
active: ( -> @get('state') is 'active' ).property('state')
|
||||
isClosed: ->
|
||||
@set('state', 'closed')
|
||||
|
||||
@@ -11,7 +11,7 @@ App.Order = DS.Model.extend
|
||||
active: (-> @get('state') == 'active').property('state')
|
||||
delivered: (-> @get('state') == 'delivered').property('state')
|
||||
placed: (-> @get('state') == 'placed').property('state')
|
||||
needs_supplier_attention: (-> (@get('state') == 'placed') || (@get('state') == 'active')).property('state')
|
||||
needs_supplier_attention: (-> (@get('state') is 'placed') or (@get('state') is 'active')).property('state')
|
||||
|
||||
isClosed: ->
|
||||
@set 'state', 'closed'
|
||||
|
||||
@@ -8,9 +8,9 @@ App.Product = DS.Model.extend Ember.Validations.Mixin,
|
||||
active: attr('boolean', defaultValue: true)
|
||||
position: attr('number', defaultValue: 0)
|
||||
image: attr()
|
||||
product_category: DS.belongsTo('product_category')
|
||||
product_orders: DS.hasMany('product_order')
|
||||
product_variants: DS.hasMany('product_variant')
|
||||
product_category: DS.belongsTo('product_category', async: false)
|
||||
product_orders: DS.hasMany('product_order', async: false)
|
||||
product_variants: DS.hasMany('product_variant', async: false)
|
||||
|
||||
image_src: (->
|
||||
image = @get('image')
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
attr = DS.attr
|
||||
App.ProductCategory = DS.Model.extend Ember.Validations.Mixin,
|
||||
name: attr('string')
|
||||
products: DS.hasMany('product')
|
||||
supplier: DS.belongsTo 'supplier'
|
||||
active_on_sunday: attr('boolean', defaultValue: true)
|
||||
active_on_monday: attr('boolean', defaultValue: true)
|
||||
active_on_tuesday: attr('boolean', defaultValue: true)
|
||||
@@ -15,6 +13,9 @@ App.ProductCategory = DS.Model.extend Ember.Validations.Mixin,
|
||||
end_on: attr('number')
|
||||
position: attr('number')
|
||||
|
||||
products: DS.hasMany('product', async: false)
|
||||
supplier: DS.belongsTo 'supplier', async: false
|
||||
|
||||
sorted_products: (-> @get('products').sortBy('position') ).property('products.@each.position')
|
||||
|
||||
availability_text: Ember.computed 'active_on_sunday', 'active_on_monday', 'active_on_tuesday', 'active_on_wednesday', 'active_on_thursday', 'active_on_friday', 'active_on_saturday', 'full_day', 'start_from', 'end_on', ->
|
||||
|
||||
@@ -5,7 +5,7 @@ App.ProductOrder = DS.Model.extend
|
||||
product_variant: attr('string')
|
||||
product_name: attr('string')
|
||||
product: DS.belongsTo('product', async: true)
|
||||
order: DS.belongsTo('order')
|
||||
order: DS.belongsTo('order', async: false)
|
||||
increment: ->
|
||||
@set('quantity', @get('quantity') + 1)
|
||||
total: (-> @get('quantity') * @get('price')).property('quantity', 'price')
|
||||
|
||||
@@ -6,6 +6,6 @@ App.SectionArea = DS.Model.extend Ember.Validations.Mixin,
|
||||
position_x: attr 'number', defaultValue: 0
|
||||
position_y: attr 'number', defaultValue: 0
|
||||
rounded: attr 'boolean', defaultValue: false
|
||||
section: DS.belongsTo('section')
|
||||
section: DS.belongsTo('section', async: false)
|
||||
validations:
|
||||
title: {presence: true}
|
||||
|
||||
@@ -3,4 +3,4 @@ App.SectionElement = DS.Model.extend App.SvgElementMixin, App.Rotation,
|
||||
position_x: attr 'number', defaultValue: 0
|
||||
position_y: attr 'number', defaultValue: 0
|
||||
rotation: attr 'number', defaultValue: 0
|
||||
section: DS.belongsTo('section')
|
||||
section: DS.belongsTo('section', async: false)
|
||||
|
||||
@@ -15,9 +15,10 @@ App.Supplier = DS.Model.extend
|
||||
lat: attr 'number'
|
||||
lng: attr 'number'
|
||||
week_starts_on_monday: attr 'boolean'
|
||||
product_categories: DS.hasMany 'product_category'
|
||||
orders_in_process_count: attr('number')
|
||||
orders_placed_count: attr('number')
|
||||
|
||||
product_categories: DS.hasMany 'product_category', async: false
|
||||
employee_shifts: DS.hasMany('employee-shift')
|
||||
|
||||
close: ->
|
||||
|
||||
+3
-2
@@ -131,11 +131,12 @@ App.ApplicationRoute = Ember.Route.extend
|
||||
@store.pushPayload(data.payload)
|
||||
if order_id = data.payload.data.id
|
||||
order = @store.peekRecord('order', order_id)
|
||||
return if @get('globals.active_section.id') and order.get('section.id') isnt @get('globals.active_section.id')
|
||||
return if @get('globals.active_section.id') and order.get('list.section.id') isnt @get('globals.active_section.id')
|
||||
@set 'globals.flash_message', order.get('display_with_table')
|
||||
try ion.sound.play('water_droplet')
|
||||
new_list: (data)->
|
||||
debugger
|
||||
if data.payload
|
||||
@store.pushPayload(data.payload)
|
||||
try ion.sound.play('water_droplet')
|
||||
list_changed_table: (data) -> @store.pushPayload('list', lists: [data.list])
|
||||
list_closed: (data) -> list.isClosed() if list = @store.peekRecord('list', data.id)
|
||||
@@ -1,7 +1,4 @@
|
||||
App.SectionsRoute = Ember.Route.extend
|
||||
beforeModel: ->
|
||||
@store.findAll 'section-element'
|
||||
@store.findAll 'section-area'
|
||||
model: -> @store.peekAll 'section'
|
||||
|
||||
# setupController: (controller, collection) ->
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
#App.ApplicationSerializer = DS.ActiveModelSerializer
|
||||
|
||||
App.ApplicationSerializer = DS.JSONAPISerializer.extend
|
||||
keyForAttribute: (attr, method)-> attr
|
||||
App.ApplicationSerializer = DS.JSONAPISerializer.extend {}
|
||||
App.CreationSerializer = DS.ActiveModelSerializer.extend {}
|
||||
# keyForAttribute: (attr, method)-> attr
|
||||
#App.ApplicationStore = DS.Store
|
||||
#adapter: DS.ActiveModelAdapter.extend
|
||||
#namespace: 'supplier'
|
||||
|
||||
@@ -7,12 +7,12 @@ module Suppliers
|
||||
@employee_shifts.select! do |shift|
|
||||
current_supplier.employee_ids.include?(shift.employee.try(:id))
|
||||
end
|
||||
render json: JSONAPI::Serializer.serialize(@employee_shifts, serializer: Suppliers::EmployeeShiftSerializer, is_collection: true, include: %w[employee supplier])
|
||||
render json: JSONAPI::Serializer.serialize(@employee_shifts, serializer: Suppliers::EmployeeShiftSerializer, is_collection: true, include: %w[employee])
|
||||
end
|
||||
def create
|
||||
@employee_shift.supplier = current_supplier
|
||||
@employee_shift.save
|
||||
render json: JSONAPI::Serializer.serialize(@employee_shift, serializer: Suppliers::EmployeeShiftSerializer, include: %w[employee supplier])
|
||||
render json: JSONAPI::Serializer.serialize(@employee_shift, serializer: Suppliers::EmployeeShiftSerializer, include: %w[employee])
|
||||
end
|
||||
|
||||
def update
|
||||
@@ -31,6 +31,5 @@ module Suppliers
|
||||
def employee_shift_params
|
||||
params.require(:employee_shift).permit(:start_from, :end_on, :employee_id, :description)
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
@@ -23,13 +23,9 @@ module Suppliers
|
||||
|
||||
render json: JSONAPI::Serializer.serialize(@lists, serializer: Suppliers::ListSerializer, is_collection: true, include: %w[
|
||||
orders
|
||||
orders.list
|
||||
orders.user
|
||||
orders.product_orders
|
||||
orders.product_orders.product
|
||||
users
|
||||
section
|
||||
table
|
||||
])
|
||||
end
|
||||
|
||||
|
||||
@@ -6,6 +6,15 @@ module Suppliers
|
||||
|
||||
def show
|
||||
current_supplier.sections.include_relations(:tables, :section_areas, :section_elements, product_categories: {products: :product_variants})
|
||||
#render json: JSONAPI::Serializer.serialize(current_supplier, serializer: Suppliers::SupplierSerializer, include: %w[
|
||||
#sections
|
||||
#sections.tables
|
||||
#sections.section_areas
|
||||
#sections.section_elements
|
||||
#product_categories
|
||||
#product_categories.products
|
||||
#product_categories.products.product_variants
|
||||
#]) #.new(current_supplier).as_json
|
||||
render json: JSONAPI::Serializer.serialize(current_supplier, serializer: Suppliers::SupplierSerializer, include: %w[
|
||||
sections
|
||||
sections.tables
|
||||
@@ -14,7 +23,7 @@ module Suppliers
|
||||
product_categories
|
||||
product_categories.products
|
||||
product_categories.products.product_variants
|
||||
]) #.new(current_supplier).as_json
|
||||
])
|
||||
end
|
||||
|
||||
def update
|
||||
|
||||
@@ -27,7 +27,7 @@ module Users
|
||||
def show
|
||||
@list ||= List.find(params[:id]) if params[:id]
|
||||
render json: {}, status: :not_found and return unless @list.present? && Array.wrap(@list.user_ids).include?(current_user.id)
|
||||
render json: JSONAPI::Serializer.serialize(@list, serializer: Users::ListSerializer, include: %w[supplier users join_requests join_requests.list join_requests.user])
|
||||
render json: JSONAPI::Serializer.serialize(@list, serializer: Users::ListSerializer, include: %w[supplier users join_requests join_requests.user])
|
||||
end
|
||||
|
||||
# POST /user/list_needs_payment.json
|
||||
|
||||
@@ -37,6 +37,10 @@ class Employee
|
||||
end
|
||||
end
|
||||
|
||||
def to_hash
|
||||
attributes.merge(settings.as_json).merge("id" => id)
|
||||
end
|
||||
|
||||
#validates :email, email: true
|
||||
has_and_belongs_to_many :suppliers, storing_keys: false
|
||||
has_many :orders
|
||||
|
||||
+2
-1
@@ -320,11 +320,12 @@ class List
|
||||
table
|
||||
])
|
||||
# broadcast_supplier supplier.id, 'new_order', OrderSerializer.new(order)
|
||||
broadcast_supplier supplier.id, 'new_list', supplier_orders_placed_count: orders_placed_count, payload: supplier_payload
|
||||
broadcast_supplier supplier.id, 'new_list', supplier_orders_placed_count: orders_placed_count, payload: supplier_payload, list_id: self.id
|
||||
else
|
||||
# broadcast_users 'new_order', order: order.with_products_as_json, total_amount: price
|
||||
user_payload = JSONAPI::Serializer.serialize(order, serializer: Users::OrderSerializer, include: %w[list user product_orders product_orders.order])
|
||||
supplier_payload = JSONAPI::Serializer.serialize(order, serializer: Suppliers::OrderSerializer, include: %w[
|
||||
list
|
||||
user
|
||||
product_orders
|
||||
])
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
class Suppliers::EmployeeShiftSerializer
|
||||
include Qwaiter::SupplierBaseSerializer
|
||||
attributes :start_from, :end_on, :employee_id, :supplier_id
|
||||
attributes :start_from, :end_on
|
||||
has_one :supplier, serializer: Suppliers::SupplierSerializer
|
||||
has_one :employee, serializer: Suppliers::EmployeeSerializer
|
||||
end
|
||||
|
||||
@@ -4,4 +4,5 @@ class Suppliers::ProductCategorySerializer
|
||||
:active_on_thursday, :active_on_friday, :active_on_saturday, :full_day, :start_from, :end_on,
|
||||
:position
|
||||
has_many :products, serializer: Suppliers::ProductSerializer
|
||||
has_one :supplier, serializer: Suppliers::SupplierSerializer
|
||||
end
|
||||
|
||||
@@ -10,5 +10,5 @@ class Suppliers::ProductSerializer
|
||||
end
|
||||
|
||||
has_many :product_variants, serializer: Suppliers::ProductVariantSerializer
|
||||
has_one :product_category, serializer: Suppliers::ProductSerializer
|
||||
has_one :product_category, serializer: Suppliers::ProductCategorySerializer
|
||||
end
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
class Suppliers::ProductVariantSerializer
|
||||
include Qwaiter::SupplierBaseSerializer
|
||||
attributes :name
|
||||
has_one :product, serializer: Suppliers::ProductSerializer
|
||||
end
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
class Suppliers::SectionSerializer
|
||||
include Qwaiter::SupplierBaseSerializer
|
||||
attributes :title, :path, :width, :height
|
||||
attributes :title, :width, :height #, :path
|
||||
has_many :tables, serializer: Suppliers::TableSerializer
|
||||
has_many :section_areas, serializer: Suppliers::SectionAreaSerializer
|
||||
has_many :section_elements, serializer: Suppliers::SectionElementSerializer
|
||||
has_one :supplier, serializer: Suppliers::SupplierSerializer
|
||||
end
|
||||
|
||||
@@ -5,6 +5,10 @@ class JoinRequest
|
||||
end
|
||||
alias _id id
|
||||
|
||||
def list_id
|
||||
list.try(:id)
|
||||
end
|
||||
|
||||
def initialize(user: nil, list: nil, created_at: Time.now, updated_at: Time.now)
|
||||
@user, @list, @created_at, @updated_at = [user, list, created_at, updated_at]
|
||||
end
|
||||
|
||||
@@ -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.attributes.merge(id: current_employee.id).to_json %>;
|
||||
var employee_object=<%=raw current_employee.to_json %>;
|
||||
var data_host = '';
|
||||
var $asset_path = '/assets/';
|
||||
var event_host = '<%= Qwaiter.event_host %>';
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
.home-panel
|
||||
/.home-panel
|
||||
.home-header = image_tag 'logo.png'
|
||||
.home-center
|
||||
a href="#" onClick="QMobile.scanQr()" = image_tag 'user/scan-logo.png'
|
||||
@@ -6,7 +6,7 @@
|
||||
.home-footer-content
|
||||
= link_to content_tag(:span, 'P'), user_list_products_path, class: ['home-link', 'home-menu-link']
|
||||
= link_to content_tag(:span, 'L'), user_active_list_path, class: ['home-link', 'home-list-link']
|
||||
- content_for :footer do
|
||||
/- content_for :footer do
|
||||
javascript:
|
||||
$(function(){
|
||||
Quser.home_loader();
|
||||
|
||||
+1
-1
@@ -54,7 +54,7 @@ Qwaiter::Application.routes.draw do
|
||||
# USER
|
||||
#default_url_options format: 'html'
|
||||
#get '/user/index' => 'user#index', as: :user_root
|
||||
#get '/user' => 'user#index'
|
||||
get '/user' => 'user#index'
|
||||
#get '/user/active_list(.:format)' => 'user#active_list', as: :user_active_list
|
||||
#get '/user/list_info' => 'user#list_info', as: :user_list_info, via: [:get, :options]
|
||||
#post '/user/needs_help' => 'user#needs_help', as: :user_needs_help
|
||||
|
||||
@@ -12,18 +12,17 @@ module Qwaiter::SupplierBaseSerializer
|
||||
end
|
||||
|
||||
def format_name(attribute_name)
|
||||
#attribute_name.to_s.dasherize
|
||||
attribute_name.to_s
|
||||
attribute_name.to_s.dasherize
|
||||
end
|
||||
|
||||
def unformat_name(attribute_name)
|
||||
#attribute_name.to_s.underscore
|
||||
attribute_name.to_s
|
||||
attribute_name.to_s.underscore
|
||||
end
|
||||
|
||||
#alias_method :default_relationship_related_link, :relationship_related_link
|
||||
def relationship_related_link(attribute_name)
|
||||
super if related_link_for_attributes.include?(attribute_name)
|
||||
#super if related_link_for_attributes.include?(attribute_name)
|
||||
super
|
||||
end
|
||||
|
||||
def relationship_self_link(attribute_name)
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
require 'spec_helper'
|
||||
|
||||
describe "asldfj", type: :request do
|
||||
let(:supplier){ create :supplier }
|
||||
let(:employee){ create :employee }
|
||||
before do
|
||||
supplier.add_employee(employee)
|
||||
login_as employee, scope: :employee
|
||||
end
|
||||
it "works" do
|
||||
supplier = create :supplier
|
||||
get "/supplier/suppliers/#{supplier.id}.json"
|
||||
api_response.data.relationships.product_categorie
|
||||
included_section = api_response.included.find{|ih| ih['type'] == 'sections'}
|
||||
included_section['relationships']['tables']['data'].should eq []
|
||||
included_section['relationships']['section-areas']['data'].should eq []
|
||||
end
|
||||
end
|
||||
@@ -41,6 +41,25 @@ module FactoryAttributesFor
|
||||
super(obj, options).merge(build(obj).attributes.select{|k,v| k =~ /_id$/}).symbolize_keys
|
||||
end
|
||||
end
|
||||
|
||||
module RequestSpecHelpers
|
||||
module MethodsForHash
|
||||
def method_missing(m, *args)
|
||||
r = self[m.to_s.dasherize]
|
||||
if r.is_a?(Hash)
|
||||
r.extend MethodsForHash
|
||||
end
|
||||
r
|
||||
end
|
||||
end
|
||||
def api_response
|
||||
result = JSON.parse(response.body)
|
||||
result.extend MethodsForHash
|
||||
#result.extend Hashie::Extensions::DeepFind
|
||||
result
|
||||
end
|
||||
end
|
||||
|
||||
module SpecSelectorHelpers
|
||||
def top_navigation
|
||||
'.navbar-fixed-top'
|
||||
@@ -61,6 +80,12 @@ module SpecSelectorHelpers
|
||||
|
||||
end
|
||||
|
||||
class Ability
|
||||
include CanCan::Ability
|
||||
def initialize(record)
|
||||
can :manage, :All
|
||||
end
|
||||
end
|
||||
class TestCounter < InMemoryQCounter
|
||||
#def incr(*args)
|
||||
#result = super
|
||||
@@ -103,6 +128,8 @@ RSpec.configure do |config|
|
||||
config.include SpecRouteHelpers, type: :feature
|
||||
config.include SpecEmberHelpers, type: :feature
|
||||
config.include SerializersTestHelpers, type: :serializer
|
||||
config.include Warden::Test::Helpers, type: :request
|
||||
config.include RequestSpecHelpers, type: :request
|
||||
#config.use_transactional_fixtures = true
|
||||
config.infer_base_class_for_anonymous_controllers = true
|
||||
config.filter_run_excluding broken: true
|
||||
@@ -170,6 +197,13 @@ RSpec.configure do |config|
|
||||
Capybara.session_name = :default
|
||||
end
|
||||
|
||||
config.around :each, type: :request do |example|
|
||||
Warden.test_mode!
|
||||
example.run
|
||||
Warden.test_reset!
|
||||
end
|
||||
|
||||
|
||||
config.after :suite do
|
||||
=begin
|
||||
rspec_outfile = Rails.root.join('coverage/rspec_results.html')
|
||||
|
||||
Reference in New Issue
Block a user