diff --git a/app/assets/javascripts/darkswarm/controllers/order_cycle_controller.js.coffee b/app/assets/javascripts/darkswarm/controllers/order_cycle_controller.js.coffee index 49d902a7f0..a4ddc59860 100644 --- a/app/assets/javascripts/darkswarm/controllers/order_cycle_controller.js.coffee +++ b/app/assets/javascripts/darkswarm/controllers/order_cycle_controller.js.coffee @@ -25,3 +25,6 @@ Darkswarm.controller "OrderCycleChangeCtrl", ($scope, $rootScope, $timeout, Orde Cart.reloadFinalisedLineItems() ChangeableOrdersAlert.reload() $rootScope.$broadcast 'orderCycleSelected' + + $scope.closesInLessThan3Months = () -> + moment().diff(moment(OrderCycle.orders_close_at(), "YYYY-MM-DD HH:mm:SS Z"), 'days') > -75 diff --git a/app/assets/stylesheets/darkswarm/_shop-navigation.scss b/app/assets/stylesheets/darkswarm/_shop-navigation.scss index 8ed5400ed9..3251aa2f96 100644 --- a/app/assets/stylesheets/darkswarm/_shop-navigation.scss +++ b/app/assets/stylesheets/darkswarm/_shop-navigation.scss @@ -170,6 +170,10 @@ shop ordercycle { float: none; padding: 0; } + + .no-message-pad { + padding: 0.95rem; + } } form.custom { diff --git a/app/views/enterprises/_change_order_cycle.html.haml b/app/views/enterprises/_change_order_cycle.html.haml index 4f9f20bab2..b6186ba8b6 100644 --- a/app/views/enterprises/_change_order_cycle.html.haml +++ b/app/views/enterprises/_change_order_cycle.html.haml @@ -1,8 +1,10 @@ %div{"ng-controller" => "OrderCycleChangeCtrl", "ng-cloak" => true} %closing %div{"ng-if" => "OrderCycle.selected()"} - = t :enterprises_next_closing - %strong {{ OrderCycle.orders_close_at() | date_in_words }} + %div{"ng-if" => "closesInLessThan3Months()"} + = t :enterprises_next_closing + %strong {{ OrderCycle.orders_close_at() | date_in_words }} + %div.no-message-pad{"ng-if" => "!closesInLessThan3Months()"} %div{"ng-if" => "!OrderCycle.selected()"} = t :enterprises_choose diff --git a/spec/features/consumer/shopping/shopping_spec.rb b/spec/features/consumer/shopping/shopping_spec.rb index 8dfa95a080..9f3bba9236 100644 --- a/spec/features/consumer/shopping/shopping_spec.rb +++ b/spec/features/consumer/shopping/shopping_spec.rb @@ -49,11 +49,24 @@ feature "As a consumer I want to shop with a distributor", js: true do describe "selecting an order cycle" do let(:exchange1) { oc1.exchanges.to_enterprises(distributor).outgoing.first } - it "selects an order cycle if only one is open" do - exchange1.update_attribute :pickup_time, "turtles" - visit shop_path - expect(page).to have_selector "p", text: 'turtles' - expect(page).not_to have_content "choose when you want your order" + describe "with only one open order cycle" do + before { exchange1.update_attribute :pickup_time, "turtles" } + + it "selects an order cycle" do + visit shop_path + expect(page).to have_selector "p", text: 'turtles' + expect(page).not_to have_content "choose when you want your order" + expect(page).to have_content "Next order closing in 2 days" + end + + describe "when order cycle closes in more than 3 months" do + before { oc1.update orders_close_at: 5.months.from_now } + + it "does not show 'closing in' message" do + visit shop_path + expect(page).not_to have_content "Next order closing in 2 days" + end + end end describe "with multiple order cycles" do