Merge branch 'master' into enterprise-index-revamp

This commit is contained in:
Rohan Mitchell
2015-06-12 10:26:11 +10:00
12 changed files with 80 additions and 67 deletions

View File

@@ -353,7 +353,7 @@ GEM
net-scp (1.1.2)
net-ssh (>= 2.6.5)
net-ssh (2.6.8)
newrelic_rpm (3.6.7.152)
newrelic_rpm (3.12.0.288)
nokogiri (1.6.6.2)
mini_portile (~> 0.6.0)
oj (2.1.2)

View File

@@ -7,5 +7,5 @@ Darkswarm.factory "MapConfiguration", ->
zoom: 12
additional_options: {}
#mapTypeId: 'satellite'
styles: [{"featureType":"landscape","stylers":[{"saturation":-100},{"lightness":65},{"visibility":"on"}]},{"featureType":"poi","stylers":[{"saturation":-100},{"lightness":51},{"visibility":"simplified"}]},{"featureType":"road.highway","stylers":[{"saturation":-100},{"visibility":"simplified"}]},{"featureType":"road.arterial","stylers":[{"saturation":-100},{"lightness":30},{"visibility":"on"}]},{"featureType":"road.local","stylers":[{"saturation":-100},{"lightness":40},{"visibility":"on"}]},{"featureType":"transit","stylers":[{"saturation":-100},{"visibility":"simplified"}]},{"featureType":"administrative.province","stylers":[{"visibility":"off"}]},{"featureType":"water","elementType":"labels","stylers":[{"visibility":"on"},{"lightness":-25},{"saturation":-100}]},{"featureType":"water","elementType":"geometry","stylers":[{"hue":"#ffff00"},{"lightness":-25},{"saturation":-97}]}]
styles: [{"featureType":"landscape","stylers":[{"saturation":-100},{"lightness":65},{"visibility":"on"}]},{"featureType":"poi","stylers":[{"saturation":-100},{"lightness":51},{"visibility":"simplified"}]},{"featureType":"road.highway","stylers":[{"saturation":-100},{"visibility":"simplified"}]},{"featureType":"road.arterial","stylers":[{"saturation":-100},{"lightness":30},{"visibility":"on"}]},{"featureType":"road.local","stylers":[{"saturation":-100},{"lightness":40},{"visibility":"on"}]},{"featureType":"transit","stylers":[{"saturation":-100},{"visibility":"simplified"}]},{"featureType":"administrative.province","stylers":[{"visibility":"off"}]},{"featureType":"water","elementType":"labels","stylers":[{"visibility":"on"},{"lightness":-25},{"saturation":-100}]},{"featureType":"water","elementType":"geometry","stylers":[{"hue":"#ffff00"},{"lightness":-25},{"saturation":-97}]},{"featureType":"road","elementType": "labels.icon","stylers":[{"visibility":"off"}]}]

View File

@@ -30,9 +30,18 @@
float: right
margin-left: 0.5rem
//Hub Link
@media all and (max-width: 640px)
a.hub
display: block
//Hub Name
span.hub-name-listing
font-weight: 700
&:after
content: ">>"
display: inline-block
margin-left: 5px
//CLOSED row
&.closed

View File

@@ -1,5 +1,8 @@
Spree::Api::LineItemsController.class_eval do
after_filter :apply_enterprise_fees, :only => :update
after_filter :apply_enterprise_fees, only: :update
private
def apply_enterprise_fees
authorize! :read, order

View File

@@ -157,20 +157,22 @@ Spree::Order.class_eval do
end
def update_distribution_charge!
EnterpriseFee.clear_all_adjustments_on_order self
with_lock do
EnterpriseFee.clear_all_adjustments_on_order self
line_items.each do |line_item|
if provided_by_order_cycle? line_item
OpenFoodNetwork::EnterpriseFeeCalculator.new.create_line_item_adjustments_for line_item
line_items.each do |line_item|
if provided_by_order_cycle? line_item
OpenFoodNetwork::EnterpriseFeeCalculator.new.create_line_item_adjustments_for line_item
else
pd = product_distribution_for line_item
pd.create_adjustment_for line_item if pd
else
pd = product_distribution_for line_item
pd.create_adjustment_for line_item if pd
end
end
end
if order_cycle
OpenFoodNetwork::EnterpriseFeeCalculator.new.create_order_adjustments_for self
if order_cycle
OpenFoodNetwork::EnterpriseFeeCalculator.new.create_order_adjustments_for self
end
end
end

