implement confirm without date functionality on appty on append date js

This commit is contained in:
Taylor Griffin
2014-10-23 22:43:38 +11:00
parent 9b10a7c3ce
commit 0ccd6e843a
2 changed files with 25 additions and 2 deletions

View File

@@ -8,12 +8,28 @@ jQuery ->
el.datepicker({'format': 'yyyy-mm-dd'})
href = el.attr('href')
originalText = el.text()
el.click (e) ->
e.stopPropagation()
e.preventDefault()
$(this).text('Confirm without date')
$(this).bind('click.confirm', (e) ->
link = $("<a href='#{href}' data-method='put'></a>")
$('body').append(link)
$(link).click()
)
$(this).blur (e) ->
$(this).text(originalText)
$(this).unbind('click.confirm')
el.one 'changeDate', ->
href = $(this).attr('href')
date = $(this).datepicker('getDate')
url = "#{href}&planting[finished_at]=#{date}"

View File

@@ -1,6 +1,6 @@
shared_examples "append date" do
scenario "Displaying a datepicker" do
scenario "Selecting a date with datepicker" do
this_month = Date.today.strftime("%B")
this_year = Date.today.strftime("%Y")
visit path
@@ -12,4 +12,11 @@ shared_examples "append date" do
expect(page).to have_content "Finished: #{this_month} 21, #{this_year}"
end
scenario "Confirming without selecting date" do
visit path
click_link link_text
click_link "Confirm without date"
expect(page).to have_content("Finished: Yes (no date specified) ")
end
end