Fix employee adding
This commit is contained in:
@@ -1,5 +1,38 @@
|
||||
Feature: Manage employees
|
||||
|
||||
@javascript
|
||||
Scenario: create an not yet existing extra employee
|
||||
Given there is a confirmed and open supplier
|
||||
And I am signed in as supplier
|
||||
When the supplier employee visits the 'employees' path
|
||||
And I click on selector '.new-employee-button'
|
||||
And the supplier emloyee sets the 'name' to 'New employee' in the employee popup
|
||||
And the supplier emloyee sets the 'email' to 'new-employee@example.com' in the employee popup
|
||||
And I click on selector '.form-row.manager .switch'
|
||||
And I click on selector '.modal-confirm'
|
||||
And I wait 1 second
|
||||
Then the new employee should be added to the supplier
|
||||
|
||||
@javascript
|
||||
Scenario: adding an already existing employee that was firstly added as manager without manager and active
|
||||
Given there is a confirmed and open supplier
|
||||
And I am signed in as supplier
|
||||
When the supplier employee visits the 'employees' path
|
||||
And I click on selector '.new-employee-button'
|
||||
And the supplier emloyee sets the 'name' to 'Existing employee' in the employee popup
|
||||
And the supplier emloyee sets the 'email' to 'existing-employee@example.com' in the employee popup
|
||||
And I click on selector '.form-row.manager .switch'
|
||||
And I click on selector '.modal-confirm'
|
||||
And the supplier employee clicks on the existing employee table destroy button
|
||||
And I click on selector '.modal-confirm'
|
||||
And I click on selector '.new-employee-button'
|
||||
And the supplier emloyee sets the 'name' to 'Existing employee readded' in the employee popup
|
||||
And the supplier emloyee sets the 'email' to 'existing-employee@example.com' in the employee popup
|
||||
And I click on selector '.form-row.active .switch'
|
||||
And I click on selector '.modal-confirm'
|
||||
And I wait 1 second
|
||||
Then the new employee should be re-added to the supplier as non manager non active
|
||||
|
||||
@javascript
|
||||
Scenario: a just signed up manager can manage employees
|
||||
Given there is a confirmed and open supplier
|
||||
@@ -7,7 +40,7 @@ Feature: Manage employees
|
||||
And I am signed in as supplier
|
||||
When the supplier employee visits the 'employees' path
|
||||
And the supplier employee clicks on the other employee table edit button
|
||||
And the supplier emloyee sets the 'name' to 'Edited employee'
|
||||
And the supplier emloyee sets the 'name' to 'Edited employee' in the employee popup
|
||||
And the supplier emloyee clicks the active switch to deactivate the employee
|
||||
And the supplier employee clicks the confirm modal button
|
||||
Then the other employee should no longer be active for the current supplier
|
||||
|
||||
@@ -8,7 +8,13 @@ step "the supplier employee clicks on the other employee table edit button" do
|
||||
all('tr').last.find('.table-edit').click
|
||||
end
|
||||
|
||||
step "the supplier emloyee sets the :attribute to :value" do |attribute, value|
|
||||
step "the supplier employee clicks on the existing employee table destroy button" do
|
||||
find 'table.table'
|
||||
sleep 0.2
|
||||
all('tr').last.find('.table-destroy').click
|
||||
end
|
||||
|
||||
step "the supplier emloyee sets the :attribute to :value in the employee popup" do |attribute, value|
|
||||
js_set_field ".form-row.#{attribute} input", value
|
||||
end
|
||||
|
||||
@@ -21,3 +27,24 @@ step "the other employee should no longer be active for the current supplier" do
|
||||
@supplier.reload
|
||||
@supplier.settings_for(@other_employee).active?.should be false
|
||||
end
|
||||
|
||||
step "the new employee should be added to the supplier" do
|
||||
@new_employee = Employee.find_by_email('new-employee@example.com')
|
||||
@new_employee.should be_present
|
||||
@new_employee.name.should eq 'New employee'
|
||||
@supplier.reload
|
||||
settings = @supplier.settings_for @new_employee
|
||||
settings.is_manager?.should be true
|
||||
settings.is_active?.should be true
|
||||
end
|
||||
|
||||
step "the new employee should be re-added to the supplier as non manager non active" do
|
||||
# Non active for a non default setting change to be recorded
|
||||
@existing_employee = Employee.find_by_email('existing-employee@example.com')
|
||||
@existing_employee.should be_present
|
||||
@existing_employee.name.should eq 'Existing employee readded'
|
||||
@supplier.reload
|
||||
settings = @supplier.settings_for @existing_employee
|
||||
settings.is_manager?.should be false
|
||||
settings.is_active?.should be false
|
||||
end
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
FactoryGirl.define do
|
||||
factory :employee do
|
||||
sequence(:name){|i| "Employee #{i}"}
|
||||
email 'employee@mozo.bar'
|
||||
sequence(:email){ |i| "employee#{i}@mozo.bar" }
|
||||
password 'secret'
|
||||
|
||||
trait :confirmed do
|
||||
|
||||
@@ -124,9 +124,30 @@ describe Supplier do
|
||||
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)
|
||||
settings = reloaded_supplier.settings_for(employee)
|
||||
settings.manager?.should be true
|
||||
end
|
||||
|
||||
it "Adds another manager (second appears to work different as the first)" do
|
||||
supplier.add_manager employee
|
||||
new_employee = create :employee, email: 'new-employee@example.com'
|
||||
supplier.add_manager new_employee
|
||||
reloaded_supplier = Supplier.find(supplier.id)
|
||||
settings = reloaded_supplier.settings_for(new_employee)
|
||||
settings.manager?.should be true
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
describe '#add_employee' do
|
||||
it 'resets the settings to the supplier settings' do
|
||||
employee = create :employee
|
||||
expect( employee.settings ).not_to be_present
|
||||
expect( employee.settings.supplier ).not_to be_present
|
||||
supplier.add_employee employee
|
||||
new_supplier_referenced = (employee.settings.supplier == supplier)
|
||||
new_supplier_referenced.should be true
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
+6
-4
@@ -10,7 +10,7 @@ require 'turnip/capybara'
|
||||
require 'in_memory_q_counter'
|
||||
require 'capybara-screenshot/rspec'
|
||||
require 'webmock/rspec'
|
||||
#require 'capybara/poltergeist'
|
||||
require 'capybara/poltergeist'
|
||||
|
||||
# Requires supporting ruby files with custom matchers and macros, etc,
|
||||
# in spec/support/ and its subdirectories.
|
||||
@@ -21,9 +21,9 @@ Dir.glob("spec/acceptance_steps/**/*steps.rb") { |f| load f, true }
|
||||
I18n.locale =I18n.default_locale
|
||||
Devise.stretches = 1
|
||||
#Capybara.javascript_driver = :webkit
|
||||
#Capybara.javascript_driver = :poltergeist
|
||||
Capybara.javascript_driver = :selenium
|
||||
Capybara.default_wait_time = 4 # ember needs more time than the default of 2
|
||||
Capybara.javascript_driver = :poltergeist
|
||||
#Capybara.javascript_driver = :selenium
|
||||
Capybara.default_wait_time = 3 # ember needs more time than the default of 2
|
||||
Capybara::Screenshot.webkit_options = { width: 1024, height: 768 }
|
||||
WebMock.disable_net_connect!(allow_localhost: true)
|
||||
|
||||
@@ -169,12 +169,14 @@ RSpec.configure do |config|
|
||||
end
|
||||
|
||||
config.after :suite do
|
||||
=begin
|
||||
rspec_outfile = Rails.root.join('coverage/rspec_results.html')
|
||||
result = File.read rspec_outfile
|
||||
replacement = %|<body><div><a href="index.html" style="padding:4px 8px;background-color:#393;color:white;font-weight:bold;border:2px #050 outset">Coverage</a></div>|
|
||||
result.gsub! /<body>/, replacement
|
||||
File.open(rspec_outfile, 'w'){|f| f.puts result}
|
||||
`open #{rspec_outfile}`
|
||||
=end
|
||||
end
|
||||
|
||||
# If true, the base class of anonymous controllers will be inferred
|
||||
|
||||
Reference in New Issue
Block a user