Skip to content

Commit

Permalink
Merge pull request #70 from jbeast/expiry_date_fix
Browse files Browse the repository at this point in the history
Set expiry date to today when days_to_keep is 0
  • Loading branch information
jbeast committed May 20, 2016
2 parents da23c4e + 4b13e13 commit 583b832
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
2 changes: 1 addition & 1 deletion app/assets/javascripts/views/expiry_date.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ class Mixtio.Views.ExpiryDate extends Backbone.View
@render()

render: () ->
@$el.datepicker('setDate', @model?.get('days_to_keep'))
@$el.datepicker('setDate', @model?.get('days_to_keep') or 'today')
this
17 changes: 17 additions & 0 deletions spec/features/batches_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,23 @@
end
end

context 'when a consumable type is selected that has a days_to_keep of 0' do
before do
@consumable_type = create(:consumable_type, days_to_keep: 0)
end

let(:select_a_consumable_type) {
visit new_batch_path
select @consumable_type.name, from: 'Consumable Type'
wait_for_ajax
}

it 'sets the expiry date to today', js: true do
select_a_consumable_type
expect(find_field("Expiry Date").value).to eq(Date.today.to_date.to_s(:default))
end
end

context 'when trying to use a batch that does not exist as an ingredient' do

before do
Expand Down

0 comments on commit 583b832

Please sign in to comment.