diff --git a/Gemfile.lock b/Gemfile.lock new file mode 100644 index 000000000..8c7328269 --- /dev/null +++ b/Gemfile.lock @@ -0,0 +1,382 @@ +GIT + remote: https://github.com/alexreisner/geocoder.git + revision: 104d466ba7097b7dce5ba19f8e4091b7f69ccdf6 + ref: 104d46 + specs: + geocoder (1.1.8) + +PATH + remote: vendor/gems/active_utils-1.0.5 + specs: + active_utils (1.0.5) + activesupport (>= 2.3.11) + i18n + +PATH + remote: vendor/gems/activemerchant-1.33.0 + specs: + activemerchant (1.33.0) + +GEM + remote: https://rubygems.org/ + specs: + actionmailer (3.2.13) + actionpack (= 3.2.13) + mail (~> 2.5.3) + actionpack (3.2.13) + activemodel (= 3.2.13) + activesupport (= 3.2.13) + builder (~> 3.0.0) + erubis (~> 2.7.0) + journey (~> 1.0.4) + rack (~> 1.4.5) + rack-cache (~> 1.2) + rack-test (~> 0.6.1) + sprockets (~> 2.2.1) + activemodel (3.2.13) + activesupport (= 3.2.13) + builder (~> 3.0.0) + activerecord (3.2.13) + activemodel (= 3.2.13) + activesupport (= 3.2.13) + arel (~> 3.0.2) + tzinfo (~> 0.3.29) + activeresource (3.2.13) + activemodel (= 3.2.13) + activesupport (= 3.2.13) + activesupport (3.2.13) + i18n (= 0.6.1) + multi_json (~> 1.0) + addressable (2.3.6) + arel (3.0.3) + bcrypt (3.1.9) + better_errors (2.0.0) + coderay (>= 1.0.0) + erubis (>= 2.6.6) + rack (>= 0.9.0) + binding_of_caller (0.7.2) + debug_inspector (>= 0.0.1) + bluecloth (2.2.0) + bootstrap-datepicker-rails (1.3.0.2) + railties (>= 3.0) + builder (3.0.4) + byebug (3.5.1) + columnize (~> 0.8) + debugger-linecache (~> 1.2) + slop (~> 3.6) + cancan (1.6.10) + capybara (2.4.4) + mime-types (>= 1.16) + nokogiri (>= 1.3.3) + rack (>= 1.0.0) + rack-test (>= 0.5.4) + xpath (~> 2.0) + capybara-email (2.4.0) + capybara (~> 2.4) + mail + chunky_png (1.3.3) + cliver (0.3.2) + coderay (1.1.0) + coffee-rails (3.2.2) + coffee-script (>= 2.2.0) + railties (~> 3.2.0) + coffee-script (2.3.0) + coffee-script-source + execjs + coffee-script-source (1.8.0) + columnize (0.8.9) + commonjs (0.2.7) + compass (0.12.7) + chunky_png (~> 1.2) + fssm (>= 0.2.7) + sass (~> 3.2.19) + compass-rails (1.0.3) + compass (>= 0.12.2, < 0.14) + coveralls (0.7.1) + multi_json (~> 1.3) + rest-client + simplecov (>= 0.7) + term-ansicolor + thor + csv_shaper (1.1.1) + activesupport (>= 3.0.0) + dalli (2.7.2) + database_cleaner (1.3.0) + debug_inspector (0.0.2) + debugger-linecache (1.2.0) + devise (3.2.4) + bcrypt (~> 3.0) + orm_adapter (~> 0.1) + railties (>= 3.2.6, < 5) + thread_safe (~> 0.1) + warden (~> 1.2.3) + diff-lcs (1.1.3) + docile (1.1.5) + easy_translate (0.5.0) + json + thread + thread_safe + erubis (2.7.0) + execjs (2.2.2) + factory_girl (4.5.0) + activesupport (>= 3.0.0) + factory_girl_rails (4.5.0) + factory_girl (~> 4.5.0) + railties (>= 3.0.0) + figaro (1.0.0) + thor (~> 0.14) + flickraw (0.9.8) + friendly_id (4.0.10.1) + activerecord (>= 3.0, < 4.0) + fssm (0.2.10) + gibbon (1.1.4) + httparty + multi_json (>= 1.3.4) + gravatar-ultimate (2.0.0) + activesupport (>= 2.3.14) + rack + haml (4.0.5) + tilt + haml-rails (0.4) + actionpack (>= 3.1, < 4.1) + activesupport (>= 3.1, < 4.1) + haml (>= 3.1, < 4.1) + railties (>= 3.1, < 4.1) + hashie (3.3.1) + highline (1.6.21) + hike (1.2.3) + httparty (0.11.0) + multi_json (~> 1.0) + multi_xml (>= 0.5.2) + i18n (0.6.1) + i18n-tasks (0.7.8) + activesupport + easy_translate (>= 0.5.0) + erubis + highline + i18n + slop (>= 3.5.0) + term-ansicolor + terminal-table + journey (1.0.4) + jquery-rails (3.1.2) + railties (>= 3.0, < 5.0) + thor (>= 0.14, < 2.0) + jquery-ui-rails (4.1.2) + railties (>= 3.1.0) + js-routes (0.9.9) + railties (>= 3.2) + sprockets-rails + json (1.7.7) + kgio (2.9.2) + launchy (2.4.3) + addressable (~> 2.3) + leaflet-markercluster-rails (0.7.0) + railties (>= 3.1) + leaflet-rails (0.7.4) + less (2.5.1) + commonjs (~> 0.2.7) + less-rails (2.5.0) + actionpack (>= 3.1) + less (~> 2.5.0) + less-rails-bootstrap (3.2.0) + less-rails (~> 2.5.0) + letter_opener (1.2.0) + launchy (~> 2.2) + libv8 (3.16.14.3) + mail (2.5.4) + mime-types (~> 1.16) + treetop (~> 1.4.8) + memcachier (0.0.2) + method_source (0.8.2) + mime-types (1.25.1) + mini_portile (0.6.1) + multi_json (1.10.1) + multi_xml (0.5.5) + netrc (0.8.0) + newrelic_rpm (3.9.6.257) + nokogiri (1.6.4.1) + mini_portile (~> 0.6.0) + oauth (0.4.7) + omniauth (1.2.2) + hashie (>= 1.2, < 4) + rack (~> 1.0) + omniauth-flickr (0.0.15) + omniauth-oauth (~> 1.0) + omniauth-oauth (1.0.1) + oauth + omniauth (~> 1.0) + omniauth-twitter (1.1.0) + multi_json (~> 1.3) + omniauth-oauth (~> 1.0) + orm_adapter (0.5.0) + pg (0.17.1) + poltergeist (1.5.1) + capybara (~> 2.1) + cliver (~> 0.3.1) + multi_json (~> 1.0) + websocket-driver (>= 0.2.0) + polyglot (0.3.5) + pry (0.10.1) + coderay (~> 1.1.0) + method_source (~> 0.8.1) + slop (~> 3.4) + rack (1.4.5) + rack-cache (1.2) + rack (>= 0.4) + rack-ssl (1.3.4) + rack + rack-test (0.6.2) + rack (>= 1.0) + rails (3.2.13) + actionmailer (= 3.2.13) + actionpack (= 3.2.13) + activerecord (= 3.2.13) + activeresource (= 3.2.13) + activesupport (= 3.2.13) + bundler (~> 1.0) + railties (= 3.2.13) + rails_12factor (0.0.3) + rails_serve_static_assets + rails_stdout_logging + rails_serve_static_assets (0.0.2) + rails_stdout_logging (0.0.3) + railties (3.2.13) + actionpack (= 3.2.13) + activesupport (= 3.2.13) + rack-ssl (~> 1.3.2) + rake (>= 0.8.7) + rdoc (~> 3.4) + thor (>= 0.14.6, < 2.0) + raindrops (0.13.0) + rake (10.3.2) + rdoc (3.12.2) + json (~> 1.4) + ref (1.0.5) + rest-client (1.7.2) + mime-types (>= 1.16, < 3.0) + netrc (~> 0.7) + rspec-core (2.12.2) + rspec-expectations (2.12.1) + diff-lcs (~> 1.1.3) + rspec-mocks (2.12.2) + rspec-rails (2.12.2) + actionpack (>= 3.0) + activesupport (>= 3.0) + railties (>= 3.0) + rspec-core (~> 2.12.0) + rspec-expectations (~> 2.12.0) + rspec-mocks (~> 2.12.0) + sass (3.2.19) + sass-rails (3.2.6) + railties (~> 3.2.0) + sass (>= 3.1.10) + tilt (~> 1.3) + simplecov (0.9.1) + docile (~> 1.1.0) + multi_json (~> 1.0) + simplecov-html (~> 0.8.0) + simplecov-html (0.8.0) + slop (3.6.0) + sprockets (2.2.3) + hike (~> 1.2) + multi_json (~> 1.0) + rack (~> 1.0) + tilt (~> 1.1, != 1.3.0) + sprockets-rails (0.0.1) + sprockets (>= 1.0.2) + term-ansicolor (1.3.0) + tins (~> 1.0) + terminal-table (1.4.5) + therubyracer (0.12.1) + libv8 (~> 3.16.14.0) + ref + thor (0.19.1) + thread (0.1.4) + thread_safe (0.3.4) + tilt (1.4.1) + tins (1.3.3) + treetop (1.4.15) + polyglot + polyglot (>= 0.3.1) + tzinfo (0.3.42) + uglifier (2.2.1) + execjs (>= 0.3.0) + multi_json (~> 1.0, >= 1.0.2) + unicorn (4.8.3) + kgio (~> 2.6) + rack + raindrops (~> 0.7) + warden (1.2.3) + rack (>= 1.0) + webrat (0.7.3) + nokogiri (>= 1.2.0) + rack (>= 1.0) + rack-test (>= 0.5.3) + websocket-driver (0.4.0) + will_paginate (3.0.7) + xpath (2.0.0) + nokogiri (~> 1.3) + +PLATFORMS + ruby + +DEPENDENCIES + active_utils (= 1.0.5)! + activemerchant (= 1.33.0)! + better_errors + binding_of_caller + bluecloth + bootstrap-datepicker-rails + bundler (>= 1.1.5) + byebug + cancan + capybara + capybara-email + coffee-rails (~> 3.2.1) + compass-rails (~> 1.0.3) + coveralls + csv_shaper + dalli + database_cleaner (~> 1.3.0) + devise (~> 3.2.0) + factory_girl_rails (~> 4.0) + figaro + flickraw + friendly_id (~> 4.0.10) + geocoder! + gibbon + gravatar-ultimate + haml + haml-rails + i18n-tasks + jquery-rails + jquery-ui-rails + js-routes + json (~> 1.7.7) + leaflet-markercluster-rails + leaflet-rails + less (~> 2.5.0) + less-rails (~> 2.5.0) + less-rails-bootstrap (~> 3.2.0) + letter_opener + libv8 (= 3.16.14.3) + memcachier + newrelic_rpm + omniauth + omniauth-flickr (>= 0.0.15) + omniauth-twitter + pg + poltergeist (~> 1.5.1) + pry + rack (~> 1.4.5) + rails (= 3.2.13) + rails_12factor + rake (>= 10.0.0) + rspec-rails (~> 2.12.1) + sass-rails (~> 3.2.3) + therubyracer (~> 0.12) + uglifier (>= 1.0.3) + unicorn + webrat + will_paginate (~> 3.0) diff --git a/app/assets/javascripts/append_date.js.coffee b/app/assets/javascripts/append_date.js.coffee index cf54f4654..8fc31de9d 100644 --- a/app/assets/javascripts/append_date.js.coffee +++ b/app/assets/javascripts/append_date.js.coffee @@ -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 = $("") + $('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}" diff --git a/app/views/plantings/_thumbnail.html.haml b/app/views/plantings/_thumbnail.html.haml index c8588abf5..fd34b0703 100644 --- a/app/views/plantings/_thumbnail.html.haml +++ b/app/views/plantings/_thumbnail.html.haml @@ -17,14 +17,6 @@ in = link_to planting.location, planting.garden - - if planting.finished - %p - Finished: - - if planting.finished_at - = planting.finished_at - - else - Yes (no date specified) - %p - if planting.quantity Quantity: @@ -37,11 +29,19 @@ :growstuff_markdown #{ planting.description } + - if planting.finished + %p + Finished: + - if planting.finished_at + = planting.finished_at + - else + Yes (no date specified) + - if can? :edit, planting or can? :destroy, planting %p - if can? :edit, planting =link_to 'Edit', edit_planting_path(planting), :class => 'btn btn-default btn-xs' - if ! planting.finished - = link_to "Mark as finished", planting_path(planting, :planting => {:finished => 1}), :method => :put, :class => 'btn btn-default btn-xs' + = link_to "Mark as finished", planting_path(planting, :planting => {:finished => 1}), :method => :put, :class => 'btn btn-default btn-xs append-date' - if can? :destroy, planting =link_to 'Delete', planting, method: :delete, data: { confirm: 'Are you sure?' }, :class => 'btn btn-default btn-xs' diff --git a/app/views/plantings/index.html.haml b/app/views/plantings/index.html.haml index fe69ed344..1d27df4e8 100644 --- a/app/views/plantings/index.html.haml +++ b/app/views/plantings/index.html.haml @@ -53,7 +53,7 @@ - if can? :edit, planting =link_to 'Edit', edit_planting_path(planting), :class => 'btn btn-default btn-xs' - if ! planting.finished - = link_to "Mark as finished", planting_path(planting, :planting => {:finished => 1}), :method => :put, :class => 'btn btn-default btn-xs' + = link_to "Mark as finished", planting_path(planting, :planting => {:finished => 1}), :method => :put, :class => 'btn btn-default btn-xs append-date' - if can? :destroy, planting =link_to 'Delete', planting, method: :delete, data: { confirm: 'Are you sure?' }, :class => 'btn btn-default btn-xs' diff --git a/app/views/plantings/show.html.haml b/app/views/plantings/show.html.haml index cc3d58bae..72819f7ac 100644 --- a/app/views/plantings/show.html.haml +++ b/app/views/plantings/show.html.haml @@ -11,14 +11,6 @@ %b Planted: = @planting.planted_at ? @planting.planted_at : "not specified" - - if @planting.finished - %p - %b Finished: - - if @planting.finished_at - = @planting.finished_at - - else - Yes (no date specified) - %p %b Where: =link_to "#{@planting.owner}'s", @planting.owner @@ -39,6 +31,15 @@ %b Sun or shade? = @planting.sunniness + - if @planting.finished + %p + %b Finished: + - if @planting.finished_at + = @planting.finished_at + - else + Yes (no date specified) + + - if can? :edit, @planting or can? :destroy, @planting %p diff --git a/spec/features/gardens_spec.rb b/spec/features/gardens_spec.rb index 1b803a41e..2b4c22d8b 100644 --- a/spec/features/gardens_spec.rb +++ b/spec/features/gardens_spec.rb @@ -2,6 +2,8 @@ require 'spec_helper' feature "Planting a crop", :js => true do let!(:garden) { FactoryGirl.create(:garden) } + let!(:planting) { FactoryGirl.create(:planting, garden: garden, planted_at: Date.parse("2013-3-10")) } + background do login_as(garden.owner) @@ -54,4 +56,11 @@ feature "Planting a crop", :js => true do expect(page).to have_content "#{garden.owner}'s gardens" end + describe "Making a planting inactive from garden show" do + let(:path) { garden_path(garden) } + let(:link_text) { "Mark as finished" } + + it_behaves_like "append date" + end + end diff --git a/spec/features/plantings/planting_a_crop_spec.rb b/spec/features/plantings/planting_a_crop_spec.rb index 99114ab43..82d180d84 100644 --- a/spec/features/plantings/planting_a_crop_spec.rb +++ b/spec/features/plantings/planting_a_crop_spec.rb @@ -4,14 +4,14 @@ feature "Planting a crop", :js => true do let(:member) { FactoryGirl.create(:member) } let!(:maize) { FactoryGirl.create(:maize) } let(:garden) { FactoryGirl.create(:garden, owner: member) } - let(:planting) { FactoryGirl.create(:planting, garden: garden, planted_at: Date.parse("2013-3-10")) } + let!(:planting) { FactoryGirl.create(:planting, garden: garden, planted_at: Date.parse("2013-3-10")) } background do login_as(member) visit new_planting_path end - it_behaves_like "crop suggest", "planting", "crop" + it_behaves_like "crop suggest", "planting" scenario "Creating a new planting" do fill_autocomplete "crop", :with => "m" @@ -87,16 +87,16 @@ feature "Planting a crop", :js => true do expect(page).to have_content "Finished: Yes (no date specified)" end - scenario "Marking a planting as finished from the show page" do - this_month = Date.today.strftime("%B") - this_year = Date.today.strftime("%Y") - visit planting_path(planting) - click_link "Mark as finished" - within "div.datepicker" do - expect(page).to have_content "#{this_month}" - page.find(".datepicker-days td.day", text: "21").click - end - expect(page).to have_content "Finished: #{this_month} 21, #{this_year}" + describe "Marking a planting as finished from the show page" do + let(:path) { planting_path(planting) } + let(:link_text) { "Mark as finished" } + it_behaves_like "append date" + end + + describe "Marking a planting as finished from the list page" do + let(:path) { plantings_path } + let(:link_text) { "Mark as finished" } + it_behaves_like "append date" end end diff --git a/spec/features/shared_examples/append_date_spec.rb b/spec/features/shared_examples/append_date_spec.rb new file mode 100644 index 000000000..089680ff9 --- /dev/null +++ b/spec/features/shared_examples/append_date_spec.rb @@ -0,0 +1,22 @@ +shared_examples "append date" do + + scenario "Selecting a date with datepicker" do + this_month = Date.today.strftime("%B") + this_year = Date.today.strftime("%Y") + visit path + click_link link_text + within "div.datepicker" do + expect(page).to have_content "#{this_month}" + page.find(".datepicker-days td.day", text: "21").click + end + 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 \ No newline at end of file diff --git a/spec/features/shared_examples/crop_suggest.rb b/spec/features/shared_examples/crop_suggest.rb index 499bab891..da10072a3 100644 --- a/spec/features/shared_examples/crop_suggest.rb +++ b/spec/features/shared_examples/crop_suggest.rb @@ -1,5 +1,3 @@ -require 'spec_helper' - shared_examples "crop suggest" do |resource| let!(:popcorn) { FactoryGirl.create(:popcorn) } let!(:pear) { FactoryGirl.create(:pear) }