Skip to content

Commit

Permalink
Updates to cleanup stuff that should be in marketplace.
Browse files Browse the repository at this point in the history
  • Loading branch information
Jeff Dutil authored and Jeff Dutil committed Jul 23, 2014
1 parent e1a133a commit caec60b
Show file tree
Hide file tree
Showing 8 changed files with 45 additions and 33 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def get_suppliers
# Scopes the collection to the Supplier.
def supplier_collection
if try_spree_current_user && !try_spree_current_user.admin? && try_spree_current_user.supplier?
@collection = @collection.joins(:suppliers).where('spree_suppliers.id = ?', spree_current_user.supplier_id)
@collection = @collection.joins(:suppliers).where('spree_suppliers.id = ?', try_spree_current_user.supplier_id)
end
end

Expand Down
4 changes: 2 additions & 2 deletions app/models/spree/drop_ship_configuration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ class DropShipConfiguration < Preferences::Configuration
# Automatically deliver drop ship orders by default.
preference :automatically_deliver_orders_to_supplier, :boolean, default: true

# Default flat rate to charge drop ship suppliers per order for commission.
# Default flat rate to charge suppliers per order for commission.
preference :default_commission_flat_rate, :float, default: 0.0

# Default percentage to charge drop ship suppliers per order for commission.
# Default percentage to charge suppliers per order for commission.
preference :default_commission_percentage, :float, default: 0.0

# Determines whether or not to email a new supplier their welcome email.
Expand Down
17 changes: 0 additions & 17 deletions app/overrides/spree/users/show/add_supplier_info.html.erb.deface

This file was deleted.

2 changes: 1 addition & 1 deletion app/views/spree/admin/drop_ship_settings/edit.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<%= form_tag(spree.admin_drop_ship_settings_path, :method => :put) do %>
<fieldset class="general no-border-top">
<% %w(allow_signup automatically_deliver_orders_to_supplier default_commission_flat_rate default_commission_percentage send_supplier_email).each do |key|
<% %w(automatically_deliver_orders_to_supplier default_commission_flat_rate default_commission_percentage send_supplier_email).each do |key|
type = SpreeDropShip::Config.preference_type(key) %>
<div class="field">
<%= label_tag(key, Spree.t(key) + ': ') + tag(:br) if type != :boolean %>
Expand Down
12 changes: 6 additions & 6 deletions lib/tasks/spree_sample.rake
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ namespace :spree_sample do
desc "Create sample drop ship orders"
task :drop_ship_orders => :environment do
if Spree::Order.count == 0
puts "Please run `rake spree_sample:load` first to create products and orders"
puts "Please run `rake spree_sample:load` first to create products and orders"
exit
end

if Spree::Supplier.count == 0
puts "Please run `rake spree_sample:suppliers` first to create suppliers"
puts "Please run `rake spree_sample:suppliers` first to create suppliers"
exit
end

Expand All @@ -34,13 +34,13 @@ namespace :spree_sample do
SpreeDropShip::Config[:send_supplier_email] = false

@usa = Spree::Country.find_by_iso("US")
@ca = @usa.states.find_by_abbr("CA")
@ca = @usa.states.find_by_abbr("CA")

count = Spree::Supplier.count
puts "Creating Suppliers..."
5.times{|i|
name = "Supplier #{count + i + 1}"
supplier = Spree::Supplier.new(:name => name,
supplier = Spree::Supplier.new(:name => name,
:email => "#{name.parameterize}@example.com",
:url => "http://example.com")
supplier.build_address(:firstname => name, :lastname => name,
Expand All @@ -60,9 +60,9 @@ namespace :spree_sample do
count = 0

@products.each do |product|
product.supplier_id = @supplier_ids[rand(@supplier_ids.length)]
product.add_supplier! Spree::Supplier.find(@supplier_ids[rand(@supplier_ids.length)])
product.save
count += 1
count += 1
print "*"
end
puts
Expand Down
33 changes: 33 additions & 0 deletions spec/features/admin/settings_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
require 'spec_helper'

describe 'Admin - DropShip Settings', js: true do

before do
login_user create(:admin_user)

visit spree.admin_path
within 'ul[data-hook=admin_tabs]' do
click_link 'Configuration'
end
within 'ul[data-hook=admin_configurations_sidebar_menu]' do
click_link 'Drop Ship Settings'
end
end

it 'should be able to be updated' do
# Change settings
uncheck 'send_supplier_email'
fill_in 'default_commission_flat_rate', with: 0.30
fill_in 'default_commission_percentage', with: 10
click_button 'Update'
expect(page).to have_content('Drop ship settings successfully updated.')

# Verify update saved properly by reversing checkboxes or checking field values.
check 'send_supplier_email'
click_button 'Update'
find_field('default_commission_flat_rate').value.to_f.should eql(0.3)
find_field('default_commission_percentage').value.to_f.should eql(10.0)
expect(page).to have_content('Drop ship settings successfully updated.')
end

end
6 changes: 1 addition & 5 deletions spec/features/admin/suppliers_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,7 @@
before do
@user = create(:supplier_user)
login_user @user
visit spree.account_path
within 'dd.supplier-info' do
click_link 'Edit'
end
visit spree.edit_admin_supplier_path(@user.supplier)
end

scenario 'should only see tabs they have access to' do
Expand All @@ -89,7 +86,6 @@
page.should_not have_link('Promotions')
page.should_not have_link('Suppliers')
page.should have_link('Shipments')

end
end

Expand Down
2 changes: 1 addition & 1 deletion spree_drop_ship.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ Gem::Specification.new do |s|
s.add_development_dependency 'factory_girl_rails', '~> 4.2'
s.add_development_dependency 'ffaker'
s.add_development_dependency 'launchy'
s.add_development_dependency 'rspec-rails', '~> 2.13'
s.add_development_dependency 'rspec-rails', '~> 2.99'
s.add_development_dependency 'sass-rails', '~> 4.0.2'
s.add_development_dependency 'selenium-webdriver'
s.add_development_dependency 'shoulda-matchers'
Expand Down

0 comments on commit caec60b

Please sign in to comment.