View File

@@ -1,7 +1,7 @@
.row.active_table_row{"ng-if" => "hub.is_distributor", "ng-click" => "toggle($event)", "ng-class" => "{'closed' : !open(), 'is_distributor' : producer.is_distributor}", bindonce: true}
.columns.small-12.medium-6.large-5.skinny-head
%a.hub{"bo-href" => "hub.path", "ng-class" => "{primary: hub.active, secondary: !hub.active}", "ofn-empties-cart" => "hub"}
.columns.small-12.medium-5.large-5.skinny-head
%a.hub{"bo-href" => "hub.path", "ng-class" => "{primary: hub.active, secondary: !hub.active}", "ofn-empties-cart" => "hub", "data-is-link" => "true"}
%i{bo: {class: "hub.icon_font"}}
%span.margin-top.hub-name-listing{"bo-bind" => "hub.name | truncate:40"}
@@ -10,7 +10,7 @@
.columns.small-2.medium-1.large-1
%span.margin-top{"bo-bind" => "hub.address.state_name | uppercase"}
.columns.small-6.medium-3.large-4.text-right{"bo-if" => "hub.active"}
.columns.small-4.medium-3.large-3.text-right{"bo-if" => "hub.active"}
%a.hub.open_closed{"bo-href" => "hub.path", "ng-class" => "{primary: hub.active, secondary: !hub.active}", "ofn-empties-cart" => "hub"}
%i.ofn-i_033-open-sign
%span.margin-top{ bo: { if: "current()" } }
@@ -18,13 +18,17 @@
%span.margin-top{ bo: { if: "!current()" } }
%span{"bo-bind" => "hub.orders_close_at | sensible_timeframe"}
.columns.small-6.medium-3.large-4.text-right{"bo-if" => "!hub.active"}
.columns.small-4.medium-3.large-3.text-right{"bo-if" => "!hub.active"}
%a.hub.open_closed{"bo-href" => "hub.path", "ng-class" => "{primary: hub.active, secondary: !hub.active}", "ofn-empties-cart" => "hub"}
%i.ofn-i_032-closed-sign
%span.margin-top{ bo: { if: "current()" } }
%em Shopping here
%span.margin-top{ bo: { if: "!current()" } } Orders closed
.columns.small-2.medium-1.large-1.text-right
%span.margin-top
%i{"ng-class" => "{'ofn-i_005-caret-down' : !open(), 'ofn-i_006-caret-up' : open()}"}
.row.active_table_row{"ng-if" => "!hub.is_distributor", "ng-class" => "closed"}
.columns.small-12.medium-6.large-5.skinny-head
%a.hub{"ng-click" => "openModal(hub)", "ng-class" => "{primary: hub.active, secondary: !hub.active}"}
@@ -39,3 +43,4 @@
.columns.small-6.medium-3.large-4.text-right
%span.margin-top{ bo: { if: "!current()" } }
%em Profile only

View File

@@ -1,27 +1,2 @@
preload_app true # https://newrelic.com/docs/ruby/no-data-with-unicorn
worker_processes 4 # amount of unicorn workers to spin up
timeout 60 # restarts workers that hang for 30 seconds
# https://devcenter.heroku.com/articles/forked-pg-connections
before_fork do |server, worker|
Signal.trap 'TERM' do
puts 'Unicorn master intercepting TERM and sending myself QUIT instead'
Process.kill 'QUIT', Process.pid
end
defined?(ActiveRecord::Base) and
ActiveRecord::Base.connection.disconnect!
end
after_fork do |server, worker|
Signal.trap 'TERM' do
puts 'Unicorn worker intercepting TERM and doing nothing. Wait for master to sent QUIT'
end
defined?(ActiveRecord::Base) and
ActiveRecord::Base.establish_connection
end
worker_processes 2 # amount of unicorn workers to spin up
timeout 120 # restarts workers that hang for 30 seconds

View File

