Fixed all specs except signup flow
This commit is contained in:
+1
@@ -7,6 +7,7 @@ class SupplierEmployeesSettings
|
||||
end
|
||||
|
||||
def for_employee(employee)
|
||||
return SupplierEmployeeSettings::NullObject.new unless employee.present?
|
||||
if employee_ids.include? employee.id
|
||||
settings = SupplierEmployeeSettings.new(self, employee, dictionary[employee.id])
|
||||
else
|
||||
@@ -30,7 +30,7 @@ aside.side-menu
|
||||
a.supplier-close-shop href="javascript:void(0)" onclick="$(this).parents('form').submit()"
|
||||
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.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-inner
|
||||
.container
|
||||
@@ -50,7 +50,7 @@ aside.side-menu
|
||||
= form_tag supplier_mark_as_closed_path do
|
||||
= submit_tag t('supplier.close'), class: [:btn, 'btn-danger'], onClick: %|$(this).parents('form').submit()|
|
||||
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
|
||||
ul.nav#top-navigation-list
|
||||
//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
|
||||
When I visit the supplier root path
|
||||
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
|
||||
|
||||
@javascript
|
||||
|
||||
@@ -111,10 +111,13 @@ step "I should see the new list and new order but not the list and order" do
|
||||
end
|
||||
|
||||
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
|
||||
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
|
||||
# find(%|.section_selector option[value="#{@other_section.id}"]|).select_option
|
||||
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
|
||||
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 list changes to another table"
|
||||
end
|
||||
|
||||
@@ -3,8 +3,7 @@ require 'spec_helper'
|
||||
|
||||
describe SupplierController, type: :controller do
|
||||
before :each do
|
||||
@supplier = Supplier.find_by_email('supplier@mozo.bar') || Supplier.create(name: 'Supplier', email: 'supplier@mozo.bar', password: 'secret')
|
||||
sign_in @supplier
|
||||
setup_supplier_for_controller
|
||||
end
|
||||
|
||||
describe "GET settings" do
|
||||
|
||||
@@ -9,10 +9,9 @@ describe Suppliers::ListsController, type: :controller do
|
||||
#end
|
||||
#end
|
||||
before :each do
|
||||
@supplier = Supplier.find_by_email('supplier@mozo.bar') || create(:supplier, :confirmed)
|
||||
setup_supplier_for_controller
|
||||
ActionController::Parameters.permit_all_parameters = false
|
||||
#controller.stub(:list_params){ controller.params.require(:list).permit! } # allow all parameters since cross parameter injection is tested
|
||||
sign_in @supplier
|
||||
end
|
||||
|
||||
def valid_attributes
|
||||
@@ -28,17 +27,10 @@ describe Suppliers::ListsController, type: :controller do
|
||||
#end
|
||||
|
||||
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
|
||||
list1 = create :list, supplier: @supplier
|
||||
list2 = create :list
|
||||
get :index
|
||||
get :index, format: :json
|
||||
assigns(:lists).should eq([list1])
|
||||
end
|
||||
end
|
||||
@@ -68,11 +60,6 @@ describe Suppliers::ListsController, type: :controller do
|
||||
get :new
|
||||
assigns(:list).should be_a List
|
||||
end
|
||||
|
||||
it "renders the #show view" do
|
||||
get :new
|
||||
response.should render_template :new
|
||||
end
|
||||
end
|
||||
|
||||
describe "POST #create" do
|
||||
|
||||
@@ -3,8 +3,7 @@ require 'spec_helper'
|
||||
|
||||
describe Suppliers::ProductCategoriesController, type: :controller do
|
||||
before :each do
|
||||
@supplier = Supplier.find_by_email('supplier@mozo.bar') || create(:supplier, :confirmed)
|
||||
sign_in @supplier
|
||||
setup_supplier_for_controller
|
||||
end
|
||||
|
||||
def valid_attributes
|
||||
|
||||
@@ -11,8 +11,7 @@ describe Suppliers::ProductsController, type: :controller do
|
||||
end
|
||||
|
||||
before :each do
|
||||
@supplier = Supplier.find_by_email('supplier@mozo.bar') || create(:supplier, :confirmed)
|
||||
sign_in @supplier
|
||||
setup_supplier_for_controller
|
||||
end
|
||||
|
||||
describe "GET #index" do
|
||||
|
||||
@@ -3,8 +3,7 @@ require 'spec_helper'
|
||||
|
||||
describe Suppliers::SectionsController, type: :controller do
|
||||
before :each do
|
||||
@supplier = Supplier.find_by_email('supplier@mozo.bar') || create(:supplier, :confirmed)
|
||||
sign_in @supplier
|
||||
setup_supplier_for_controller
|
||||
end
|
||||
|
||||
def valid_attributes
|
||||
|
||||
@@ -3,9 +3,7 @@ require 'spec_helper'
|
||||
|
||||
describe Suppliers::TablesController, type: :controller do
|
||||
before :each do
|
||||
@supplier = Supplier.find_by_email('supplier@mozo.bar') || create(:supplier, :confirmed)
|
||||
#controller.stub(:table_params){ controller.params.require(:table).permit! } # allow all parameters since cross parameter injection is tested
|
||||
sign_in @supplier
|
||||
setup_supplier_for_controller
|
||||
end
|
||||
|
||||
describe "GET #index" do
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
FactoryGirl.define do
|
||||
factory :supplier do
|
||||
sequence(:name){|i| "Supplier #{i}"}
|
||||
|
||||
trait :open do
|
||||
open true
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -2,9 +2,9 @@ require 'spec_helper'
|
||||
|
||||
|
||||
describe List do
|
||||
let(:supplier) { create :supplier }
|
||||
let(:supplier_password){'secret1'}
|
||||
let(:supplier) { create :supplier, email: 'supplier@mozo.bar', password: supplier_password, confirmation_token: 'abc', confirmed_at: Time.now.utc, open: true }
|
||||
let(:employee_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, open: true }
|
||||
let(:user) { create :user }
|
||||
let(:section) { create :section, supplier: supplier}
|
||||
let(:table) { create :table, supplier: supplier}
|
||||
|
||||
@@ -2,9 +2,9 @@ require 'spec_helper'
|
||||
|
||||
|
||||
describe List do
|
||||
let(:supplier) { create :supplier }
|
||||
let(:supplier_password){'secret1'}
|
||||
let(:supplier) { create :supplier, email: 'supplier@mozo.bar', password: supplier_password, confirmation_token: 'abc', confirmed_at: Time.now.utc, open: true }
|
||||
let(:employee_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, open: true }
|
||||
let(:user) { create :user }
|
||||
let(:section) { create :section, supplier: supplier}
|
||||
let(:table) { create :table, supplier: supplier}
|
||||
|
||||
@@ -110,21 +110,21 @@ describe Supplier do
|
||||
end
|
||||
|
||||
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
|
||||
it 'returns employee_settings on for employee' do
|
||||
supplier.add_employee employee
|
||||
settings = supplier.employee_settings.for_employee(employee.id)
|
||||
settings = supplier.employee_settings.for_employee(employee)
|
||||
settings.should be_present
|
||||
settings.manager?.should be false
|
||||
end
|
||||
|
||||
it 'indicates a manager when specified as such and is persisted' do
|
||||
supplier.add_manager employee
|
||||
settings = supplier.employee_settings.for_employee(employee.id)
|
||||
settings = supplier.employee_settings.for_employee(employee)
|
||||
settings.manager?.should be true
|
||||
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
|
||||
end
|
||||
|
||||
|
||||
@@ -12,15 +12,6 @@ describe SupplierController, type: :routing do
|
||||
it "routes to #active_lists" do
|
||||
get("/supplier/active_lists").should route_to("supplier#active_lists")
|
||||
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
|
||||
post("/supplier/mark_as_open").should route_to("supplier#mark_as_open")
|
||||
end
|
||||
|
||||
@@ -58,6 +58,7 @@ module SpecSelectorHelpers
|
||||
save_page Rails.root.join( 'public', 'capybara.html' )
|
||||
%x(launchy http://localhost:3000/capybara.html)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
class TestCounter < InMemoryQCounter
|
||||
@@ -93,6 +94,7 @@ RSpec.configure do |config|
|
||||
config.include FactoryGirl::Syntax::Methods
|
||||
config.include FactoryAttributesFor
|
||||
config.include Devise::TestHelpers, type: :controller
|
||||
config.include SpecControllerHelpers, type: :controller
|
||||
config.include EndWithMatcher
|
||||
config.include Matchers
|
||||
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
|
||||
--------
|
||||
|
||||
- facebook icons in list????
|
||||
- Settings saved feedback, according to commented spec, maybe with redirect
|
||||
- Link employee to orders
|
||||
- Employee personal schedule
|
||||
- english emails
|
||||
- form action button looks (Roos)
|
||||
- Add qr print functionality offering to send the stickers
|
||||
- Limit tables to section
|
||||
- Add qr-print button to tables
|
||||
- Product variants
|
||||
|
||||
|
||||
Reference in New Issue
Block a user