From e98031e58111e6ddd321b24c242b880f2931f966 Mon Sep 17 00:00:00 2001 From: Will Marshall Date: Fri, 13 Dec 2013 10:12:41 +1100 Subject: [PATCH 01/16] Fixing some minor report bugs --- app/controllers/spree/admin/reports_controller_decorator.rb | 3 +++ app/views/spree/admin/reports/products_and_inventory.html.haml | 2 +- spec/features/admin/reports_spec.rb | 1 - 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/app/controllers/spree/admin/reports_controller_decorator.rb b/app/controllers/spree/admin/reports_controller_decorator.rb index bae1f36374..31ea232976 100644 --- a/app/controllers/spree/admin/reports_controller_decorator.rb +++ b/app/controllers/spree/admin/reports_controller_decorator.rb @@ -50,6 +50,8 @@ Spree::Admin::ReportsController.class_eval do @report_types = REPORT_TYPES[:customers] @report_type = params[:report_type] @report = OpenFoodNetwork::CustomersReport.new spree_current_user, params + + render_report(@report.header, @report.table, params[:csv], "customers.csv") end def orders_and_distributors @@ -557,6 +559,7 @@ Spree::Admin::ReportsController.class_eval do @report = OpenFoodNetwork::ProductsAndInventoryReport.new spree_current_user, params #@table = @report.table #@header = @report.header + render_report(@report.header, @report.table, params[:csv], "products_and_inventory.csv") end def render_report (header, table, create_csv, csv_file_name) diff --git a/app/views/spree/admin/reports/products_and_inventory.html.haml b/app/views/spree/admin/reports/products_and_inventory.html.haml index 23228ffb71..93859d0c58 100644 --- a/app/views/spree/admin/reports/products_and_inventory.html.haml +++ b/app/views/spree/admin/reports/products_and_inventory.html.haml @@ -20,7 +20,7 @@ %br = label_tag nil, "Report Type: " - = select_tag(:report_type, options_for_select(@report_types, @report_type)) + = select_tag(:report_type, options_for_select(@report_types, params[:report_type])) %br %br diff --git a/spec/features/admin/reports_spec.rb b/spec/features/admin/reports_spec.rb index 1b3a2055e9..a1e788a932 100644 --- a/spec/features/admin/reports_spec.rb +++ b/spec/features/admin/reports_spec.rb @@ -150,6 +150,5 @@ feature %q{ ].sort end end - end From 6e36142809b75ce20bc8fb40e7ec4359caa01d02 Mon Sep 17 00:00:00 2001 From: Will Marshall Date: Fri, 13 Dec 2013 11:39:45 +1100 Subject: [PATCH 02/16] Making some changes to the data on the products inventory page --- .../products_and_inventory_report.rb | 24 +++++++++++---- .../spree/admin/reports_controller_spec.rb | 4 +++ spec/features/admin/reports_spec.rb | 8 ++--- .../products_and_inventory_report_spec.rb | 30 ++++++++++++++----- 4 files changed, 49 insertions(+), 17 deletions(-) diff --git a/lib/open_food_network/products_and_inventory_report.rb b/lib/open_food_network/products_and_inventory_report.rb index 1dfc874906..2e6260f82f 100644 --- a/lib/open_food_network/products_and_inventory_report.rb +++ b/lib/open_food_network/products_and_inventory_report.rb @@ -8,17 +8,29 @@ module OpenFoodNetwork end def header - ["Supplier", "Product", "SKU", "Variant", "On Hand", "Price"] + [ + "Supplier", + "Producer Suburb", + "Product", + "Product Properties", + "Variant Value", + "Price", + "Group Buy Unit Quantity", + "Amount" + ] end def table variants.map do |variant| [variant.product.supplier.name, - variant.product.name, - variant.sku, - variant.options_text, - variant.count_on_hand, - variant.price] + variant.product.supplier.address.city, + variant.product.name, + variant.product.properties.map(&:name).join(", "), + variant.options_text, + variant.price, + variant.product.group_buy_unit_size, + "" + ] end end diff --git a/spec/controllers/spree/admin/reports_controller_spec.rb b/spec/controllers/spree/admin/reports_controller_spec.rb index af4268a8e0..64b4e27e2b 100644 --- a/spec/controllers/spree/admin/reports_controller_spec.rb +++ b/spec/controllers/spree/admin/reports_controller_spec.rb @@ -190,6 +190,8 @@ describe Spree::Admin::ReportsController do OpenFoodNetwork::ProductsAndInventoryReport.should_receive(:new) .with(user, {"test"=>"foo", "controller"=>"spree/admin/reports", "action"=>"products_and_inventory"}) .and_return(report = double(:report)) + report.stub(:header).and_return [] + report.stub(:table).and_return [] spree_get :products_and_inventory, :test => "foo" assigns(:report).should == report end @@ -236,6 +238,8 @@ describe Spree::Admin::ReportsController do OpenFoodNetwork::CustomersReport.should_receive(:new) .with(user, {"test"=>"foo", "controller"=>"spree/admin/reports", "action"=>"customers"}) .and_return(report = double(:report)) + report.stub(:header).and_return [] + report.stub(:table).and_return [] spree_get :customers, :test => "foo" assigns(:report).should == report end diff --git a/spec/features/admin/reports_spec.rb b/spec/features/admin/reports_spec.rb index a1e788a932..8f59e40d00 100644 --- a/spec/features/admin/reports_spec.rb +++ b/spec/features/admin/reports_spec.rb @@ -143,10 +143,10 @@ feature %q{ table = rows.map { |r| r.all("th,td").map { |c| c.text.strip } } table.sort.should == [ - ["Supplier", "Product", "SKU", "Variant", "On Hand", "Price"], - [product_1.supplier.name, "Product Name", variant_1.sku, "Size: Test", "10", "100.0"], - [product_1.supplier.name, "Product Name", variant_2.sku, "Size: S", "20", "80.0"], - [product_2.supplier.name, "Product 2", product_2.master.sku, "", "9", "99.0"] + ["Supplier", "Producer Suburb", "Product", "Product Properties", "Variant Value", "Price", "Group Buy Unit Quantity", "Amount"], + [product_1.supplier.name, product_1.supplier.address.city, "Product Name", product_1.properties.join(", "), "Size: Test", "100.0", product_1.group_buy_unit_size.to_s, ""], + [product_1.supplier.name, product_1.supplier.address.city, "Product Name", product_1.properties.join(", "), "Size: S", "80.0", product_1.group_buy_unit_size.to_s, ""], + [product_2.supplier.name, product_1.supplier.address.city, "Product 2", product_1.properties.join(", "), "", "99.0", product_1.group_buy_unit_size.to_s, ""] ].sort end end diff --git a/spec/lib/open_food_network/products_and_inventory_report_spec.rb b/spec/lib/open_food_network/products_and_inventory_report_spec.rb index 514dfd0ac1..c65d7bcae0 100644 --- a/spec/lib/open_food_network/products_and_inventory_report_spec.rb +++ b/spec/lib/open_food_network/products_and_inventory_report_spec.rb @@ -13,24 +13,40 @@ module OpenFoodNetwork end it "Should return headers" do - subject.header.should == ["Supplier", "Product", "SKU", "Variant", "On Hand", "Price"] + subject.header.should == [ + "Supplier", + "Producer Suburb", + "Product", + "Product Properties", + "Variant Value", + "Price", + "Group Buy Unit Quantity", + "Amount" + ] end it "should build a table from a list of variants" do variant = double(:variant, sku: "sku", - options_text: "Variant Name", - count_on_hand: 10, - price: 100) + options_text: "Variant Name", + count_on_hand: 10, + price: 100) variant.stub_chain(:product, :supplier, :name).and_return("Supplier") + variant.stub_chain(:product, :supplier, :address, :city).and_return("A city") variant.stub_chain(:product, :name).and_return("Product Name") + variant.stub_chain(:product, :properties).and_return [double(name: "test"), double(name: "foo")] + variant.stub_chain(:product, :group_buy_unit_size).and_return(21) subject.stub(:variants).and_return [variant] + subject.table.should == [[ "Supplier", + "A city", "Product Name", - "sku", + "test, foo", "Variant Name", - 10, - 100]] + 100, + 21, + "" + ]] end it "fetches variants for some params" do From 124b6df75d9f32335453f8e5a8d2ce9fa70da9ed Mon Sep 17 00:00:00 2001 From: Rohan Mitchell Date: Fri, 13 Dec 2013 14:51:43 +1100 Subject: [PATCH 03/16] Show undated order cycles on index page --- app/controllers/admin/order_cycles_controller.rb | 3 ++- app/helpers/order_cycles_helper.rb | 4 +++- app/models/order_cycle.rb | 12 +++++++++--- spec/features/admin/order_cycles_spec.rb | 8 ++++++-- spec/models/order_cycle_spec.rb | 14 ++++++++++++++ 5 files changed, 34 insertions(+), 7 deletions(-) diff --git a/app/controllers/admin/order_cycles_controller.rb b/app/controllers/admin/order_cycles_controller.rb index 26627caeed..46273d0eff 100644 --- a/app/controllers/admin/order_cycles_controller.rb +++ b/app/controllers/admin/order_cycles_controller.rb @@ -72,7 +72,8 @@ module Admin def collection ocs = OrderCycle.managed_by(spree_current_user) - ocs.soonest_closing + + ocs.undated + + ocs.soonest_closing + ocs.soonest_opening + ocs.most_recently_closed end diff --git a/app/helpers/order_cycles_helper.rb b/app/helpers/order_cycles_helper.rb index af5f16e10c..d20c667da7 100644 --- a/app/helpers/order_cycles_helper.rb +++ b/app/helpers/order_cycles_helper.rb @@ -18,7 +18,9 @@ module OrderCyclesHelper end def order_cycle_status_class(order_cycle) - if order_cycle.upcoming? + if order_cycle.undated? + 'undated' + elsif order_cycle.upcoming? 'upcoming' elsif order_cycle.open? 'open' diff --git a/app/models/order_cycle.rb b/app/models/order_cycle.rb index 362f1eb05a..877b932fd3 100644 --- a/app/models/order_cycle.rb +++ b/app/models/order_cycle.rb @@ -16,6 +16,7 @@ class OrderCycle < ActiveRecord::Base scope :inactive, lambda { where('order_cycles.orders_open_at > ? OR order_cycles.orders_close_at < ?', Time.now, Time.now) } scope :upcoming, lambda { where('order_cycles.orders_open_at > ?', Time.now) } scope :closed, lambda { where('order_cycles.orders_close_at < ?', Time.now) } + scope :undated, where(orders_open_at: nil, orders_close_at: nil) scope :distributing_product, lambda { |product| joins(:exchanges => :variants). @@ -111,16 +112,21 @@ class OrderCycle < ActiveRecord::Base self.variants.include? variant end + def undated? + self.orders_open_at.nil? && self.orders_close_at.nil? + end + def upcoming? - Time.now < self.orders_open_at + self.orders_open_at && Time.now < self.orders_open_at end def open? - Time.now > self.orders_open_at && Time.now < self.orders_close_at + self.orders_open_at && self.orders_close_at && + Time.now > self.orders_open_at && Time.now < self.orders_close_at end def closed? - Time.now > self.orders_close_at + self.orders_close_at && Time.now > self.orders_close_at end def exchange_for_distributor(distributor) diff --git a/spec/features/admin/order_cycles_spec.rb b/spec/features/admin/order_cycles_spec.rb index 34a8e72c85..4e6564756c 100644 --- a/spec/features/admin/order_cycles_spec.rb +++ b/spec/features/admin/order_cycles_spec.rb @@ -29,6 +29,8 @@ feature %q{ oc5 = create(:simple_order_cycle, name: '5', orders_open_at: 1.month.ago, orders_close_at: 2.weeks.ago) oc1 = create(:order_cycle, name: '1') + oc0 = create(:simple_order_cycle, name: '0', + orders_open_at: nil, orders_close_at: nil) # When I go to the admin order cycles page login_to_admin_section @@ -36,9 +38,10 @@ feature %q{ # Then the order cycles should be ordered correctly page.all('#listing_order_cycles tr td:first-child').map(&:text).should == - ['1', '2', '3', '4', '5', '6'] + ['0', '1', '2', '3', '4', '5', '6'] # And the rows should have the correct classes + page.should have_selector "#listing_order_cycles tr.order-cycle-#{oc0.id}.undated" page.should have_selector "#listing_order_cycles tr.order-cycle-#{oc1.id}.open" page.should have_selector "#listing_order_cycles tr.order-cycle-#{oc2.id}.open" page.should have_selector "#listing_order_cycles tr.order-cycle-#{oc3.id}.upcoming" @@ -47,7 +50,8 @@ feature %q{ page.should have_selector "#listing_order_cycles tr.order-cycle-#{oc6.id}.closed" # And I should see all the details for an order cycle - within('table#listing_order_cycles tbody tr:first-child') do + # (the table includes a hidden field between each row, making this nth-child(3) instead of 2) + within('table#listing_order_cycles tbody tr:nth-child(3)') do # Then I should see the basic fields page.should have_selector 'a', text: oc1.name diff --git a/spec/models/order_cycle_spec.rb b/spec/models/order_cycle_spec.rb index 1f3f4a0ad2..c4eeb37b3c 100644 --- a/spec/models/order_cycle_spec.rb +++ b/spec/models/order_cycle_spec.rb @@ -34,11 +34,13 @@ describe OrderCycle do oc_active = create(:simple_order_cycle, orders_open_at: 1.week.ago, orders_close_at: 1.week.from_now) oc_not_yet_open = create(:simple_order_cycle, orders_open_at: 1.week.from_now, orders_close_at: 2.weeks.from_now) oc_already_closed = create(:simple_order_cycle, orders_open_at: 2.weeks.ago, orders_close_at: 1.week.ago) + oc_undated = create(:simple_order_cycle, orders_open_at: nil, orders_close_at: nil) OrderCycle.active.should == [oc_active] OrderCycle.inactive.sort.should == [oc_not_yet_open, oc_already_closed].sort OrderCycle.upcoming.should == [oc_not_yet_open] OrderCycle.closed.should == [oc_already_closed] + OrderCycle.undated.should == [oc_undated] end it "finds order cycles accessible by a user" do @@ -248,6 +250,7 @@ describe OrderCycle do it "reports status when an order cycle is upcoming" do Timecop.freeze(oc.orders_open_at - 1.second) do + oc.should_not be_undated oc.should be_upcoming oc.should_not be_open oc.should_not be_closed @@ -255,6 +258,7 @@ describe OrderCycle do end it "reports status when an order cycle is open" do + oc.should_not be_undated oc.should_not be_upcoming oc.should be_open oc.should_not be_closed @@ -262,11 +266,21 @@ describe OrderCycle do it "reports status when an order cycle has closed" do Timecop.freeze(oc.orders_close_at + 1.second) do + oc.should_not be_undated oc.should_not be_upcoming oc.should_not be_open oc.should be_closed end end + + it "reports status when an order cycle is undated" do + oc.update_attributes!(orders_open_at: nil, orders_close_at: nil) + + oc.should be_undated + oc.should_not be_upcoming + oc.should_not be_open + oc.should_not be_closed + end end it "clones itself" do From 12743850b42ff40207ad2d21701f072d1143b860 Mon Sep 17 00:00:00 2001 From: Will Marshall Date: Fri, 13 Dec 2013 14:57:27 +1100 Subject: [PATCH 04/16] Removing a chili, refactoring order mailer --- Gemfile | 2 +- Gemfile.lock | 8 ---- .../application.css | 0 .../feature.css | 0 app/mailers/spree/order_mailer_decorator.rb | 10 +++++ app/models/order_cycle.rb | 4 ++ .../add_distributor_info.html.haml.deface | 0 ...name_extended_description.html.haml.deface | 0 .../add_distributor_info.html.haml.deface | 0 ...name_extended_description.html.haml.deface | 0 .../rich_text.html.haml.deface | 0 .../spree_application/assets.html.erb.deface | 0 .../spree/order_mailer/confirm_email.text.erb | 39 +++++++++--------- ...945_add_distributor_info_to_enterprises.rb | 0 .../.gitignore | 3 -- .../README.rdoc | 3 -- .../.gitkeep | 0 .../application.js | 13 ------ ...nfirm_email_with_distributor_info.text.erb | 40 ------------------- .../config/routes.rb | 3 -- ...distributor_info_rich_text_feature.gemspec | 22 ---------- ...ises_distributor_info_rich_text_feature.rb | 7 ---- .../engine.rb | 23 ----------- .../version.rb | 3 -- ...ibutor_info_rich_text_feature_generator.rb | 3 -- spec/helpers/order_cycles_helper_spec.rb | 1 + spec/mailers/order_mailer_spec.rb | 36 +++++++++++++++++ spec/models/order_cycle_spec.rb | 8 +++- 28 files changed, 80 insertions(+), 148 deletions(-) rename {lib/chili/enterprises_distributor_info_rich_text_feature/app => app}/assets/stylesheets/enterprises_distributor_info_rich_text_feature/application.css (100%) rename {lib/chili/enterprises_distributor_info_rich_text_feature/app => app}/assets/stylesheets/enterprises_distributor_info_rich_text_feature/feature.css (100%) rename {lib/chili/enterprises_distributor_info_rich_text_feature/app => app}/overrides/admin/enterprises/_form/add_distributor_info.html.haml.deface (100%) rename {lib/chili/enterprises_distributor_info_rich_text_feature/app => app}/overrides/admin/enterprises/_form/rename_extended_description.html.haml.deface (100%) rename {lib/chili/enterprises_distributor_info_rich_text_feature/app => app}/overrides/admin/enterprises/show/add_distributor_info.html.haml.deface (100%) rename {lib/chili/enterprises_distributor_info_rich_text_feature/app => app}/overrides/admin/enterprises/show/rename_extended_description.html.haml.deface (100%) rename {lib/chili/enterprises_distributor_info_rich_text_feature/app => app}/overrides/enterprises/_distributor_details/rich_text.html.haml.deface (100%) rename {lib/chili/enterprises_distributor_info_rich_text_feature/app => app}/overrides/spree/layouts/spree_application/assets.html.erb.deface (100%) rename {lib/chili/enterprises_distributor_info_rich_text_feature/db => db}/migrate/20130426022945_add_distributor_info_to_enterprises.rb (100%) delete mode 100644 lib/chili/enterprises_distributor_info_rich_text_feature/.gitignore delete mode 100644 lib/chili/enterprises_distributor_info_rich_text_feature/README.rdoc delete mode 100644 lib/chili/enterprises_distributor_info_rich_text_feature/app/assets/images/enterprises_distributor_info_rich_text_feature/.gitkeep delete mode 100644 lib/chili/enterprises_distributor_info_rich_text_feature/app/assets/javascripts/enterprises_distributor_info_rich_text_feature/application.js delete mode 100644 lib/chili/enterprises_distributor_info_rich_text_feature/app/views/spree/order_mailer/confirm_email_with_distributor_info.text.erb delete mode 100644 lib/chili/enterprises_distributor_info_rich_text_feature/config/routes.rb delete mode 100644 lib/chili/enterprises_distributor_info_rich_text_feature/enterprises_distributor_info_rich_text_feature.gemspec delete mode 100644 lib/chili/enterprises_distributor_info_rich_text_feature/lib/enterprises_distributor_info_rich_text_feature.rb delete mode 100644 lib/chili/enterprises_distributor_info_rich_text_feature/lib/enterprises_distributor_info_rich_text_feature/engine.rb delete mode 100644 lib/chili/enterprises_distributor_info_rich_text_feature/lib/enterprises_distributor_info_rich_text_feature/version.rb delete mode 100644 lib/chili/enterprises_distributor_info_rich_text_feature/lib/generators/enterprises_distributor_info_rich_text_feature_generator.rb create mode 100644 spec/mailers/order_mailer_spec.rb diff --git a/Gemfile b/Gemfile index d6d772203f..d26ac871a2 100644 --- a/Gemfile +++ b/Gemfile @@ -78,7 +78,7 @@ group :test do end group :chili do - gem 'enterprises_distributor_info_rich_text_feature', path: 'lib/chili/enterprises_distributor_info_rich_text_feature' + #gem 'enterprises_distributor_info_rich_text_feature', path: 'lib/chili/enterprises_distributor_info_rich_text_feature' gem 'eaterprises_feature', path: 'lib/chili/eaterprises_feature' gem 'local_organics_feature', path: 'lib/chili/local_organics_feature' end diff --git a/Gemfile.lock b/Gemfile.lock index 82921527d5..11c366f984 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -107,13 +107,6 @@ PATH chili (~> 3.1) rails (~> 3.2.11) -PATH - remote: lib/chili/enterprises_distributor_info_rich_text_feature - specs: - enterprises_distributor_info_rich_text_feature (0.0.1) - chili (~> 3.1) - rails (~> 3.2.11) - PATH remote: lib/chili/local_organics_feature specs: @@ -479,7 +472,6 @@ DEPENDENCIES debugger-linecache deface! eaterprises_feature! - enterprises_distributor_info_rich_text_feature! factory_girl_rails faker geocoder diff --git a/lib/chili/enterprises_distributor_info_rich_text_feature/app/assets/stylesheets/enterprises_distributor_info_rich_text_feature/application.css b/app/assets/stylesheets/enterprises_distributor_info_rich_text_feature/application.css similarity index 100% rename from lib/chili/enterprises_distributor_info_rich_text_feature/app/assets/stylesheets/enterprises_distributor_info_rich_text_feature/application.css rename to app/assets/stylesheets/enterprises_distributor_info_rich_text_feature/application.css diff --git a/lib/chili/enterprises_distributor_info_rich_text_feature/app/assets/stylesheets/enterprises_distributor_info_rich_text_feature/feature.css b/app/assets/stylesheets/enterprises_distributor_info_rich_text_feature/feature.css similarity index 100% rename from lib/chili/enterprises_distributor_info_rich_text_feature/app/assets/stylesheets/enterprises_distributor_info_rich_text_feature/feature.css rename to app/assets/stylesheets/enterprises_distributor_info_rich_text_feature/feature.css diff --git a/app/mailers/spree/order_mailer_decorator.rb b/app/mailers/spree/order_mailer_decorator.rb index 1ce563ad56..f95912b591 100644 --- a/app/mailers/spree/order_mailer_decorator.rb +++ b/app/mailers/spree/order_mailer_decorator.rb @@ -1,3 +1,13 @@ Spree::OrderMailer.class_eval do helper HtmlHelper + helper CheckoutHelper + def confirm_email(order, resend = false) + find_order(order) + subject = (resend ? "[#{t(:resend).upcase}] " : '') + subject += "#{Spree::Config[:site_name]} #{t('order_mailer.confirm_email.subject')} ##{@order.number}" + mail(:to => @order.email, + :from => order.distributor.email || from_address, + :subject => subject, + :cc => "orders@openfoodnetwork.org") + end end diff --git a/app/models/order_cycle.rb b/app/models/order_cycle.rb index 877b932fd3..187a93e0ef 100644 --- a/app/models/order_cycle.rb +++ b/app/models/order_cycle.rb @@ -137,6 +137,10 @@ class OrderCycle < ActiveRecord::Base exchange_for_distributor(distributor).andand.pickup_time || distributor.next_collection_at end + def pickup_instructions_for(distributor) + exchange_for_distributor(distributor).andand.pickup_instructions + end + # -- Fees def create_adjustments_for(line_item) diff --git a/lib/chili/enterprises_distributor_info_rich_text_feature/app/overrides/admin/enterprises/_form/add_distributor_info.html.haml.deface b/app/overrides/admin/enterprises/_form/add_distributor_info.html.haml.deface similarity index 100% rename from lib/chili/enterprises_distributor_info_rich_text_feature/app/overrides/admin/enterprises/_form/add_distributor_info.html.haml.deface rename to app/overrides/admin/enterprises/_form/add_distributor_info.html.haml.deface diff --git a/lib/chili/enterprises_distributor_info_rich_text_feature/app/overrides/admin/enterprises/_form/rename_extended_description.html.haml.deface b/app/overrides/admin/enterprises/_form/rename_extended_description.html.haml.deface similarity index 100% rename from lib/chili/enterprises_distributor_info_rich_text_feature/app/overrides/admin/enterprises/_form/rename_extended_description.html.haml.deface rename to app/overrides/admin/enterprises/_form/rename_extended_description.html.haml.deface diff --git a/lib/chili/enterprises_distributor_info_rich_text_feature/app/overrides/admin/enterprises/show/add_distributor_info.html.haml.deface b/app/overrides/admin/enterprises/show/add_distributor_info.html.haml.deface similarity index 100% rename from lib/chili/enterprises_distributor_info_rich_text_feature/app/overrides/admin/enterprises/show/add_distributor_info.html.haml.deface rename to app/overrides/admin/enterprises/show/add_distributor_info.html.haml.deface diff --git a/lib/chili/enterprises_distributor_info_rich_text_feature/app/overrides/admin/enterprises/show/rename_extended_description.html.haml.deface b/app/overrides/admin/enterprises/show/rename_extended_description.html.haml.deface similarity index 100% rename from lib/chili/enterprises_distributor_info_rich_text_feature/app/overrides/admin/enterprises/show/rename_extended_description.html.haml.deface rename to app/overrides/admin/enterprises/show/rename_extended_description.html.haml.deface diff --git a/lib/chili/enterprises_distributor_info_rich_text_feature/app/overrides/enterprises/_distributor_details/rich_text.html.haml.deface b/app/overrides/enterprises/_distributor_details/rich_text.html.haml.deface similarity index 100% rename from lib/chili/enterprises_distributor_info_rich_text_feature/app/overrides/enterprises/_distributor_details/rich_text.html.haml.deface rename to app/overrides/enterprises/_distributor_details/rich_text.html.haml.deface diff --git a/lib/chili/enterprises_distributor_info_rich_text_feature/app/overrides/spree/layouts/spree_application/assets.html.erb.deface b/app/overrides/spree/layouts/spree_application/assets.html.erb.deface similarity index 100% rename from lib/chili/enterprises_distributor_info_rich_text_feature/app/overrides/spree/layouts/spree_application/assets.html.erb.deface rename to app/overrides/spree/layouts/spree_application/assets.html.erb.deface diff --git a/app/views/spree/order_mailer/confirm_email.text.erb b/app/views/spree/order_mailer/confirm_email.text.erb index 3277ccaf00..34356401cd 100644 --- a/app/views/spree/order_mailer/confirm_email.text.erb +++ b/app/views/spree/order_mailer/confirm_email.text.erb @@ -5,37 +5,40 @@ Please review and retain the following order information for your records. ============================================================ Order Summary ============================================================ -Order for: <%= @order.bill_address.full_name %> +Order for: <%= @order.bill_address.full_name %> <% @order.line_items.each do |item| %> - <%= item.variant.sku %> <%= raw(item.variant.product.name) %> <%= raw(item.variant.options_text) -%> (<%=item.quantity%>) @ <%= item.single_money %> = <%= item.display_amount %> + <%= item.variant.sku %> <%= raw(item.variant.product.supplier.name) %> <%= raw(item.variant.product.name) %> <%= raw(item.variant.options_text) -%> (<%=item.quantity%>) @ <%= item.single_money %> = <%= item.display_amount %> <% end %> ============================================================ Subtotal: <%= @order.display_item_total %> -<% @order.adjustments.each do |adjustment| %> - <%= raw(adjustment.label) %> <%= adjustment.display_amount %> +<% checkout_adjustments_for_summary(@order).each do |adjustment| %> + <%= raw(adjustment.label) %> <%= adjustment.display_amount %> <% end %> Order Total: <%= @order.display_total %> -<% if @order.payments.first.payment_method.name.include? "EFT" %> +<% if @order.payments.first.andand.payment_method.andand.name.andand.include? "EFT" %> ============================================================ Payment Details ============================================================ -<%= @order.payments.first.payment_method.description.html_safe %> +<%= @order.payments.first.andand.payment_method.andand.description.andand.html_safe %> <% end %> ============================================================ Collection / Delivery Details ============================================================ -Address: - <%= @order.distributor.name %> - <% address = @order.distributor.address %> - <%= address.address1 %> <%= ",\n #{address.address2}" unless address.address2.blank? %> - <%= [address.city, address.state_text, address.zipcode, address.country.name].compact.join ', ' %> -Collection time: - <%= @order.distributor.next_collection_at %> -Contact: - <%= @order.distributor.contact %> - <%= "Phone: #{@order.distributor.phone}" %> - <%= "Email: #{@order.distributor.email}" %> +<%= raw strip_html @order.distributor.distributor_info %> -Thank you for your business. +<% if @order.order_cycle %> +<%= @order.order_cycle.pickup_time_for(@order.distributor) %> +<%= @order.order_cycle.pickup_instructions_for(@order.distributor) %> +<% else %> +<%= @order.distributor.next_collection_at %> +<% end %> + +Thanks for your support. + +<%= @order.distributor.contact %>, +<%= @order.distributor.name %> +<%= @order.distributor.phone %> +<%= @order.distributor.email %> +<%= @order.distributor.website %> diff --git a/lib/chili/enterprises_distributor_info_rich_text_feature/db/migrate/20130426022945_add_distributor_info_to_enterprises.rb b/db/migrate/20130426022945_add_distributor_info_to_enterprises.rb similarity index 100% rename from lib/chili/enterprises_distributor_info_rich_text_feature/db/migrate/20130426022945_add_distributor_info_to_enterprises.rb rename to db/migrate/20130426022945_add_distributor_info_to_enterprises.rb diff --git a/lib/chili/enterprises_distributor_info_rich_text_feature/.gitignore b/lib/chili/enterprises_distributor_info_rich_text_feature/.gitignore deleted file mode 100644 index 8619e09c5a..0000000000 --- a/lib/chili/enterprises_distributor_info_rich_text_feature/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -.bundle/ -log/*.log -pkg/ diff --git a/lib/chili/enterprises_distributor_info_rich_text_feature/README.rdoc b/lib/chili/enterprises_distributor_info_rich_text_feature/README.rdoc deleted file mode 100644 index fd60a25911..0000000000 --- a/lib/chili/enterprises_distributor_info_rich_text_feature/README.rdoc +++ /dev/null @@ -1,3 +0,0 @@ -= EnterprisesDistributorInfoRichTextFeature - -This project rocks and uses MIT-LICENSE. \ No newline at end of file diff --git a/lib/chili/enterprises_distributor_info_rich_text_feature/app/assets/images/enterprises_distributor_info_rich_text_feature/.gitkeep b/lib/chili/enterprises_distributor_info_rich_text_feature/app/assets/images/enterprises_distributor_info_rich_text_feature/.gitkeep deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/lib/chili/enterprises_distributor_info_rich_text_feature/app/assets/javascripts/enterprises_distributor_info_rich_text_feature/application.js b/lib/chili/enterprises_distributor_info_rich_text_feature/app/assets/javascripts/enterprises_distributor_info_rich_text_feature/application.js deleted file mode 100644 index 15ebed9422..0000000000 --- a/lib/chili/enterprises_distributor_info_rich_text_feature/app/assets/javascripts/enterprises_distributor_info_rich_text_feature/application.js +++ /dev/null @@ -1,13 +0,0 @@ -// This is a manifest file that'll be compiled into application.js, which will include all the files -// listed below. -// -// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts, -// or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path. -// -// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the -// the compiled file. -// -// WARNING: THE FIRST BLANK LINE MARKS THE END OF WHAT'S TO BE PROCESSED, ANY BLANK LINE SHOULD -// GO AFTER THE REQUIRES BELOW. -// -//= require_tree . diff --git a/lib/chili/enterprises_distributor_info_rich_text_feature/app/views/spree/order_mailer/confirm_email_with_distributor_info.text.erb b/lib/chili/enterprises_distributor_info_rich_text_feature/app/views/spree/order_mailer/confirm_email_with_distributor_info.text.erb deleted file mode 100644 index c47cdd7b7b..0000000000 --- a/lib/chili/enterprises_distributor_info_rich_text_feature/app/views/spree/order_mailer/confirm_email_with_distributor_info.text.erb +++ /dev/null @@ -1,40 +0,0 @@ -Dear <%= @order.bill_address.firstname %>, - -Please review and retain the following order information for your records. - -============================================================ -Order Summary -============================================================ -Order for: <%= @order.bill_address.full_name %> -<% @order.line_items.each do |item| %> - <%= item.variant.sku %> <%= raw(item.variant.product.name) %> <%= raw(item.variant.options_text) -%> (<%=item.quantity%>) @ <%= item.single_money %> = <%= item.display_amount %> -<% end %> -============================================================ -Subtotal: <%= @order.display_item_total %> -<% checkout_adjustments_for_summary(@order).each do |adjustment| %> - <%= raw(adjustment.label) %> <%= adjustment.display_amount %> -<% end %> -Order Total: <%= @order.display_total %> - -<% if @order.payments.first.payment_method.name.include? "EFT" %> -============================================================ -Payment Details -============================================================ -<%= @order.payments.first.payment_method.description.html_safe %> - -<% end %> -============================================================ -Collection / Delivery Details -============================================================ -<%= raw strip_html @order.distributor.distributor_info %> -<% if @order.order_cycle %> -<%= @order.order_cycle.pickup_time_for(@order.distributor) %> -<% else %> -<%= @order.distributor.next_collection_at %> -<% end %> - - -Thanks for your support. - -<%= @order.distributor.contact %>, -<%= @order.distributor.name %> diff --git a/lib/chili/enterprises_distributor_info_rich_text_feature/config/routes.rb b/lib/chili/enterprises_distributor_info_rich_text_feature/config/routes.rb deleted file mode 100644 index 910ef99eca..0000000000 --- a/lib/chili/enterprises_distributor_info_rich_text_feature/config/routes.rb +++ /dev/null @@ -1,3 +0,0 @@ -EnterprisesDistributorInfoRichTextFeature::Engine.automount! -EnterprisesDistributorInfoRichTextFeature::Engine.routes.draw do -end diff --git a/lib/chili/enterprises_distributor_info_rich_text_feature/enterprises_distributor_info_rich_text_feature.gemspec b/lib/chili/enterprises_distributor_info_rich_text_feature/enterprises_distributor_info_rich_text_feature.gemspec deleted file mode 100644 index 1e230928b9..0000000000 --- a/lib/chili/enterprises_distributor_info_rich_text_feature/enterprises_distributor_info_rich_text_feature.gemspec +++ /dev/null @@ -1,22 +0,0 @@ -$:.push File.expand_path("../lib", __FILE__) - -# Maintain your gem's version: -require "enterprises_distributor_info_rich_text_feature/version" - -# Describe your gem and declare its dependencies: -Gem::Specification.new do |s| - s.name = "enterprises_distributor_info_rich_text_feature" - s.version = EnterprisesDistributorInfoRichTextFeature::VERSION - s.authors = ["Rohan Mitchell"] - s.email = ["rohan@rohanmitchell.com"] - s.homepage = "" - s.summary = "Summary of EnterprisesDistributorInfoRichTextFeature." - s.description = "Description of EnterprisesDistributorInfoRichTextFeature." - - s.files = Dir["{app,config,db,lib}/**/*"] + ["README.rdoc"] - - s.add_dependency "rails", "~> 3.2.11" - s.add_dependency 'chili', '~> 3.1' - - s.add_development_dependency "sqlite3" -end diff --git a/lib/chili/enterprises_distributor_info_rich_text_feature/lib/enterprises_distributor_info_rich_text_feature.rb b/lib/chili/enterprises_distributor_info_rich_text_feature/lib/enterprises_distributor_info_rich_text_feature.rb deleted file mode 100644 index c8cc1e8333..0000000000 --- a/lib/chili/enterprises_distributor_info_rich_text_feature/lib/enterprises_distributor_info_rich_text_feature.rb +++ /dev/null @@ -1,7 +0,0 @@ -require "chili" -require "enterprises_distributor_info_rich_text_feature/engine" - -module EnterprisesDistributorInfoRichTextFeature - extend Chili::Base - active_if { OpenFoodNetwork::FeatureToggle.enabled? :enterprises_distributor_info_rich_text } -end diff --git a/lib/chili/enterprises_distributor_info_rich_text_feature/lib/enterprises_distributor_info_rich_text_feature/engine.rb b/lib/chili/enterprises_distributor_info_rich_text_feature/lib/enterprises_distributor_info_rich_text_feature/engine.rb deleted file mode 100644 index 807aee52d0..0000000000 --- a/lib/chili/enterprises_distributor_info_rich_text_feature/lib/enterprises_distributor_info_rich_text_feature/engine.rb +++ /dev/null @@ -1,23 +0,0 @@ -require_relative '../../../../open_food_network/feature_toggle' - -module EnterprisesDistributorInfoRichTextFeature - class Engine < ::Rails::Engine - isolate_namespace EnterprisesDistributorInfoRichTextFeature - - initializer 'enterprises_distributor_info_rich_text_feature.mailer', :after => :load_config_initializers do |app| - if OpenFoodNetwork::FeatureToggle.enabled? :enterprises_distributor_info_rich_text - ::Spree::OrderMailer.class_eval do - helper CheckoutHelper - - def confirm_email(order, resend = false) - find_order(order) - subject = (resend ? "[#{t(:resend).upcase}] " : '') - subject += "#{Spree::Config[:site_name]} #{t('order_mailer.confirm_email.subject')} ##{@order.number}" - mail(:to => @order.email, :from => from_address, :subject => subject, - :template_name => 'confirm_email_with_distributor_info') - end - end - end - end - end -end diff --git a/lib/chili/enterprises_distributor_info_rich_text_feature/lib/enterprises_distributor_info_rich_text_feature/version.rb b/lib/chili/enterprises_distributor_info_rich_text_feature/lib/enterprises_distributor_info_rich_text_feature/version.rb deleted file mode 100644 index f413fbd728..0000000000 --- a/lib/chili/enterprises_distributor_info_rich_text_feature/lib/enterprises_distributor_info_rich_text_feature/version.rb +++ /dev/null @@ -1,3 +0,0 @@ -module EnterprisesDistributorInfoRichTextFeature - VERSION = "0.0.1" -end diff --git a/lib/chili/enterprises_distributor_info_rich_text_feature/lib/generators/enterprises_distributor_info_rich_text_feature_generator.rb b/lib/chili/enterprises_distributor_info_rich_text_feature/lib/generators/enterprises_distributor_info_rich_text_feature_generator.rb deleted file mode 100644 index 9124250abe..0000000000 --- a/lib/chili/enterprises_distributor_info_rich_text_feature/lib/generators/enterprises_distributor_info_rich_text_feature_generator.rb +++ /dev/null @@ -1,3 +0,0 @@ -class EnterprisesDistributorInfoRichTextFeatureGenerator < Rails::Generators::Base - include Chili::GeneratorProxy -end diff --git a/spec/helpers/order_cycles_helper_spec.rb b/spec/helpers/order_cycles_helper_spec.rb index df5c11982d..45eab95396 100644 --- a/spec/helpers/order_cycles_helper_spec.rb +++ b/spec/helpers/order_cycles_helper_spec.rb @@ -32,4 +32,5 @@ describe OrderCyclesHelper do helper.stub!(:current_distributor).and_return d helper.pickup_time.should == "turtles" end + end diff --git a/spec/mailers/order_mailer_spec.rb b/spec/mailers/order_mailer_spec.rb new file mode 100644 index 0000000000..383327f53b --- /dev/null +++ b/spec/mailers/order_mailer_spec.rb @@ -0,0 +1,36 @@ +require 'spec_helper' + +describe Spree::OrderMailer do + after do + ActionMailer::Base.deliveries.clear + end + + before do + ActionMailer::Base.delivery_method = :test + ActionMailer::Base.perform_deliveries = true + ActionMailer::Base.deliveries = [] + + @bill_address = create(:address) + @distributor_address = create(:address, :address1 => "distributor address", :city => 'The Shire', :zipcode => "1234") + @distributor = create(:distributor_enterprise, :address => @distributor_address) + product = create(:product) + product_distribution = create(:product_distribution, :product => product, :distributor => @distributor) + @shipping_instructions = "pick up on thursday please!" + @order1 = create(:order, :distributor => @distributor, :bill_address => @bill_address, :special_instructions => @shipping_instructions) + end + + it "should send an email when given an order" do + Spree::OrderMailer.confirm_email(@order1).deliver + ActionMailer::Base.deliveries.count.should == 1 + end + + it "should send the email from the enterprise email" do + Spree::OrderMailer.confirm_email(@order1).deliver + ActionMailer::Base.deliveries.first.from.should == [@distributor.email] + end + + it "should cc orders" do + Spree::OrderMailer.confirm_email(@order1).deliver + ActionMailer::Base.deliveries.first.cc.should == ["orders@openfoodnetwork.org"] + end +end diff --git a/spec/models/order_cycle_spec.rb b/spec/models/order_cycle_spec.rb index c4eeb37b3c..9b024b058e 100644 --- a/spec/models/order_cycle_spec.rb +++ b/spec/models/order_cycle_spec.rb @@ -225,7 +225,7 @@ describe OrderCycle do @d2 = create(:enterprise, next_collection_at: '2-8pm Friday') @e0 = create(:exchange, order_cycle: @oc, sender: create(:enterprise), receiver: @oc.coordinator) - @e1 = create(:exchange, order_cycle: @oc, sender: @oc.coordinator, receiver: @d1, pickup_time: '5pm Tuesday') + @e1 = create(:exchange, order_cycle: @oc, sender: @oc.coordinator, receiver: @d1, pickup_time: '5pm Tuesday', pickup_instructions: "Come get it!") @e2 = create(:exchange, order_cycle: @oc, sender: @oc.coordinator, receiver: @d2, pickup_time: nil) end @@ -243,6 +243,12 @@ describe OrderCycle do @oc.pickup_time_for(@d2).should == '2-8pm Friday' end end + + describe "finding pickup instructions for a distributor" do + it "returns the pickup instructions" do + @oc.pickup_instructions_for(@d1).should == "Come get it!" + end + end end describe "checking status" do From 92b3d496a4fe4516f35a99b8b6db139e1ada83ac Mon Sep 17 00:00:00 2001 From: Will Marshall Date: Fri, 13 Dec 2013 15:00:56 +1100 Subject: [PATCH 05/16] Fixing the bugherd script to use the production one --- app/views/layouts/_bugherd_script.html.haml | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/app/views/layouts/_bugherd_script.html.haml b/app/views/layouts/_bugherd_script.html.haml index f66f865137..326c48da00 100644 --- a/app/views/layouts/_bugherd_script.html.haml +++ b/app/views/layouts/_bugherd_script.html.haml @@ -1,4 +1,4 @@ -- if Rails.env.staging? or Rails.env.production? +- if Rails.env.staging? :javascript (function (d, t) { var bh = d.createElement(t), s = d.getElementsByTagName(t)[0]; @@ -6,3 +6,12 @@ bh.src = '//www.bugherd.com/sidebarv2.js?apikey=4ftxjbgwx7y6ssykayr04w'; s.parentNode.insertBefore(bh, s); })(document, 'script'); + +- elsif Rails.env.production? + :javascript + (function (d, t) { + var bh = d.createElement(t), s = d.getElementsByTagName(t)[0]; + bh.type = 'text/javascript'; + bh.src = '//www.bugherd.com/sidebarv2.js?apikey=xro3uv55objies58o2wrua'; + s.parentNode.insertBefore(bh, s); + })(document, 'script'); From f6af9e78accabd192896d4653b9567abbeafa138 Mon Sep 17 00:00:00 2001 From: Will Marshall Date: Fri, 13 Dec 2013 15:05:07 +1100 Subject: [PATCH 06/16] Adding destroy ability to enterprise users --- app/models/spree/ability_decorator.rb | 2 +- spec/models/spree/ability_spec.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/models/spree/ability_decorator.rb b/app/models/spree/ability_decorator.rb index ed018c4fee..c6407c1f98 100644 --- a/app/models/spree/ability_decorator.rb +++ b/app/models/spree/ability_decorator.rb @@ -14,7 +14,7 @@ class AbilityDecorator user.enterprises.include? product.supplier end - can [:admin, :index, :read, :create, :edit, :update, :search], Spree::Variant + can [:admin, :index, :read, :create, :edit, :update, :search, :destroy], Spree::Variant can [:admin, :index, :read, :create, :edit], Spree::ProductProperty can [:admin, :index, :read, :create, :edit], Spree::Image diff --git a/spec/models/spree/ability_spec.rb b/spec/models/spree/ability_spec.rb index c7d96c32c5..35020aede5 100644 --- a/spec/models/spree/ability_spec.rb +++ b/spec/models/spree/ability_spec.rb @@ -44,7 +44,7 @@ module Spree end it "should be able to read/write their enterprises' product variants" do - should have_ability([:admin, :index, :read, :create, :edit, :search, :update], for: Spree::Variant) + should have_ability([:admin, :index, :read, :create, :edit, :search, :update, :destroy], for: Spree::Variant) end it "should be able to read/write their enterprises' product properties" do From 63349c7c9a88c5a45d3a984adc1920f41efffac6 Mon Sep 17 00:00:00 2001 From: Will Marshall Date: Fri, 13 Dec 2013 15:38:27 +1100 Subject: [PATCH 07/16] Fixing some breaking bugs in the refactored mailer --- app/mailers/spree/order_mailer_decorator.rb | 2 +- app/views/spree/order_mailer/confirm_email.text.erb | 2 +- ...nterprises_distributor_info_rich_text_feature_spec.rb | 9 ++++++++- spec/features/consumer/checkout_spec.rb | 6 +++--- spec/mailers/order_mailer_spec.rb | 6 +++--- 5 files changed, 16 insertions(+), 9 deletions(-) diff --git a/app/mailers/spree/order_mailer_decorator.rb b/app/mailers/spree/order_mailer_decorator.rb index f95912b591..03f9fcdfaf 100644 --- a/app/mailers/spree/order_mailer_decorator.rb +++ b/app/mailers/spree/order_mailer_decorator.rb @@ -6,7 +6,7 @@ Spree::OrderMailer.class_eval do subject = (resend ? "[#{t(:resend).upcase}] " : '') subject += "#{Spree::Config[:site_name]} #{t('order_mailer.confirm_email.subject')} ##{@order.number}" mail(:to => @order.email, - :from => order.distributor.email || from_address, + :from => @order.distributor.email || from_address, :subject => subject, :cc => "orders@openfoodnetwork.org") end diff --git a/app/views/spree/order_mailer/confirm_email.text.erb b/app/views/spree/order_mailer/confirm_email.text.erb index 34356401cd..e72fe48433 100644 --- a/app/views/spree/order_mailer/confirm_email.text.erb +++ b/app/views/spree/order_mailer/confirm_email.text.erb @@ -12,7 +12,7 @@ Order for: <%= @order.bill_address.full_name %> ============================================================ Subtotal: <%= @order.display_item_total %> <% checkout_adjustments_for_summary(@order).each do |adjustment| %> - <%= raw(adjustment.label) %> <%= adjustment.display_amount %> + <%= raw(adjustment.label) %> <%= adjustment.display_amount %> <% end %> Order Total: <%= @order.display_total %> diff --git a/spec/features/chili/enterprises_distributor_info_rich_text_feature_spec.rb b/spec/features/chili/enterprises_distributor_info_rich_text_feature_spec.rb index b0c985d423..a8c6c6c541 100644 --- a/spec/features/chili/enterprises_distributor_info_rich_text_feature_spec.rb +++ b/spec/features/chili/enterprises_distributor_info_rich_text_feature_spec.rb @@ -10,9 +10,16 @@ feature "enterprises distributor info as rich text" do enterprises_distributor_info_rich_text: true}) + ActionMailer::Base.delivery_method = :test + ActionMailer::Base.perform_deliveries = true + ActionMailer::Base.deliveries = [] # The deployment is not set to local_organics on Rails init, so these + # # initializers won't run. Re-call them now that the deployment is set. - EnterprisesDistributorInfoRichTextFeature::Engine.initializers.each &:run + end + + after do + ActionMailer::Base.deliveries.clear end diff --git a/spec/features/consumer/checkout_spec.rb b/spec/features/consumer/checkout_spec.rb index 3585ff6864..df4ea5500b 100644 --- a/spec/features/consumer/checkout_spec.rb +++ b/spec/features/consumer/checkout_spec.rb @@ -348,7 +348,7 @@ feature %q{ # -- Checkout: Email email = ActionMailer::Base.deliveries.last - email.body.should =~ /Distribution \$12.00/ + email.body.should =~ /Distribution[\s+]\$12.00/ end scenario "buying a product from an order cycle", :js => true do @@ -414,7 +414,7 @@ feature %q{ # -- Checkout: Email email = ActionMailer::Base.deliveries.last - email.body.should =~ /Distribution \$54.00/ + email.body.should =~ /Distribution[\s+]\$54.00/ end scenario "when I have past orders, it fills in my address", :js => true do @@ -497,7 +497,7 @@ feature %q{ # -- Checkout: Email email = ActionMailer::Base.deliveries.last - email.body.should =~ /Distribution \$54.00/ + email.body.should =~ /Distribution[\s+]\$54.00/ end diff --git a/spec/mailers/order_mailer_spec.rb b/spec/mailers/order_mailer_spec.rb index 383327f53b..3a8659cc0f 100644 --- a/spec/mailers/order_mailer_spec.rb +++ b/spec/mailers/order_mailer_spec.rb @@ -20,17 +20,17 @@ describe Spree::OrderMailer do end it "should send an email when given an order" do - Spree::OrderMailer.confirm_email(@order1).deliver + Spree::OrderMailer.confirm_email(@order1.id).deliver ActionMailer::Base.deliveries.count.should == 1 end it "should send the email from the enterprise email" do - Spree::OrderMailer.confirm_email(@order1).deliver + Spree::OrderMailer.confirm_email(@order1.id).deliver ActionMailer::Base.deliveries.first.from.should == [@distributor.email] end it "should cc orders" do - Spree::OrderMailer.confirm_email(@order1).deliver + Spree::OrderMailer.confirm_email(@order1.id).deliver ActionMailer::Base.deliveries.first.cc.should == ["orders@openfoodnetwork.org"] end end From 222ed2036118e9242d3a6b5353388c7530df1b10 Mon Sep 17 00:00:00 2001 From: Will Marshall Date: Fri, 13 Dec 2013 15:57:32 +1100 Subject: [PATCH 08/16] Defaulting to bulk products --- app/overrides/add_bulk_edit_tab_to_products_admin_sub_menu.rb | 2 +- app/views/spree/admin/shared/_tabs.html.erb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/overrides/add_bulk_edit_tab_to_products_admin_sub_menu.rb b/app/overrides/add_bulk_edit_tab_to_products_admin_sub_menu.rb index f6b6f94e9f..42d0120538 100644 --- a/app/overrides/add_bulk_edit_tab_to_products_admin_sub_menu.rb +++ b/app/overrides/add_bulk_edit_tab_to_products_admin_sub_menu.rb @@ -1,4 +1,4 @@ Deface::Override.new(:virtual_path => "spree/admin/shared/_product_sub_menu", :name => "add_bulk_edit_tab_to_products_admin_sub_menu", :insert_bottom => "[data-hook='admin_product_sub_tabs']", - :text => "<%= tab :bulk_product_edit, :url => bulk_edit_admin_products_path %>") \ No newline at end of file + :text => "<%= tab :bulk_product_edit, :url => bulk_edit_admin_products_path %>") diff --git a/app/views/spree/admin/shared/_tabs.html.erb b/app/views/spree/admin/shared/_tabs.html.erb index fef894389f..ab66dbf1de 100644 --- a/app/views/spree/admin/shared/_tabs.html.erb +++ b/app/views/spree/admin/shared/_tabs.html.erb @@ -1,5 +1,5 @@ <%= tab :overview, :route => :admin, :icon => 'icon-dashboard' %> <%= tab :orders, :payments, :creditcard_payments, :shipments, :credit_cards, :return_authorizations, :url => admin_orders_path('q[s]' => 'completed_at desc'), :icon => 'icon-shopping-cart' %> -<%= tab :products , :option_types, :properties, :prototypes, :variants, :product_properties, :taxons, :icon => 'icon-th-large' %> +<%= tab :products , :option_types, :properties, :prototypes, :variants, :product_properties, :taxons, :url => bulk_edit_admin_products_path, :icon => 'icon-th-large' %> <%= tab :reports, :icon => 'icon-file' %> <%= tab :configurations, :general_settings, :mail_methods, :tax_categories, :zones, :states, :payment_methods, :inventory_settings, :taxonomies, :shipping_methods, :trackers, :label => 'configuration', :icon => 'icon-wrench', :url => edit_admin_general_settings_path %> From 5c744c729558334e798f7ae9c2dfdb0a1053e350 Mon Sep 17 00:00:00 2001 From: Rohan Mitchell Date: Fri, 13 Dec 2013 15:59:59 +1100 Subject: [PATCH 09/16] Move enterprises_distributor_info_rich_text_feature styles into central files --- Gemfile | 1 - .../application.css | 13 ------------- .../feature.css | 5 ----- .../stylesheets/store/openfoodnetwork.css.scss | 7 +++++++ 4 files changed, 7 insertions(+), 19 deletions(-) delete mode 100644 app/assets/stylesheets/enterprises_distributor_info_rich_text_feature/application.css delete mode 100644 app/assets/stylesheets/enterprises_distributor_info_rich_text_feature/feature.css diff --git a/Gemfile b/Gemfile index d26ac871a2..9c977995fe 100644 --- a/Gemfile +++ b/Gemfile @@ -78,7 +78,6 @@ group :test do end group :chili do - #gem 'enterprises_distributor_info_rich_text_feature', path: 'lib/chili/enterprises_distributor_info_rich_text_feature' gem 'eaterprises_feature', path: 'lib/chili/eaterprises_feature' gem 'local_organics_feature', path: 'lib/chili/local_organics_feature' end diff --git a/app/assets/stylesheets/enterprises_distributor_info_rich_text_feature/application.css b/app/assets/stylesheets/enterprises_distributor_info_rich_text_feature/application.css deleted file mode 100644 index 3192ec897b..0000000000 --- a/app/assets/stylesheets/enterprises_distributor_info_rich_text_feature/application.css +++ /dev/null @@ -1,13 +0,0 @@ -/* - * This is a manifest file that'll be compiled into application.css, which will include all the files - * listed below. - * - * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets, - * or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path. - * - * You're free to add application-wide styles to this file and they'll appear at the top of the - * compiled file, but it's generally better to create a new file per style scope. - * - *= require_self - *= require_tree . - */ diff --git a/app/assets/stylesheets/enterprises_distributor_info_rich_text_feature/feature.css b/app/assets/stylesheets/enterprises_distributor_info_rich_text_feature/feature.css deleted file mode 100644 index e8eab603e8..0000000000 --- a/app/assets/stylesheets/enterprises_distributor_info_rich_text_feature/feature.css +++ /dev/null @@ -1,5 +0,0 @@ -.distributor-details .next-collection-at { - font-size: 20px; - font-weight: bold; - color: #de790c; -} diff --git a/app/assets/stylesheets/store/openfoodnetwork.css.scss b/app/assets/stylesheets/store/openfoodnetwork.css.scss index 646edd5510..f98642cc22 100644 --- a/app/assets/stylesheets/store/openfoodnetwork.css.scss +++ b/app/assets/stylesheets/store/openfoodnetwork.css.scss @@ -372,3 +372,10 @@ div#eft-payment-alert { display: none; } + +/* Distributor details */ +.distributor-details .next-collection-at { + font-size: 20px; + font-weight: bold; + color: #de790c; +} From f1f3d7a99cf2d6c4d3031e5511050f2e07e53569 Mon Sep 17 00:00:00 2001 From: Rohan Mitchell Date: Fri, 13 Dec 2013 16:01:29 +1100 Subject: [PATCH 10/16] Remove duplicate migration --- .../20130426022945_add_distributor_info_to_enterprises.rb | 5 ----- 1 file changed, 5 deletions(-) delete mode 100644 db/migrate/20130426022945_add_distributor_info_to_enterprises.rb diff --git a/db/migrate/20130426022945_add_distributor_info_to_enterprises.rb b/db/migrate/20130426022945_add_distributor_info_to_enterprises.rb deleted file mode 100644 index 7342726a92..0000000000 --- a/db/migrate/20130426022945_add_distributor_info_to_enterprises.rb +++ /dev/null @@ -1,5 +0,0 @@ -class AddDistributorInfoToEnterprises < ActiveRecord::Migration - def change - add_column :enterprises, :distributor_info, :text - end -end From e443495a7e1a4f376b6221174156b7ca2f381a5b Mon Sep 17 00:00:00 2001 From: Rohan Mitchell Date: Tue, 17 Dec 2013 12:48:44 +1100 Subject: [PATCH 11/16] Remove reference to deleted stylesheet --- .../spree/layouts/spree_application/assets.html.erb.deface | 2 -- 1 file changed, 2 deletions(-) delete mode 100644 app/overrides/spree/layouts/spree_application/assets.html.erb.deface diff --git a/app/overrides/spree/layouts/spree_application/assets.html.erb.deface b/app/overrides/spree/layouts/spree_application/assets.html.erb.deface deleted file mode 100644 index 7a43bc4978..0000000000 --- a/app/overrides/spree/layouts/spree_application/assets.html.erb.deface +++ /dev/null @@ -1,2 +0,0 @@ - -<%= stylesheet_link_tag 'enterprises_distributor_info_rich_text_feature/application' %> From 3c959939750ae2ca0a212d06c323dbc85787389a Mon Sep 17 00:00:00 2001 From: Rohan Mitchell Date: Tue, 17 Dec 2013 15:25:17 +1100 Subject: [PATCH 12/16] Remove order sensitivity in specs --- spec/models/exchange_spec.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spec/models/exchange_spec.rb b/spec/models/exchange_spec.rb index 05141cbcf6..f4ebfc2d8a 100644 --- a/spec/models/exchange_spec.rb +++ b/spec/models/exchange_spec.rb @@ -81,12 +81,12 @@ describe Exchange do it "finds exchanges going to any of a number of enterprises" do Exchange.to_enterprises([coordinator]).should == [incoming_exchange] - Exchange.to_enterprises([coordinator, distributor]).should == [incoming_exchange, outgoing_exchange] + Exchange.to_enterprises([coordinator, distributor]).sort.should == [incoming_exchange, outgoing_exchange].sort end it "finds exchanges coming from any of a number of enterprises" do Exchange.from_enterprises([coordinator]).should == [outgoing_exchange] - Exchange.from_enterprises([supplier, coordinator]).should == [incoming_exchange, outgoing_exchange] + Exchange.from_enterprises([supplier, coordinator]).sort.should == [incoming_exchange, outgoing_exchange].sort end it "finds exchanges with a particular variant" do From 9f47ff64faffc69fc2a7ace0e5fdde588f67abdc Mon Sep 17 00:00:00 2001 From: Rohan Mitchell Date: Tue, 17 Dec 2013 15:29:25 +1100 Subject: [PATCH 13/16] Update spec now that bulk product edit is the default product edit view --- spec/features/admin/products_spec.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/spec/features/admin/products_spec.rb b/spec/features/admin/products_spec.rb index 646ed70346..e472311223 100644 --- a/spec/features/admin/products_spec.rb +++ b/spec/features/admin/products_spec.rb @@ -104,6 +104,7 @@ feature %q{ product = create(:simple_product, supplier: @supplier2) click_link 'Products' + within('#sub_nav') { click_link 'Products' } click_link product.name within('#sidebar') { click_link 'Product Distributions' } From 37f8ce68fb0c05d541651d4a878c4b3573afad73 Mon Sep 17 00:00:00 2001 From: Will Marshall Date: Thu, 19 Dec 2013 11:58:08 +1100 Subject: [PATCH 14/16] Adding one additional mailer test --- spec/features/consumer/checkout_spec.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/spec/features/consumer/checkout_spec.rb b/spec/features/consumer/checkout_spec.rb index df4ea5500b..98cafcfdac 100644 --- a/spec/features/consumer/checkout_spec.rb +++ b/spec/features/consumer/checkout_spec.rb @@ -414,6 +414,7 @@ feature %q{ # -- Checkout: Email email = ActionMailer::Base.deliveries.last + email.from.include?(@distributor_oc.email).should == true email.body.should =~ /Distribution[\s+]\$54.00/ end From aaa2999ee1e09f9b5d367f91e122dc33c74d5e87 Mon Sep 17 00:00:00 2001 From: Will Marshall Date: Thu, 19 Dec 2013 11:58:21 +1100 Subject: [PATCH 15/16] Dropping our override of ActionMailer --- config/initializers/spree.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/config/initializers/spree.rb b/config/initializers/spree.rb index bd106caf5a..9a93593f45 100644 --- a/config/initializers/spree.rb +++ b/config/initializers/spree.rb @@ -22,6 +22,7 @@ Spree.config do |config| # -- spree_paypal_express # Auto-capture payments. Without this option, payments must be manually captured in the paypal interface. config.auto_capture = true + config.override_actionmailer_config = false end From 87cef4edcca2a91a3f5d446e6df5e1fb741b5637 Mon Sep 17 00:00:00 2001 From: Will Marshall Date: Thu, 19 Dec 2013 12:29:21 +1100 Subject: [PATCH 16/16] Reverting previous commit --- config/initializers/spree.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/initializers/spree.rb b/config/initializers/spree.rb index 9a93593f45..0460865c7e 100644 --- a/config/initializers/spree.rb +++ b/config/initializers/spree.rb @@ -22,7 +22,7 @@ Spree.config do |config| # -- spree_paypal_express # Auto-capture payments. Without this option, payments must be manually captured in the paypal interface. config.auto_capture = true - config.override_actionmailer_config = false + #config.override_actionmailer_config = false end