@@ -212,7 +212,7 @@ FactoryGirl.define do
factory :customer, :class => Customer do
email { Faker::Internet.email }
enterprise
code { Faker::Lorem.word }
code { SecureRandom.base64(150) }
user
end
end

View File

@@ -117,31 +117,34 @@ feature %q{
end
end
scenario "creating a new product", js: true do
Spree::Config.products_require_tax_category = false
click_link 'Products'
click_link 'New Product'
context "products do not require a tax category" do
around { |example| with_products_require_tax_category(false) { example.run } }
fill_in 'product_name', :with => 'A new product !!!'
fill_in 'product_price', :with => '19.99'
scenario "creating a new product", js: true do
click_link 'Products'
click_link 'New Product'
page.should have_selector('#product_supplier_id')
select 'Another Supplier', :from => 'product_supplier_id'
select 'Weight (g)', from: 'product_variant_unit_with_scale'
fill_in 'product_unit_value_with_description', with: '500'
select taxon.name, from: "product_primary_taxon_id"
select 'None', from: "product_tax_category_id"
fill_in 'product_name', :with => 'A new product !!!'
fill_in 'product_price', :with => '19.99'
# Should only have suppliers listed which the user can manage
page.should have_select 'product_supplier_id', with_options: [@supplier2.name, @supplier_permitted.name]
page.should_not have_select 'product_supplier_id', with_options: [@supplier.name]
page.should have_selector('#product_supplier_id')
select 'Another Supplier', :from => 'product_supplier_id'
select 'Weight (g)', from: 'product_variant_unit_with_scale'
fill_in 'product_unit_value_with_description', with: '500'
select taxon.name, from: "product_primary_taxon_id"
select 'None', from: "product_tax_category_id"
click_button 'Create'
# Should only have suppliers listed which the user can manage
page.should have_select 'product_supplier_id', with_options: [@supplier2.name, @supplier_permitted.name]
page.should_not have_select 'product_supplier_id', with_options: [@supplier.name]
flash_message.should == 'Product "A new product !!!" has been successfully created!'
product = Spree::Product.find_by_name('A new product !!!')
product.supplier.should == @supplier2
product.tax_category.should be_nil
click_button 'Create'
flash_message.should == 'Product "A new product !!!" has been successfully created!'
product = Spree::Product.find_by_name('A new product !!!')
product.supplier.should == @supplier2
product.tax_category.should be_nil
end
end
scenario "editing a product" do

View File

@@ -40,7 +40,7 @@ module Spree
describe "tax category" do
context "when a tax category is required" do
before { Spree::Config.products_require_tax_category = true }
around { |example| with_products_require_tax_category(true) { example.run } }
it "is invalid when a tax category is not provided" do
build(:product, tax_category_id: nil).should_not be_valid
@@ -48,7 +48,7 @@ module Spree
end
context "when a tax category is not required" do
before { Spree::Config.products_require_tax_category = false }
around { |example| with_products_require_tax_category(false) { example.run } }
it "is valid when a tax category is not provided" do
build(:product, tax_category_id: nil).should be_valid

View File

@@ -80,6 +80,9 @@ RSpec.configure do |config|
# Geocoding
config.before(:each) { Spree::Address.any_instance.stub(:geocode).and_return([1,1]) }
# Ensure we start with consistent config settings
config.before(:all) { Spree::Config.products_require_tax_category = false }
# Helpers
config.include Rails.application.routes.url_helpers
config.include Spree::UrlHelpers
@@ -91,6 +94,7 @@ RSpec.configure do |config|
config.include OpenFoodNetwork::ControllerHelper, :type => :controller
config.include OpenFoodNetwork::FeatureToggleHelper
config.include OpenFoodNetwork::EnterpriseGroupsHelper
config.include OpenFoodNetwork::ProductsHelper
config.include OpenFoodNetwork::DistributionHelper
config.include OpenFoodNetwork::HtmlHelper
config.include ActionView::Helpers::DateHelper

View File

@@ -0,0 +1,12 @@
module OpenFoodNetwork
module ProductsHelper
def with_products_require_tax_category(value)
original_value = Spree::Config.products_require_tax_category
Spree::Config.products_require_tax_category = value
yield
ensure
Spree::Config.products_require_tax_category = original_value
end
end
end