Dont show 'closing in' message when oc closes in more than 3 months

This commit is contained in:
Luis Ramos
2020-10-21 09:49:21 +01:00
committed by Andy Brett
parent a51d01efac
commit f71de8123a
4 changed files with 29 additions and 7 deletions

View File

@@ -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

View File

@@ -170,6 +170,10 @@ shop ordercycle {
float: none;
padding: 0;
}
.no-message-pad {
padding: 0.95rem;
}
}
form.custom {

View File

@@ -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

View File

@@ -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