mirror of
https://github.com/Growstuff/growstuff.git
synced 2026-04-16 13:03:16 -04:00
implement confirm without date functionality on appty on append date js
This commit is contained in:
@@ -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}"
|
||||
|
||||
|
||||
@@ -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
|
||||
Reference in New Issue
Block a user