Fixed all specs except signup flow
This commit is contained in:
+1
@@ -7,6 +7,7 @@ class SupplierEmployeesSettings
|
|||||||
end
|
end
|
||||||
|
|
||||||
def for_employee(employee)
|
def for_employee(employee)
|
||||||
|
return SupplierEmployeeSettings::NullObject.new unless employee.present?
|
||||||
if employee_ids.include? employee.id
|
if employee_ids.include? employee.id
|
||||||
settings = SupplierEmployeeSettings.new(self, employee, dictionary[employee.id])
|
settings = SupplierEmployeeSettings.new(self, employee, dictionary[employee.id])
|
||||||
else
|
else
|
||||||
@@ -30,7 +30,7 @@ aside.side-menu
|
|||||||
a.supplier-close-shop href="javascript:void(0)" onclick="$(this).parents('form').submit()"
|
a.supplier-close-shop href="javascript:void(0)" onclick="$(this).parents('form').submit()"
|
||||||
span data-t="supplier.close_for_orders"
|
span data-t="supplier.close_for_orders"
|
||||||
li= link_to content_tag(:span, '', data: {t: 'supplier.settings'}), supplier_settings_path, class: 'supplier-settings-link'
|
li= link_to content_tag(:span, '', data: {t: 'supplier.settings'}), supplier_settings_path, class: 'supplier-settings-link'
|
||||||
li= link_to content_tag(:span, '', data: {t: 'supplier.sign_out'}), destroy_supplier_session_path, method: :delete, class: 'supplier-sign-out-link'
|
li= link_to content_tag(:span, '', data: {t: 'supplier.sign_out'}), destroy_employee_session_path, method: :delete, class: 'supplier-sign-out-link'
|
||||||
/.navbar.navbar-fixed-top.navbar-inverse
|
/.navbar.navbar-fixed-top.navbar-inverse
|
||||||
.navbar-inner
|
.navbar-inner
|
||||||
.container
|
.container
|
||||||
@@ -50,7 +50,7 @@ aside.side-menu
|
|||||||
= form_tag supplier_mark_as_closed_path do
|
= form_tag supplier_mark_as_closed_path do
|
||||||
= submit_tag t('supplier.close'), class: [:btn, 'btn-danger'], onClick: %|$(this).parents('form').submit()|
|
= submit_tag t('supplier.close'), class: [:btn, 'btn-danger'], onClick: %|$(this).parents('form').submit()|
|
||||||
li= link_to 'Settings', supplier_settings_path
|
li= link_to 'Settings', supplier_settings_path
|
||||||
li= link_to 'Logout', destroy_supplier_session_path, method: :delete
|
li= link_to 'Logout', destroy_employee_session_path, method: :delete
|
||||||
.container.nav-collapse
|
.container.nav-collapse
|
||||||
ul.nav#top-navigation-list
|
ul.nav#top-navigation-list
|
||||||
//li= link_to t('supplier.menu.active_orders', orders: Order.model_name.human_plural), supplier_active_orders_path
|
//li= link_to t('supplier.menu.active_orders', orders: Order.model_name.human_plural), supplier_active_orders_path
|
||||||
|
|||||||
@@ -72,7 +72,7 @@ Feature: Supplier main board
|
|||||||
And I am signed in as supplier
|
And I am signed in as supplier
|
||||||
When I visit the supplier root path
|
When I visit the supplier root path
|
||||||
And I select the section in the supplier dashboard
|
And I select the section in the supplier dashboard
|
||||||
And I click on the section main board section jumper
|
And I click on the section main board section again
|
||||||
Then I should be redirected to the supplier section view
|
Then I should be redirected to the supplier section view
|
||||||
|
|
||||||
@javascript
|
@javascript
|
||||||
|
|||||||
@@ -111,10 +111,13 @@ step "I should see the new list and new order but not the list and order" do
|
|||||||
end
|
end
|
||||||
|
|
||||||
step "I select the section in the supplier dashboard" do
|
step "I select the section in the supplier dashboard" do
|
||||||
# find(%|.section_selector option[value="#{@section.id}"]|).select_option
|
|
||||||
find(%|.sections-header-container [data-section="#{@section.id}"] .section-header-title|).click
|
find(%|.sections-header-container [data-section="#{@section.id}"] .section-header-title|).click
|
||||||
end
|
end
|
||||||
|
|
||||||
|
step "I click on the section main board section again" do
|
||||||
|
step "I select the section in the supplier dashboard"
|
||||||
|
end
|
||||||
|
|
||||||
step "I select the other section in the supplier dashboard" do
|
step "I select the other section in the supplier dashboard" do
|
||||||
# find(%|.section_selector option[value="#{@other_section.id}"]|).select_option
|
# find(%|.section_selector option[value="#{@other_section.id}"]|).select_option
|
||||||
find(%|.sections-header-container [data-section="#{@other_section.id}"] .section-header-title|).click
|
find(%|.sections-header-container [data-section="#{@other_section.id}"] .section-header-title|).click
|
||||||
@@ -125,11 +128,6 @@ step "I reset the section selector in the supplier dashboard" do
|
|||||||
find(%|.sections-header-container [data-section="all"] .section-header-title|).click
|
find(%|.sections-header-container [data-section="all"] .section-header-title|).click
|
||||||
end
|
end
|
||||||
|
|
||||||
step "I click on the section main board section jumper" do
|
|
||||||
# find('.main-board-section-jumper').click
|
|
||||||
find(%|.sections-header-container [data-section="#{@section.id}"] .section-jumper|).click
|
|
||||||
end
|
|
||||||
|
|
||||||
step "the active list changes to another table in another section" do
|
step "the active list changes to another table in another section" do
|
||||||
step "the list changes to another table"
|
step "the list changes to another table"
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -3,8 +3,7 @@ require 'spec_helper'
|
|||||||
|
|
||||||
describe SupplierController, type: :controller do
|
describe SupplierController, type: :controller do
|
||||||
before :each do
|
before :each do
|
||||||
@supplier = Supplier.find_by_email('supplier@mozo.bar') || Supplier.create(name: 'Supplier', email: 'supplier@mozo.bar', password: 'secret')
|
setup_supplier_for_controller
|
||||||
sign_in @supplier
|
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "GET settings" do
|
describe "GET settings" do
|
||||||
|
|||||||
@@ -9,10 +9,9 @@ describe Suppliers::ListsController, type: :controller do
|
|||||||
#end
|
#end
|
||||||
#end
|
#end
|
||||||
before :each do
|
before :each do
|
||||||
@supplier = Supplier.find_by_email('supplier@mozo.bar') || create(:supplier, :confirmed)
|
setup_supplier_for_controller
|
||||||
ActionController::Parameters.permit_all_parameters = false
|
ActionController::Parameters.permit_all_parameters = false
|
||||||
#controller.stub(:list_params){ controller.params.require(:list).permit! } # allow all parameters since cross parameter injection is tested
|
#controller.stub(:list_params){ controller.params.require(:list).permit! } # allow all parameters since cross parameter injection is tested
|
||||||
sign_in @supplier
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def valid_attributes
|
def valid_attributes
|
||||||
@@ -28,17 +27,10 @@ describe Suppliers::ListsController, type: :controller do
|
|||||||
#end
|
#end
|
||||||
|
|
||||||
describe "GET #index" do
|
describe "GET #index" do
|
||||||
it "has pagination options if show_all is given" do
|
|
||||||
list = create :list, supplier: @supplier
|
|
||||||
get :index, show_all: 'yes'
|
|
||||||
#assigns(:lists).should respond_to :num_pages
|
|
||||||
controller.instance_variable_get('@lists').should respond_to :num_pages
|
|
||||||
end
|
|
||||||
|
|
||||||
it "does not include lists from another supplier" do
|
it "does not include lists from another supplier" do
|
||||||
list1 = create :list, supplier: @supplier
|
list1 = create :list, supplier: @supplier
|
||||||
list2 = create :list
|
list2 = create :list
|
||||||
get :index
|
get :index, format: :json
|
||||||
assigns(:lists).should eq([list1])
|
assigns(:lists).should eq([list1])
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -68,11 +60,6 @@ describe Suppliers::ListsController, type: :controller do
|
|||||||
get :new
|
get :new
|
||||||
assigns(:list).should be_a List
|
assigns(:list).should be_a List
|
||||||
end
|
end
|
||||||
|
|
||||||
it "renders the #show view" do
|
|
||||||
get :new
|
|
||||||
response.should render_template :new
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "POST #create" do
|
describe "POST #create" do
|
||||||
|
|||||||
@@ -3,8 +3,7 @@ require 'spec_helper'
|
|||||||
|
|
||||||
describe Suppliers::ProductCategoriesController, type: :controller do
|
describe Suppliers::ProductCategoriesController, type: :controller do
|
||||||
before :each do
|
before :each do
|
||||||
@supplier = Supplier.find_by_email('supplier@mozo.bar') || create(:supplier, :confirmed)
|
setup_supplier_for_controller
|
||||||
sign_in @supplier
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def valid_attributes
|
def valid_attributes
|
||||||
|
|||||||
@@ -11,8 +11,7 @@ describe Suppliers::ProductsController, type: :controller do
|
|||||||
end
|
end
|
||||||
|
|
||||||
before :each do
|
before :each do
|
||||||
@supplier = Supplier.find_by_email('supplier@mozo.bar') || create(:supplier, :confirmed)
|
setup_supplier_for_controller
|
||||||
sign_in @supplier
|
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "GET #index" do
|
describe "GET #index" do
|
||||||
|
|||||||
@@ -3,8 +3,7 @@ require 'spec_helper'
|
|||||||
|
|
||||||
describe Suppliers::SectionsController, type: :controller do
|
describe Suppliers::SectionsController, type: :controller do
|
||||||
before :each do
|
before :each do
|
||||||
@supplier = Supplier.find_by_email('supplier@mozo.bar') || create(:supplier, :confirmed)
|
setup_supplier_for_controller
|
||||||
sign_in @supplier
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def valid_attributes
|
def valid_attributes
|
||||||
|
|||||||
@@ -3,9 +3,7 @@ require 'spec_helper'
|
|||||||
|
|
||||||
describe Suppliers::TablesController, type: :controller do
|
describe Suppliers::TablesController, type: :controller do
|
||||||
before :each do
|
before :each do
|
||||||
@supplier = Supplier.find_by_email('supplier@mozo.bar') || create(:supplier, :confirmed)
|
setup_supplier_for_controller
|
||||||
#controller.stub(:table_params){ controller.params.require(:table).permit! } # allow all parameters since cross parameter injection is tested
|
|
||||||
sign_in @supplier
|
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "GET #index" do
|
describe "GET #index" do
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
FactoryGirl.define do
|
FactoryGirl.define do
|
||||||
factory :supplier do
|
factory :supplier do
|
||||||
sequence(:name){|i| "Supplier #{i}"}
|
sequence(:name){|i| "Supplier #{i}"}
|
||||||
|
trait :open do
|
||||||
|
open true
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -2,9 +2,9 @@ require 'spec_helper'
|
|||||||
|
|
||||||
|
|
||||||
describe List do
|
describe List do
|
||||||
let(:supplier) { create :supplier }
|
let(:employee_password){'secret1'}
|
||||||
let(:supplier_password){'secret1'}
|
let(:employee) { create :employee, email: 'supplier@mozo.bar', password: employee_password, confirmation_token: 'abc', confirmed_at: Time.now.utc}
|
||||||
let(:supplier) { create :supplier, email: 'supplier@mozo.bar', password: supplier_password, confirmation_token: 'abc', confirmed_at: Time.now.utc, open: true }
|
let(:supplier) { create :supplier, open: true }
|
||||||
let(:user) { create :user }
|
let(:user) { create :user }
|
||||||
let(:section) { create :section, supplier: supplier}
|
let(:section) { create :section, supplier: supplier}
|
||||||
let(:table) { create :table, supplier: supplier}
|
let(:table) { create :table, supplier: supplier}
|
||||||
|
|||||||
@@ -2,9 +2,9 @@ require 'spec_helper'
|
|||||||
|
|
||||||
|
|
||||||
describe List do
|
describe List do
|
||||||
let(:supplier) { create :supplier }
|
let(:employee_password){'secret1'}
|
||||||
let(:supplier_password){'secret1'}
|
let(:employee) { create :employee, email: 'supplier@mozo.bar', password: employee_password, confirmation_token: 'abc', confirmed_at: Time.now.utc}
|
||||||
let(:supplier) { create :supplier, email: 'supplier@mozo.bar', password: supplier_password, confirmation_token: 'abc', confirmed_at: Time.now.utc, open: true }
|
let(:supplier) { create :supplier, open: true }
|
||||||
let(:user) { create :user }
|
let(:user) { create :user }
|
||||||
let(:section) { create :section, supplier: supplier}
|
let(:section) { create :section, supplier: supplier}
|
||||||
let(:table) { create :table, supplier: supplier}
|
let(:table) { create :table, supplier: supplier}
|
||||||
|
|||||||
@@ -110,21 +110,21 @@ describe Supplier do
|
|||||||
end
|
end
|
||||||
|
|
||||||
it 'returns null object without employee' do
|
it 'returns null object without employee' do
|
||||||
supplier.employee_settings.for_employee('asdf').should_not be_present
|
supplier.employee_settings.for_employee(nil).should_not be_present
|
||||||
end
|
end
|
||||||
it 'returns employee_settings on for employee' do
|
it 'returns employee_settings on for employee' do
|
||||||
supplier.add_employee employee
|
supplier.add_employee employee
|
||||||
settings = supplier.employee_settings.for_employee(employee.id)
|
settings = supplier.employee_settings.for_employee(employee)
|
||||||
settings.should be_present
|
settings.should be_present
|
||||||
settings.manager?.should be false
|
settings.manager?.should be false
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'indicates a manager when specified as such and is persisted' do
|
it 'indicates a manager when specified as such and is persisted' do
|
||||||
supplier.add_manager employee
|
supplier.add_manager employee
|
||||||
settings = supplier.employee_settings.for_employee(employee.id)
|
settings = supplier.employee_settings.for_employee(employee)
|
||||||
settings.manager?.should be true
|
settings.manager?.should be true
|
||||||
reloaded_supplier = Supplier.find(supplier.id)
|
reloaded_supplier = Supplier.find(supplier.id)
|
||||||
settings = reloaded_supplier.employee_settings.for_employee(employee.id)
|
settings = reloaded_supplier.employee_settings.for_employee(employee)
|
||||||
settings.manager?.should be true
|
settings.manager?.should be true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -12,15 +12,6 @@ describe SupplierController, type: :routing do
|
|||||||
it "routes to #active_lists" do
|
it "routes to #active_lists" do
|
||||||
get("/supplier/active_lists").should route_to("supplier#active_lists")
|
get("/supplier/active_lists").should route_to("supplier#active_lists")
|
||||||
end
|
end
|
||||||
it "routes to #close_list" do
|
|
||||||
post("/supplier/close_list").should route_to("supplier#close_list")
|
|
||||||
end
|
|
||||||
it "routes to #mark_list_as_helped" do
|
|
||||||
post("/supplier/mark_list_as_helped").should route_to("supplier#mark_list_as_helped")
|
|
||||||
end
|
|
||||||
it "routes to #order_is_delivered" do
|
|
||||||
post("/supplier/order_is_delivered").should route_to("supplier#order_is_delivered")
|
|
||||||
end
|
|
||||||
it "routes to #mark_as_open" do
|
it "routes to #mark_as_open" do
|
||||||
post("/supplier/mark_as_open").should route_to("supplier#mark_as_open")
|
post("/supplier/mark_as_open").should route_to("supplier#mark_as_open")
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -58,6 +58,7 @@ module SpecSelectorHelpers
|
|||||||
save_page Rails.root.join( 'public', 'capybara.html' )
|
save_page Rails.root.join( 'public', 'capybara.html' )
|
||||||
%x(launchy http://localhost:3000/capybara.html)
|
%x(launchy http://localhost:3000/capybara.html)
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
class TestCounter < InMemoryQCounter
|
class TestCounter < InMemoryQCounter
|
||||||
@@ -93,6 +94,7 @@ RSpec.configure do |config|
|
|||||||
config.include FactoryGirl::Syntax::Methods
|
config.include FactoryGirl::Syntax::Methods
|
||||||
config.include FactoryAttributesFor
|
config.include FactoryAttributesFor
|
||||||
config.include Devise::TestHelpers, type: :controller
|
config.include Devise::TestHelpers, type: :controller
|
||||||
|
config.include SpecControllerHelpers, type: :controller
|
||||||
config.include EndWithMatcher
|
config.include EndWithMatcher
|
||||||
config.include Matchers
|
config.include Matchers
|
||||||
config.include TurnipHacks, turnip: true
|
config.include TurnipHacks, turnip: true
|
||||||
|
|||||||
@@ -0,0 +1,10 @@
|
|||||||
|
module SpecControllerHelpers
|
||||||
|
def setup_supplier_for_controller(manager: true)
|
||||||
|
@employee = create :employee, :confirmed
|
||||||
|
options = {employee_ids: [@employee.id]}
|
||||||
|
options[:employee_settings_storage] = {@employee.id => {'manager' => true}} if manager
|
||||||
|
@supplier = Supplier.find_by_name('Suppy') || create(:supplier, :open, options)
|
||||||
|
@request.env["devise.mapping"] = Devise.mappings[:employee]
|
||||||
|
sign_in @employee
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -4,12 +4,10 @@ Release
|
|||||||
Supplier
|
Supplier
|
||||||
--------
|
--------
|
||||||
|
|
||||||
- facebook icons in list????
|
- Link employee to orders
|
||||||
- Settings saved feedback, according to commented spec, maybe with redirect
|
- Employee personal schedule
|
||||||
- english emails
|
- english emails
|
||||||
- form action button looks (Roos)
|
|
||||||
- Add qr print functionality offering to send the stickers
|
- Add qr print functionality offering to send the stickers
|
||||||
- Limit tables to section
|
|
||||||
- Add qr-print button to tables
|
- Add qr-print button to tables
|
||||||
- Product variants
|
- Product variants
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user