diff --git a/app/views/spree/admin/orders/bulk_management.html.haml b/app/views/spree/admin/orders/bulk_management.html.haml index 2c6310c7a0..a687d376c9 100644 --- a/app/views/spree/admin/orders/bulk_management.html.haml +++ b/app/views/spree/admin/orders/bulk_management.html.haml @@ -45,7 +45,7 @@ %table.index#listing_orders.bulk %thead %tr - %th.email Email + %th.full_name Name %th.date Order Date %th.producer Producer %th.variant Product (Unit): Var @@ -55,7 +55,7 @@ Ask?  %input{ :type => 'checkbox', 'ng-model' => "confirmDelete" } %tr.line_item{ 'ng-repeat' => 'line_item in lineItems | filter:quickSearch | selectFilter:supplierFilter:distributorFilter:orderCycleFilter:quickSearch', 'ng-class-even' => "'even'", 'ng-class-odd' => "'odd'", :id => "li_{{line_item.id}}" } - %td.email {{ line_item.order.email }} + %td.full_name {{ line_item.order.full_name }} %td.date {{ line_item.order.completed_at }} %td.producer {{ line_item.supplier.name }} %td.variant {{ line_item.variant_unit_text }} diff --git a/app/views/spree/api/orders/bulk_show.v1.rabl b/app/views/spree/api/orders/bulk_show.v1.rabl index 4e77763d6e..14a8c37369 100644 --- a/app/views/spree/api/orders/bulk_show.v1.rabl +++ b/app/views/spree/api/orders/bulk_show.v1.rabl @@ -1,5 +1,7 @@ object @order -attributes :id, :number, :email +attributes :id, :number + +node( :full_name ) { |order| order.billing_address.nil? ? order.email : order.billing_address.full_name } node( :completed_at ) { |order| order.completed_at.blank? ? "" : order.completed_at.strftime("%F %T") } node( :distributor ) { |order| partial 'spree/api/enterprises/bulk_show', :object => order.distributor } node( :order_cycle ) { |order| partial 'api/order_cycles/bulk_show', :object => order.order_cycle } diff --git a/spec/controllers/spree/api/orders_controller_spec.rb b/spec/controllers/spree/api/orders_controller_spec.rb index 8961cc8070..647ce29ca8 100644 --- a/spec/controllers/spree/api/orders_controller_spec.rb +++ b/spec/controllers/spree/api/orders_controller_spec.rb @@ -7,14 +7,14 @@ module Spree render_views let!(:dist1) { FactoryGirl.create(:distributor_enterprise) } - let!(:order1) { FactoryGirl.create(:order, state: 'complete', completed_at: Time.now, distributor: dist1 ) } - let!(:order2) { FactoryGirl.create(:order, state: 'complete', completed_at: Time.now, distributor: dist1 ) } - let!(:order3) { FactoryGirl.create(:order, state: 'complete', completed_at: Time.now, distributor: dist1 ) } + let!(:order1) { FactoryGirl.create(:order, state: 'complete', completed_at: Time.now, distributor: dist1, billing_address: FactoryGirl.create(:address) ) } + let!(:order2) { FactoryGirl.create(:order, state: 'complete', completed_at: Time.now, distributor: dist1, billing_address: FactoryGirl.create(:address) ) } + let!(:order3) { FactoryGirl.create(:order, state: 'complete', completed_at: Time.now, distributor: dist1, billing_address: FactoryGirl.create(:address) ) } let!(:line_item1) { FactoryGirl.create(:line_item, order: order1) } let!(:line_item2) { FactoryGirl.create(:line_item, order: order2) } let!(:line_item3) { FactoryGirl.create(:line_item, order: order2) } let!(:line_item4) { FactoryGirl.create(:line_item, order: order3) } - let(:order_attributes) { [:id, :email, :completed_at, :line_items, :distributor, :order_cycle, :number] } + let(:order_attributes) { [:id, :full_name, :completed_at, :line_items, :distributor, :order_cycle, :number] } let(:line_item_attributes) { [:id, :quantity, :max_quantity, :supplier, :variant_unit_text] } before do diff --git a/spec/features/admin/bulk_order_management_spec.rb b/spec/features/admin/bulk_order_management_spec.rb index 168421f77c..a08b13fa0f 100644 --- a/spec/features/admin/bulk_order_management_spec.rb +++ b/spec/features/admin/bulk_order_management_spec.rb @@ -58,8 +58,8 @@ feature %q{ end context "displaying individual columns" do - let!(:o1) { FactoryGirl.create(:order, state: 'complete', completed_at: Time.now ) } - let!(:o2) { FactoryGirl.create(:order, state: 'complete', completed_at: Time.now ) } + let!(:o1) { FactoryGirl.create(:order, state: 'complete', completed_at: Time.now, bill_address: FactoryGirl.create(:address) ) } + let!(:o2) { FactoryGirl.create(:order, state: 'complete', completed_at: Time.now, bill_address: nil ) } let!(:li1) { FactoryGirl.create(:line_item, order: o1 ) } let!(:li2) { FactoryGirl.create(:line_item, order: o2 ) } @@ -67,10 +67,10 @@ feature %q{ visit '/admin/orders/bulk_management' end - it "displays a column for user email" do - page.should have_selector "th.email", text: "EMAIL", :visible => true - page.should have_selector "td.email", text: o1.email, :visible => true - page.should have_selector "td.email", text: o2.email, :visible => true + it "displays a column for user's full name, returns email if no billing address exists" do + page.should have_selector "th.full_name", text: "NAME", :visible => true + page.should have_selector "td.full_name", text: o1.bill_address.full_name, :visible => true + page.should have_selector "td.full_name", text: o2.email, :visible => true end it "displays a column for order date" do