Saturday progress
This commit is contained in:
@@ -12,6 +12,7 @@ var $translations = {
|
|||||||
<%= I18n.t('supplier', locale: :nl).to_json[1..-2] %>
|
<%= I18n.t('supplier', locale: :nl).to_json[1..-2] %>
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$transformation_mappings = {
|
$transformation_mappings = {
|
||||||
downcase: 'toLowerCase',
|
downcase: 'toLowerCase',
|
||||||
upcase: 'toUpperCase'
|
upcase: 'toUpperCase'
|
||||||
|
|||||||
@@ -18,6 +18,13 @@ body
|
|||||||
padding-bottom: 0
|
padding-bottom: 0
|
||||||
.main-content
|
.main-content
|
||||||
padding-top: 16px
|
padding-top: 16px
|
||||||
|
label
|
||||||
|
&.number
|
||||||
|
display: inline
|
||||||
|
padding: 4px 10px
|
||||||
|
input
|
||||||
|
&.number
|
||||||
|
width: 40px
|
||||||
.supplier-is-closed
|
.supplier-is-closed
|
||||||
.alert
|
.alert
|
||||||
form
|
form
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ module Suppliers
|
|||||||
# GET /tables
|
# GET /tables
|
||||||
# GET /tables.json
|
# GET /tables.json
|
||||||
def index
|
def index
|
||||||
@tables = current_supplier.tables
|
@tables = Table.for_supplier(current_supplier, page: params[:page], per_page: params[:per_page] || 25, from_number: params[:from_number], to_number: params[:to_number])
|
||||||
|
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.html # index.html.erb
|
format.html # index.html.erb
|
||||||
|
|||||||
+19
-5
@@ -31,7 +31,6 @@ class Supplier
|
|||||||
has_many :sections, dependent: :destroy
|
has_many :sections, dependent: :destroy
|
||||||
|
|
||||||
after_create :add_section_on_create
|
after_create :add_section_on_create
|
||||||
after_create :send_creation_notifications
|
|
||||||
|
|
||||||
view :by_email, key: :email
|
view :by_email, key: :email
|
||||||
|
|
||||||
@@ -39,7 +38,7 @@ class Supplier
|
|||||||
validates :iens_profile, numericality: {allow_blank: true}
|
validates :iens_profile, numericality: {allow_blank: true}
|
||||||
|
|
||||||
def location=(val)
|
def location=(val)
|
||||||
lat, lng = val.strip.split(/[ ,]+/).map(&:to_f)
|
lat, lng = val.is_a?(Array) ? val : val.strip.split(/[ ,]+/).map(&:to_f)
|
||||||
self.lat = lat
|
self.lat = lat
|
||||||
self.lng = lng
|
self.lng = lng
|
||||||
end
|
end
|
||||||
@@ -88,14 +87,29 @@ class Supplier
|
|||||||
self.open = false
|
self.open = false
|
||||||
save
|
save
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
# Find a user by its confirmation token and try to confirm it.
|
||||||
|
# If no user is found, returns a new user with an error.
|
||||||
|
# If the user is already confirmed, create an error for the user
|
||||||
|
# Options must have the confirmation_token
|
||||||
|
#
|
||||||
|
# Overwrite devise method for mail sending
|
||||||
|
def self.confirm_by_token(confirmation_token)
|
||||||
|
confirmable = find_or_initialize_with_error_by(:confirmation_token, confirmation_token)
|
||||||
|
confirmable.confirm! if confirmable.persisted?
|
||||||
|
confirmable.send_creation_notifications if confirmable.errors.empty?
|
||||||
|
confirmable
|
||||||
|
end
|
||||||
|
|
||||||
|
def send_creation_notifications
|
||||||
|
SupplierMailer.creation(self).deliver
|
||||||
|
end
|
||||||
private
|
private
|
||||||
|
|
||||||
def add_section_on_create
|
def add_section_on_create
|
||||||
@section = Section.create supplier: self, title: I18n.t('supplier.section.first_section_title')
|
@section = Section.create supplier: self, title: I18n.t('supplier.section.first_section_title')
|
||||||
end
|
end
|
||||||
|
|
||||||
def send_creation_notifications
|
|
||||||
SupplierMailer.creation(self).deliver
|
|
||||||
end
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
+11
-2
@@ -1,5 +1,6 @@
|
|||||||
class Table
|
class Table
|
||||||
include SimplyStored::Couch
|
include SimplyStored::Couch
|
||||||
|
per_page_method :limit_value #kaminari
|
||||||
|
|
||||||
property :number, type: Fixnum, default: 1
|
property :number, type: Fixnum, default: 1
|
||||||
property :position_x, type: Float
|
property :position_x, type: Float
|
||||||
@@ -21,8 +22,16 @@ class Table
|
|||||||
view :by_number, key: :number
|
view :by_number, key: :number
|
||||||
|
|
||||||
def self.for_supplier(supplier, options = {})
|
def self.for_supplier(supplier, options = {})
|
||||||
startkey = options[:from_number].present? ? [supplier.id, options.delete(:from_number).to_i] : [supplier.id]
|
startkey = if from_number = options.delete(:from_number).presence
|
||||||
endkey = options[:to_number].present? ? [supplier.id, options.delete(:to_number).to_i]: [supplier.id, {}]
|
[supplier.id, from_number.to_i]
|
||||||
|
else
|
||||||
|
[supplier.id]
|
||||||
|
end
|
||||||
|
endkey = if to_number = options.delete(:to_number).presence
|
||||||
|
[supplier.id, to_number.to_i]
|
||||||
|
else
|
||||||
|
[supplier.id, {}]
|
||||||
|
end
|
||||||
|
|
||||||
total_entries = database.view(by_supplier_id_and_number({startkey: startkey, endkey: endkey, include_docs: false, reduce: true}))
|
total_entries = database.view(by_supplier_id_and_number({startkey: startkey, endkey: endkey, include_docs: false, reduce: true}))
|
||||||
options[:total_entries] = total_entries
|
options[:total_entries] = total_entries
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ div.page-header= title :index, model_class
|
|||||||
th= Table.model_name.human
|
th= Table.model_name.human
|
||||||
th= Supplier.model_name.human
|
th= Supplier.model_name.human
|
||||||
th= model_class.human_attribute_name(:created_at)
|
th= model_class.human_attribute_name(:created_at)
|
||||||
th=t 'helpers.actions'
|
th=t 'helpers.actions.title'
|
||||||
tbody
|
tbody
|
||||||
- @lists.each do |list|
|
- @lists.each do |list|
|
||||||
tr
|
tr
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ div.page-header= title :index, model_class
|
|||||||
th= model_class.human_attribute_name(:state)
|
th= model_class.human_attribute_name(:state)
|
||||||
th= Supplier.model_name.human
|
th= Supplier.model_name.human
|
||||||
th= model_class.human_attribute_name(:created_at)
|
th= model_class.human_attribute_name(:created_at)
|
||||||
th=t 'helpers.actions'
|
th=t 'helpers.actions.title'
|
||||||
tbody
|
tbody
|
||||||
- @orders.each do |order|
|
- @orders.each do |order|
|
||||||
tr
|
tr
|
||||||
|
|||||||
@@ -8,7 +8,7 @@
|
|||||||
th= model_class.human_attribute_name(:position)
|
th= model_class.human_attribute_name(:position)
|
||||||
th= Supplier.model_name.human
|
th= Supplier.model_name.human
|
||||||
th.timestamp= model_class.human_attribute_name(:created_at)
|
th.timestamp= model_class.human_attribute_name(:created_at)
|
||||||
th.actions=t 'helpers.actions'
|
th.actions=t 'helpers.actions.title'
|
||||||
tbody
|
tbody
|
||||||
- @product_categories.each do |product_category|
|
- @product_categories.each do |product_category|
|
||||||
tr
|
tr
|
||||||
|
|||||||
@@ -9,7 +9,7 @@
|
|||||||
th= model_class.human_attribute_name(:price)
|
th= model_class.human_attribute_name(:price)
|
||||||
th= Supplier.model_name.human
|
th= Supplier.model_name.human
|
||||||
th.timestamp= model_class.human_attribute_name(:created_at)
|
th.timestamp= model_class.human_attribute_name(:created_at)
|
||||||
th.actions=t 'helpers.actions'
|
th.actions=t 'helpers.actions.title'
|
||||||
tbody
|
tbody
|
||||||
- @products.each do |product|
|
- @products.each do |product|
|
||||||
tr
|
tr
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
th= model_class.human_attribute_name(:title)
|
th= model_class.human_attribute_name(:title)
|
||||||
th= Supplier.model_name.human
|
th= Supplier.model_name.human
|
||||||
th= model_class.human_attribute_name(:created_at)
|
th= model_class.human_attribute_name(:created_at)
|
||||||
th=t 'helpers.actions'
|
th=t 'helpers.actions.title'
|
||||||
tbody
|
tbody
|
||||||
- @sections.each do |section|
|
- @sections.each do |section|
|
||||||
tr
|
tr
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
th= model_class.human_attribute_name(:email)
|
th= model_class.human_attribute_name(:email)
|
||||||
th= model_class.human_attribute_name(:name)
|
th= model_class.human_attribute_name(:name)
|
||||||
th= model_class.human_attribute_name(:created_at)
|
th= model_class.human_attribute_name(:created_at)
|
||||||
th=t 'helpers.actions'
|
th=t 'helpers.actions.title'
|
||||||
tbody
|
tbody
|
||||||
- @suppliers.each do |supplier|
|
- @suppliers.each do |supplier|
|
||||||
tr
|
tr
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ div.page-header= title :index, model_class
|
|||||||
th= model_class.human_attribute_name(:number)
|
th= model_class.human_attribute_name(:number)
|
||||||
th= Supplier.model_name.human
|
th= Supplier.model_name.human
|
||||||
th= model_class.human_attribute_name(:created_at)
|
th= model_class.human_attribute_name(:created_at)
|
||||||
th=t 'helpers.actions'
|
th=t 'helpers.actions.title'
|
||||||
tbody
|
tbody
|
||||||
- @tables.each do |table|
|
- @tables.each do |table|
|
||||||
tr
|
tr
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
tr
|
tr
|
||||||
th= model_class.human_attribute_name(:email)
|
th= model_class.human_attribute_name(:email)
|
||||||
th= model_class.human_attribute_name(:created_at)
|
th= model_class.human_attribute_name(:created_at)
|
||||||
th=t 'helpers.actions'
|
th=t 'helpers.actions.title'
|
||||||
tbody
|
tbody
|
||||||
- @users.each do |user|
|
- @users.each do |user|
|
||||||
tr
|
tr
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ form action='' method="get"
|
|||||||
th= Table.model_name.human
|
th= Table.model_name.human
|
||||||
th.currency= model_class.human_attribute_name(:price)
|
th.currency= model_class.human_attribute_name(:price)
|
||||||
th.timestamp= model_class.human_attribute_name(:created_at)
|
th.timestamp= model_class.human_attribute_name(:created_at)
|
||||||
th.actions=t 'helpers.actions'
|
th.actions=t 'helpers.actions.title'
|
||||||
tbody
|
tbody
|
||||||
- @lists.each do |list|
|
- @lists.each do |list|
|
||||||
tr
|
tr
|
||||||
|
|||||||
@@ -5,12 +5,12 @@
|
|||||||
table.table
|
table.table
|
||||||
thead
|
thead
|
||||||
tr
|
tr
|
||||||
th= model_class.human_attribute_name(:name)
|
th data-t="attributes.product.name" = model_class.human_attribute_name(:name)
|
||||||
th= model_class.human_attribute_name(:code)
|
th data-t="attributes.product.code" = model_class.human_attribute_name(:code)
|
||||||
th.currency= model_class.human_attribute_name(:price)
|
th.currency data-t="attributes.product.price" = model_class.human_attribute_name(:price)
|
||||||
th= ProductCategory.model_name.human_plural
|
th data-t="models.product_category" = ProductCategory.model_name.human_plural
|
||||||
th.timestamp= model_class.human_attribute_name(:created_at)
|
th.timestamp data-t="attributes.product.created_at" = model_class.human_attribute_name(:created_at)
|
||||||
th.actions=t 'helpers.actions'
|
th.actions data-t="helpers.actions.title" =t 'helpers.actions.title'
|
||||||
tbody
|
tbody
|
||||||
- @products.each do |product|
|
- @products.each do |product|
|
||||||
tr
|
tr
|
||||||
@@ -26,4 +26,4 @@
|
|||||||
- else
|
- else
|
||||||
= no_content_given model_class
|
= no_content_given model_class
|
||||||
= link_to t("helpers.links.new"), new_suppliers_product_path(product_category_id: @product_category.try(:id)), class: 'btn btn-primary'
|
= link_to t("helpers.links.new"), new_suppliers_product_path(product_category_id: @product_category.try(:id)), class: 'btn btn-primary'
|
||||||
|
/a.btn.btn-primary data-t="helpers.links.new" href=new_suppliers_product_path
|
||||||
|
|||||||
@@ -1,4 +1,8 @@
|
|||||||
h2= t('devise.registrations.title')
|
h2= t('devise.registrations.title')
|
||||||
|
p
|
||||||
|
|
|
||||||
|
Leuk dat je je wilt aanmelden voor Qwaiter. Na de aanmelding zal er een bevestigings e-mail worden gestuurd
|
||||||
|
om het e-mailadres te bevestigen. Hierna kan je aan de slag met mobiel bestellen!
|
||||||
= form_for(resource, :as => resource_name, :url => registration_path(resource_name), html: {class: 'form-horizontal'}) do |f|
|
= form_for(resource, :as => resource_name, :url => registration_path(resource_name), html: {class: 'form-horizontal'}) do |f|
|
||||||
= devise_error_messages!
|
= devise_error_messages!
|
||||||
.control-group
|
.control-group
|
||||||
|
|||||||
@@ -10,7 +10,7 @@
|
|||||||
th.numeric data-t='attributes.section.width' = model_class.human_attribute_name(:width)
|
th.numeric data-t='attributes.section.width' = model_class.human_attribute_name(:width)
|
||||||
th.numeric data-t='attributes.section.height' = model_class.human_attribute_name(:height)
|
th.numeric data-t='attributes.section.height' = model_class.human_attribute_name(:height)
|
||||||
th.timestamp data-t='attributes.section.created_at' = model_class.human_attribute_name(:created_at)
|
th.timestamp data-t='attributes.section.created_at' = model_class.human_attribute_name(:created_at)
|
||||||
th.actions data-t='helpers.actions' = t 'helpers.actions'
|
th.actions data-t='helpers.actions.title' = t 'helpers.actions.title'
|
||||||
tbody
|
tbody
|
||||||
- @sections.each do |section|
|
- @sections.each do |section|
|
||||||
tr
|
tr
|
||||||
|
|||||||
@@ -1,14 +1,22 @@
|
|||||||
- model_class = Table
|
- model_class = Table
|
||||||
div.page-header= title :index, model_class
|
div.page-header= title :index, model_class
|
||||||
|
= form_tag({}, method: :get) do
|
||||||
|
label.number for="filter-from_number" data-t="attributes.table.from_number"
|
||||||
|
input#filter-from_number.number type="number" size=4 value=params[:from_number] name="from_number"
|
||||||
|
label.number for="filter-to_number" data-t="attributes.table.to_number"
|
||||||
|
input#filter-to_number.number type="number" size=4 value=params[:to_number] name="to_number"
|
||||||
|
'
|
||||||
|
= submit_tag 'Filter'
|
||||||
.well
|
.well
|
||||||
- if @tables.any?
|
- if @tables.any?
|
||||||
|
= paginate @tables
|
||||||
table.table
|
table.table
|
||||||
thead
|
thead
|
||||||
tr
|
tr
|
||||||
th.link data-t="attributes.table.number"= model_class.human_attribute_name(:number)
|
th.link data-t="attributes.table.number"= model_class.human_attribute_name(:number)
|
||||||
th.link data-t="models.section"= Section.model_name.human
|
th.link data-t="models.section"= Section.model_name.human
|
||||||
th.timestamp data-t="attributes.table.created_at"= model_class.human_attribute_name(:created_at)
|
th.timestamp data-t="attributes.table.created_at"= model_class.human_attribute_name(:created_at)
|
||||||
th.actions data-t="helpers.actions"=t 'helpers.actions'
|
th.actions data-t="helpers.actions.title"=t 'helpers.actions.title'
|
||||||
tbody
|
tbody
|
||||||
- @tables.each do |table|
|
- @tables.each do |table|
|
||||||
tr
|
tr
|
||||||
|
|||||||
@@ -1,19 +0,0 @@
|
|||||||
ul.nav.nav-pills
|
|
||||||
- if controller_name != 'sessions'
|
|
||||||
li= link_to t('devise.sessions.button'), new_session_path(resource_name), class: [:devise, :btn]
|
|
||||||
|
|
||||||
- if devise_mapping.registerable? && controller_name != 'registrations'
|
|
||||||
li= link_to t('devise.registrations.button'), new_registration_path(resource_name), class: [:devise, :btn]
|
|
||||||
|
|
||||||
- if devise_mapping.recoverable? && controller_name != 'passwords'
|
|
||||||
li= link_to t('devise.sessions.forgot_your_password'), new_password_path(resource_name), class: [:devise, :btn]
|
|
||||||
|
|
||||||
- if devise_mapping.confirmable? && controller_name != 'confirmations'
|
|
||||||
li= link_to t('devise.confirmations.did_not_receive_instructions_link'), new_confirmation_path(resource_name), class: [:devise, :btn]
|
|
||||||
|
|
||||||
- if devise_mapping.lockable? && resource_class.unlock_strategy_enabled?(:email) && controller_name != 'unlocks'
|
|
||||||
li= link_to t('devise.unlocks.did_not_receive_instructions_link'), new_unlock_path(resource_name), class: [:devise, :btn]
|
|
||||||
|
|
||||||
- if devise_mapping.omniauthable?
|
|
||||||
- resource_class.omniauth_providers.each do |provider|
|
|
||||||
li= link_to t('devise.omniauth_callbacks.sign_in_with', provider: provider.to_s.titleize), omniauth_authorize_path(resource_name, provider), class: [:devise, :btn]
|
|
||||||
@@ -22,7 +22,7 @@ Qwaiter::Application.configure do
|
|||||||
|
|
||||||
# Don't care if the mailer can't send
|
# Don't care if the mailer can't send
|
||||||
config.action_mailer.raise_delivery_errors = false
|
config.action_mailer.raise_delivery_errors = false
|
||||||
#config.action_mailer.delivery_method = :letter_opener
|
config.action_mailer.delivery_method = :letter_opener
|
||||||
config.action_mailer.default_url_options = {
|
config.action_mailer.default_url_options = {
|
||||||
host: 'localhost',
|
host: 'localhost',
|
||||||
port: 3000
|
port: 3000
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ nl:
|
|||||||
send_instructions_button: Stuur mij reset instructies
|
send_instructions_button: Stuur mij reset instructies
|
||||||
confirmations:
|
confirmations:
|
||||||
send_instructions: 'Er wordt een een e-mail naar je toe gestuurd waarin je je account kan bevestigen.'
|
send_instructions: 'Er wordt een een e-mail naar je toe gestuurd waarin je je account kan bevestigen.'
|
||||||
confirmed: 'De activatie van je account is successvol. Je bent nu aangemeld!'
|
confirmed: 'De activatie van je account is succesvol. Je bent nu aangemeld!'
|
||||||
did_not_receive_instructions_link: "Heeft u geen bevestigingsinstructies ontvangen?"
|
did_not_receive_instructions_link: "Heeft u geen bevestigingsinstructies ontvangen?"
|
||||||
did_not_receive: 'Heeft u geen bevestigingsinstructies ontvangen?'
|
did_not_receive: 'Heeft u geen bevestigingsinstructies ontvangen?'
|
||||||
registrations:
|
registrations:
|
||||||
|
|||||||
@@ -30,6 +30,8 @@ en:
|
|||||||
submit: 'Save %{model}'
|
submit: 'Save %{model}'
|
||||||
list:
|
list:
|
||||||
no_records: There are no items present
|
no_records: There are no items present
|
||||||
|
actions:
|
||||||
|
title: Actions
|
||||||
messages:
|
messages:
|
||||||
cannot_order_on_non_active_list: You cannot place an order on a closed list
|
cannot_order_on_non_active_list: You cannot place an order on a closed list
|
||||||
no_active_list: There is no active list
|
no_active_list: There is no active list
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
en:
|
||||||
activemodel:
|
activemodel:
|
||||||
models:
|
models:
|
||||||
user: User
|
user: User
|
||||||
@@ -19,7 +20,10 @@
|
|||||||
section: Sections
|
section: Sections
|
||||||
attributes:
|
attributes:
|
||||||
product:
|
product:
|
||||||
|
name: Name
|
||||||
|
code: Code
|
||||||
price: Price
|
price: Price
|
||||||
|
created_at: Created
|
||||||
list:
|
list:
|
||||||
created_at: Created
|
created_at: Created
|
||||||
state: Status
|
state: Status
|
||||||
@@ -32,3 +36,8 @@
|
|||||||
password: 'Password'
|
password: 'Password'
|
||||||
password_confirmation: 'Confirmation'
|
password_confirmation: 'Confirmation'
|
||||||
iens_profile: Iens profile id
|
iens_profile: Iens profile id
|
||||||
|
table:
|
||||||
|
number: Number
|
||||||
|
from_number: From number
|
||||||
|
to_number: To number
|
||||||
|
created_at: Created
|
||||||
|
|||||||
@@ -20,7 +20,10 @@ nl:
|
|||||||
section: Afdelingen
|
section: Afdelingen
|
||||||
attributes:
|
attributes:
|
||||||
product:
|
product:
|
||||||
|
name: Naam
|
||||||
|
code: Code
|
||||||
price: Prijs
|
price: Prijs
|
||||||
|
created_at: Aangemaakt
|
||||||
list:
|
list:
|
||||||
created_at: Aangemaakt
|
created_at: Aangemaakt
|
||||||
state: Status
|
state: Status
|
||||||
@@ -38,3 +41,8 @@ nl:
|
|||||||
password: 'Wachtwoord'
|
password: 'Wachtwoord'
|
||||||
password_confirmation: 'Bevestiging'
|
password_confirmation: 'Bevestiging'
|
||||||
iens_profile: Iens profiel id
|
iens_profile: Iens profiel id
|
||||||
|
table:
|
||||||
|
number: Nummer
|
||||||
|
from_number: Vanaf nummer
|
||||||
|
to_number: Tot nummer
|
||||||
|
created_at: Aangemaakt
|
||||||
|
|||||||
@@ -29,6 +29,8 @@ nl:
|
|||||||
submit: '%{model} opslaan'
|
submit: '%{model} opslaan'
|
||||||
list:
|
list:
|
||||||
no_records: Er zijn geen items aanwezig
|
no_records: Er zijn geen items aanwezig
|
||||||
|
actions:
|
||||||
|
title: Acties
|
||||||
messages:
|
messages:
|
||||||
cannot_order_on_non_active_list: Je kan niet bestellen op een gesloten lijst
|
cannot_order_on_non_active_list: Je kan niet bestellen op een gesloten lijst
|
||||||
no_active_list: Er is momenteel geen lijst actief
|
no_active_list: Er is momenteel geen lijst actief
|
||||||
|
|||||||
@@ -2,11 +2,11 @@ require 'acceptance/acceptance_helper'
|
|||||||
|
|
||||||
feature 'Supplier product categories spec', %q{
|
feature 'Supplier product categories spec', %q{
|
||||||
In order to manage product categories
|
In order to manage product categories
|
||||||
As a supplier
|
As a confirmed supplier
|
||||||
I want to have control over product categories and associated products
|
I want to have control over product categories and associated products
|
||||||
} do
|
} do
|
||||||
background do
|
background do
|
||||||
create_supplier 'supplier@qwaiter.com'
|
create_confirmed_supplier 'supplier@qwaiter.com'
|
||||||
end
|
end
|
||||||
context "GET #index" do
|
context "GET #index" do
|
||||||
background do
|
background do
|
||||||
|
|||||||
@@ -2,12 +2,12 @@ require 'acceptance/acceptance_helper'
|
|||||||
|
|
||||||
feature 'Supplier main board spec.rb', %q{
|
feature 'Supplier main board spec.rb', %q{
|
||||||
In order to manage active lists and orders
|
In order to manage active lists and orders
|
||||||
As a supplier
|
As a confirmed supplier
|
||||||
I want to have control over lists and orders from the main activity panel
|
I want to have control over lists and orders from the main activity panel
|
||||||
} do
|
} do
|
||||||
background do
|
background do
|
||||||
CouchPotato.couchrest_database.recreate!
|
CouchPotato.couchrest_database.recreate!
|
||||||
create_supplier 'supplier@qwaiter.com'
|
create_confirmed_supplier 'supplier@qwaiter.com'
|
||||||
create_user 'user@qwaiter.com'
|
create_user 'user@qwaiter.com'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -8,6 +8,11 @@ module HelperMethods
|
|||||||
@supplier = Supplier.find_by_email(email) || FactoryGirl.create(:supplier, email: email, password: password)
|
@supplier = Supplier.find_by_email(email) || FactoryGirl.create(:supplier, email: email, password: password)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def create_confirmed_supplier(email, password='secret')
|
||||||
|
@supplier = Supplier.find_by_email(email) || FactoryGirl.create(:supplier, :confirmed, email: email, password: password)
|
||||||
|
@supplier.confirm! unless @supplier.confirmed?
|
||||||
|
end
|
||||||
|
|
||||||
def login_user_as(email)
|
def login_user_as(email)
|
||||||
visit "/users/sign_in"
|
visit "/users/sign_in"
|
||||||
fill_in "user_email", with: email
|
fill_in "user_email", with: email
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ require 'spec_helper'
|
|||||||
|
|
||||||
describe Suppliers::ListsController do
|
describe Suppliers::ListsController do
|
||||||
before :each do
|
before :each do
|
||||||
@supplier = Supplier.find_by_email('supplier@qwaiter.com') || Supplier.create(name: 'Supplier', email: 'supplier@qwaiter.com', password: 'secret')
|
@supplier = Supplier.find_by_email('supplier@qwaiter.com') || create(:supplier, :confirmed)
|
||||||
sign_in @supplier
|
sign_in @supplier
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ require 'spec_helper'
|
|||||||
|
|
||||||
describe Suppliers::ProductCategoriesController do
|
describe Suppliers::ProductCategoriesController do
|
||||||
before :each do
|
before :each do
|
||||||
@supplier = Supplier.find_by_email('supplier@qwaiter.com') || Supplier.create(name: 'Supplier', email: 'supplier@qwaiter.com', password: 'secret')
|
@supplier = Supplier.find_by_email('supplier@qwaiter.com') || create(:supplier, :confirmed)
|
||||||
sign_in @supplier
|
sign_in @supplier
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ require 'spec_helper'
|
|||||||
|
|
||||||
describe Suppliers::ProductsController do
|
describe Suppliers::ProductsController do
|
||||||
before :each do
|
before :each do
|
||||||
@supplier = Supplier.find_by_email('supplier@qwaiter.com') || Supplier.create(name: 'Supplier', email: 'supplier@qwaiter.com', password: 'secret')
|
@supplier = Supplier.find_by_email('supplier@qwaiter.com') || create(:supplier, :confirmed)
|
||||||
sign_in @supplier
|
sign_in @supplier
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ require 'spec_helper'
|
|||||||
|
|
||||||
describe Suppliers::SectionsController do
|
describe Suppliers::SectionsController do
|
||||||
before :each do
|
before :each do
|
||||||
@supplier = Supplier.find_by_email('supplier@qwaiter.com') || Supplier.create(name: 'Supplier', email: 'supplier@qwaiter.com', password: 'secret')
|
@supplier = Supplier.find_by_email('supplier@qwaiter.com') || create(:supplier, :confirmed)
|
||||||
sign_in @supplier
|
sign_in @supplier
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ require 'spec_helper'
|
|||||||
|
|
||||||
describe Suppliers::TablesController do
|
describe Suppliers::TablesController do
|
||||||
before :each do
|
before :each do
|
||||||
@supplier = Supplier.find_by_email('supplier@qwaiter.com') || Supplier.create(name: 'Supplier', email: 'supplier@qwaiter.com', password: 'secret')
|
@supplier = Supplier.find_by_email('supplier@qwaiter.com') || create(:supplier, :confirmed)
|
||||||
sign_in @supplier
|
sign_in @supplier
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,12 @@
|
|||||||
FactoryGirl.define do
|
FactoryGirl.define do
|
||||||
factory :supplier do
|
factory :supplier do
|
||||||
sequence(:name){|i| "Supplier #{i}"}
|
sequence(:name){|i| "Supplier #{i}"}
|
||||||
|
email 'supplier@qwaiter.com'
|
||||||
password 'secret'
|
password 'secret'
|
||||||
|
|
||||||
|
trait :confirmed do
|
||||||
|
confirmed_at { Time.now }
|
||||||
|
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -16,7 +16,6 @@ describe Table do
|
|||||||
@table2 = create :table, supplier: supplier, number: 4
|
@table2 = create :table, supplier: supplier, number: 4
|
||||||
@table3 = create :table, supplier: supplier, number: 6
|
@table3 = create :table, supplier: supplier, number: 6
|
||||||
@table4 = create :table, number: 4
|
@table4 = create :table, number: 4
|
||||||
|
|
||||||
end
|
end
|
||||||
it "returns all by default" do
|
it "returns all by default" do
|
||||||
subject.should == [@table1, @table2, @table3]
|
subject.should == [@table1, @table2, @table3]
|
||||||
@@ -26,6 +25,22 @@ describe Table do
|
|||||||
options[:per_page] = 2
|
options[:per_page] = 2
|
||||||
subject.size.should == 2
|
subject.size.should == 2
|
||||||
subject.total_count.should == 3
|
subject.total_count.should == 3
|
||||||
|
end
|
||||||
|
|
||||||
|
it "should filter by table number using from_number" do
|
||||||
|
options[:per_page] = 1
|
||||||
|
options[:from_number] = 3
|
||||||
|
subject.size.should == 1
|
||||||
|
subject.total_pages.should == 2
|
||||||
|
subject.first.number.should == 4
|
||||||
|
|
||||||
|
end
|
||||||
|
it "should filter by table number using from_number and to_number" do
|
||||||
|
options[:from_number] = 3
|
||||||
|
options[:to_number] = 5
|
||||||
|
subject.size.should == 1
|
||||||
|
subject.total_pages.should == 1
|
||||||
|
subject.first.number.should == 4
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user