From 3258694021888a51490cdf7ee85ee07956a86c81 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Tue, 1 Jan 2019 19:44:03 +1300 Subject: [PATCH 001/207] Tidy up the routes --- config/routes.rb | 111 +++++++++++++++++++++++++++-------------------- 1 file changed, 63 insertions(+), 48 deletions(-) diff --git a/config/routes.rb b/config/routes.rb index 9f8918eed..49b55fa7a 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,8 +1,6 @@ Rails.application.routes.draw do get '/robots.txt' => 'robots#robots' - resources :plant_parts - devise_for :members, controllers: { registrations: "registrations", passwords: "passwords", @@ -14,84 +12,100 @@ Rails.application.routes.draw do end match '/members/:id/finish_signup' => 'members#finish_signup', via: %i(get patch), as: :finish_signup - resources :members - - resources :photos - delete 'photo_associations' => 'photo_associations#destroy' - resources :authentications, only: %i(create destroy) - resources :plantings do - resources :harvests - resources :seeds - end - get '/plantings/owner/:owner' => 'plantings#index', as: 'plantings_by_owner' - get '/plantings/crop/:crop' => 'plantings#index', as: 'plantings_by_crop' + get "home/index" + root to: 'home#index' resources :gardens do get 'timeline' => 'charts/gardens#timeline' + get 'owner/:owner' => 'gardens#index', as: 'gardens_by_owner', on: :collection + end + + resources :plantings do + get :harvests + get :seeds + collection do + get 'owner/:owner' => 'plantings#index', as: 'plantings_by_owner' + get 'crop/:crop' => 'plantings#index', as: 'plantings_by_crop' + end end - get '/gardens/owner/:owner' => 'gardens#index', as: 'gardens_by_owner' resources :seeds do - resources :plantings + get :plantings + collection do + get 'owner/:owner' => 'seeds#index', as: 'seeds_by_owner' + get 'crop/:crop' => 'seeds#index', as: 'seeds_by_crop' + end end - get '/seeds/owner/:owner' => 'seeds#index', as: 'seeds_by_owner' - get '/seeds/crop/:crop' => 'seeds#index', as: 'seeds_by_crop' - resources :harvests - get '/harvests/owner/:owner' => 'harvests#index', as: 'harvests_by_owner' - get '/harvests/crop/:crop' => 'harvests#index', as: 'harvests_by_crop' + resources :harvests do + collection do + get 'owner/:owner' => 'harvests#index', as: 'harvests_by_owner' + get 'crop/:crop' => 'harvests#index', as: 'harvests_by_crop' + end + end - resources :posts - get '/posts/author/:author' => 'posts#index', as: 'posts_by_author' + resources :posts do + collection do + get 'author/:author' => 'posts#index', as: 'posts_by_author' + end + end resources :scientific_names resources :alternate_names + resources :plant_parts + resources :photos + + delete 'photo_associations' => 'photo_associations#destroy' - get 'crops/requested' => 'crops#requested', as: 'requested_crops' - get 'crops/wrangle' => 'crops#wrangle', as: 'wrangle_crops' - get 'crops/hierarchy' => 'crops#hierarchy', as: 'crops_hierarchy' - get 'crops/search' => 'crops#search', as: 'crops_search' resources :crops do - get 'photos' => 'photos#index' - get 'sunniness' => 'charts/crops#sunniness' - get 'planted_from' => 'charts/crops#planted_from' - get 'harvested_for' => 'charts/crops#harvested_for' + get 'harvests' => 'harvests#index' + get 'plantings' => 'plantings#index' + + # Charts + get 'sunniness' => 'charts/crops#sunniness', constraints: { format: 'json' } + get 'planted_from' => 'charts/crops#planted_from', constraints: { format: 'json' } + get 'harvested_for' => 'charts/crops#harvested_for', constraints: { format: 'json' } + + collection do + get 'requested' => 'crops#requested', as: 'requested_crops' + get 'wrangle' => 'crops#wrangle', as: 'wrangle_crops' + get 'hierarchy' => 'crops#hierarchy', as: 'crops_hierarchy' + get 'search' => 'crops#search', as: 'search' + end end resources :comments resources :roles resources :forums + + resources :follows, only: %i(create destroy) + resources :likes, only: %i(create destroy) + resources :members do + get 'follows' => 'members#view_follows', as: 'member_follows' + get 'followers' => 'members#view_followers', as: 'member_followers' + end resources :notifications do get 'reply', on: :member end - resources :follows, only: %i(create destroy) - get '/members/:login_name/follows' => 'members#view_follows', as: 'member_follows' - get '/members/:login_name/followers' => 'members#view_followers', as: 'member_followers' - - get '/places' => 'places#index' - get '/places/search' => 'places#search', as: 'search_places' - get '/places/:place' => 'places#show', as: 'place' - - resources :likes, only: %i(create destroy) - - get "home/index" - root to: 'home#index' + resources :places do + collection do + get 'search' => 'places#search', as: 'search_places' + get ':place' => 'places#show', as: 'place' + end + end get 'auth/:provider/callback' => 'authentications#create' get 'members/auth/:provider/callback' => 'authentications#create' - comfy_route :cms_admin, path: '/admin/cms' - namespace :admin do + resources :admin, only: :index do + get 'newsletter' resources :members + get ':action' => 'admin#:action', on: :collection end - get '/admin' => 'admin#index' - get '/admin/newsletter' => 'admin#newsletter', as: :admin_newsletter - get '/admin/:action' => 'admin#:action' - namespace :api do namespace :v1 do jsonapi_resources :photos @@ -106,5 +120,6 @@ Rails.application.routes.draw do get '/.well-known/acme-challenge/:id' => 'pages#letsencrypt' # CMS stuff -- must remain LAST + comfy_route :cms_admin, path: '/admin/cms' comfy_route :cms, path: '/', sitemap: false end From a65983e1ed705752e2776951fe73a2e07b30c194 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Tue, 1 Jan 2019 19:48:44 +1300 Subject: [PATCH 002/207] Routes for photos and owners --- config/routes.rb | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/config/routes.rb b/config/routes.rb index 49b55fa7a..6872ae9a9 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -17,12 +17,21 @@ Rails.application.routes.draw do get "home/index" root to: 'home#index' + + concern :photo_attachable do + resources :photos, only: :index + end + + concern :ownable do + get 'owner/:owner' => 'gardens#index', on: :collection + end + resources :gardens do get 'timeline' => 'charts/gardens#timeline' get 'owner/:owner' => 'gardens#index', as: 'gardens_by_owner', on: :collection end - resources :plantings do + resources :plantings, concerns: [:photo_attachable, :ownable] do get :harvests get :seeds collection do @@ -31,7 +40,7 @@ Rails.application.routes.draw do end end - resources :seeds do + resources :seeds, concerns: [:photo_attachable, :ownable] do get :plantings collection do get 'owner/:owner' => 'seeds#index', as: 'seeds_by_owner' @@ -39,14 +48,14 @@ Rails.application.routes.draw do end end - resources :harvests do + resources :harvests, concerns: [:photo_attachable, :ownable] do collection do get 'owner/:owner' => 'harvests#index', as: 'harvests_by_owner' get 'crop/:crop' => 'harvests#index', as: 'harvests_by_crop' end end - resources :posts do + resources :posts, concerns: :ownable do collection do get 'author/:author' => 'posts#index', as: 'posts_by_author' end @@ -59,7 +68,7 @@ Rails.application.routes.draw do delete 'photo_associations' => 'photo_associations#destroy' - resources :crops do + resources :crops, concerns: [:photo_attachable, :ownable] do get 'harvests' => 'harvests#index' get 'plantings' => 'plantings#index' From 5d8352db0806887d212697978f831ae1d421b900 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Tue, 1 Jan 2019 21:40:00 +1300 Subject: [PATCH 003/207] DRY the routes --- config/routes.rb | 62 ++++++++++++++++++++++-------------------------- 1 file changed, 28 insertions(+), 34 deletions(-) diff --git a/config/routes.rb b/config/routes.rb index 6872ae9a9..85491561a 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -17,48 +17,37 @@ Rails.application.routes.draw do get "home/index" root to: 'home#index' - - concern :photo_attachable do + concern :has_photos do resources :photos, only: :index end - concern :ownable do - get 'owner/:owner' => 'gardens#index', on: :collection + concern :has_owner do + get 'owner/:owner' => 'gardens#index', as: :by_owner, on: :collection end - resources :gardens do - get 'timeline' => 'charts/gardens#timeline' - get 'owner/:owner' => 'gardens#index', as: 'gardens_by_owner', on: :collection + resources :gardens, concerns: [:has_photos, :has_owner] do + get 'timeline' => 'charts/gardens#timeline', constraints: { format: 'json' } end - resources :plantings, concerns: [:photo_attachable, :ownable] do - get :harvests - get :seeds + resources :plantings, concerns: [:has_photos, :has_owner] do + resources :harvests + resources :seeds collection do - get 'owner/:owner' => 'plantings#index', as: 'plantings_by_owner' get 'crop/:crop' => 'plantings#index', as: 'plantings_by_crop' end end - resources :seeds, concerns: [:photo_attachable, :ownable] do - get :plantings - collection do - get 'owner/:owner' => 'seeds#index', as: 'seeds_by_owner' - get 'crop/:crop' => 'seeds#index', as: 'seeds_by_crop' - end + resources :seeds, concerns: [:has_photos, :has_owner] do + resources :plantings + get 'crop/:crop' => 'seeds#index', as: 'seeds_by_crop', on: :collection end - resources :harvests, concerns: [:photo_attachable, :ownable] do - collection do - get 'owner/:owner' => 'harvests#index', as: 'harvests_by_owner' - get 'crop/:crop' => 'harvests#index', as: 'harvests_by_crop' - end + resources :harvests, concerns: [:has_photos, :has_owner] do + get 'crop/:crop' => 'harvests#index', as: 'harvests_by_crop', on: :collection end - resources :posts, concerns: :ownable do - collection do - get 'author/:author' => 'posts#index', as: 'posts_by_author' - end + resources :posts do + get 'author/:author' => 'posts#index', as: 'by_author', on: :collection end resources :scientific_names @@ -68,20 +57,25 @@ Rails.application.routes.draw do delete 'photo_associations' => 'photo_associations#destroy' - resources :crops, concerns: [:photo_attachable, :ownable] do + resources :crops, concerns: [:has_photos, :has_owner] do + get 'gardens' => 'gardens#index' get 'harvests' => 'harvests#index' get 'plantings' => 'plantings#index' + get 'seeds' => 'seeds#index' - # Charts + get 'places' => 'places#index' + get 'members' => 'members#index' + + # Charts json get 'sunniness' => 'charts/crops#sunniness', constraints: { format: 'json' } get 'planted_from' => 'charts/crops#planted_from', constraints: { format: 'json' } get 'harvested_for' => 'charts/crops#harvested_for', constraints: { format: 'json' } collection do - get 'requested' => 'crops#requested', as: 'requested_crops' - get 'wrangle' => 'crops#wrangle', as: 'wrangle_crops' - get 'hierarchy' => 'crops#hierarchy', as: 'crops_hierarchy' - get 'search' => 'crops#search', as: 'search' + get 'requested' + get 'wrangle' + get 'hierarchy' + get 'search' end end @@ -101,8 +95,8 @@ Rails.application.routes.draw do resources :places do collection do - get 'search' => 'places#search', as: 'search_places' - get ':place' => 'places#show', as: 'place' + get 'search' + get ':place' => 'places#show' end end From 68953188f8e10c76f03b3b911c0dac7279ccf127 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Tue, 1 Jan 2019 21:40:14 +1300 Subject: [PATCH 004/207] Update to new path names --- app/controllers/gardens_controller.rb | 2 +- app/helpers/application_helper.rb | 4 ++-- app/views/crops/new.html.haml | 2 +- app/views/crops/search.html.haml | 2 +- app/views/crops/show.html.haml | 2 +- app/views/crops/wrangle.html.haml | 2 +- app/views/gardens/_nav.haml | 2 +- app/views/harvests/_nav.haml | 2 +- app/views/harvests/index.html.haml | 6 +++--- app/views/harvests/show.html.haml | 2 +- app/views/layouts/_header.html.haml | 12 ++++++------ app/views/members/_stats.html.haml | 8 ++++---- app/views/plantings/_nav.haml | 4 ++-- app/views/plantings/index.html.haml | 2 +- app/views/plantings/show.html.haml | 2 +- app/views/posts/index.html.haml | 4 ++-- app/views/seeds/index.html.haml | 8 ++++---- app/views/seeds/show.html.haml | 2 +- spec/features/crops/crop_detail_page_spec.rb | 2 +- spec/features/crops/crop_search_spec.rb | 4 ++-- spec/features/harvests/harvesting_a_crop_spec.rb | 2 +- spec/features/member_profile_spec.rb | 8 ++++---- spec/features/plantings/planting_a_crop_spec.rb | 2 +- spec/features/seeds/misc_seeds_spec.rb | 2 +- spec/views/layouts/_header_spec.rb | 10 +++++----- 25 files changed, 49 insertions(+), 49 deletions(-) diff --git a/app/controllers/gardens_controller.rb b/app/controllers/gardens_controller.rb index 132430976..f1075ba35 100644 --- a/app/controllers/gardens_controller.rb +++ b/app/controllers/gardens_controller.rb @@ -57,7 +57,7 @@ class GardensController < ApplicationController def destroy @garden.destroy flash[:notice] = I18n.t('gardens.deleted') - redirect_to(gardens_by_owner_path(owner: @garden.owner)) + redirect_to(by_owner_gardens_path(owner: @garden.owner)) end private diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index f9d821fc6..8bd560114 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -70,8 +70,8 @@ module ApplicationHelper def show_inactive_tickbox_path(type, owner, show_all) all = show_all ? '' : 1 if owner - return plantings_by_owner_path(owner: owner.slug, all: all) if type == 'plantings' - return gardens_by_owner_path(owner: owner.slug, all: all) if type == 'gardens' + return by_owner_plantings_path(owner: owner.slug, all: all) if type == 'plantings' + return by_owner_gardens_path(owner: owner.slug, all: all) if type == 'gardens' end return plantings_path(all: all) if type == 'plantings' diff --git a/app/views/crops/new.html.haml b/app/views/crops/new.html.haml index 86b0aad17..843281d14 100644 --- a/app/views/crops/new.html.haml +++ b/app/views/crops/new.html.haml @@ -7,7 +7,7 @@ things to consider when suggesting a new crop: %ul %li - First, you might want to #{link_to 'search our crops', crops_search_path} + First, you might want to #{link_to 'search our crops', search_crops_path} to make sure we don't have it already, perhaps under an alternate name. %li The Growstuff database only contains edible crops. In future we hope to diff --git a/app/views/crops/search.html.haml b/app/views/crops/search.html.haml index e47f2d484..1d1879447 100644 --- a/app/views/crops/search.html.haml +++ b/app/views/crops/search.html.haml @@ -6,7 +6,7 @@ - content_for :title, "Crop search" %div - = form_tag crops_search_path, method: :get, id: 'crop-search', class: 'form-inline' do + = form_tag search_crops_path, method: :get, id: 'crop-search', class: 'form-inline' do .form-group = label_tag :term, "Search crops:", class: 'sr-only' = text_field_tag 'term', nil, diff --git a/app/views/crops/show.html.haml b/app/views/crops/show.html.haml index 940cc814e..7ac05bde3 100644 --- a/app/views/crops/show.html.haml +++ b/app/views/crops/show.html.haml @@ -23,7 +23,7 @@ .col-md-12 - if member_signed_in? = display_seed_availability(@current_member, @crop) - = link_to "View your seeds", seeds_by_owner_path(owner: current_member.slug) + = link_to "View your seeds", by_owner_seeds_path(owner: current_member.slug) %h2 - if !@crop.plantings.empty? diff --git a/app/views/crops/wrangle.html.haml b/app/views/crops/wrangle.html.haml index fc8ba3015..f8dd9ab76 100644 --- a/app/views/crops/wrangle.html.haml +++ b/app/views/crops/wrangle.html.haml @@ -5,7 +5,7 @@ %li= link_to "Requests for new crops", 'http://growstuff.org/posts/skud-20130319-requests-for-new-crops' %li= link_to "Crop wrangler guidelines", "http://wiki.growstuff.org/index.php/Crop_wrangling" %li= link_to "crop-wranglers mailing list", "http://lists.growstuff.org/listinfo/crop-wranglers" - %li= link_to "Full crop hierarchy", crops_hierarchy_path + %li= link_to "Full crop hierarchy", hierarchy_crops_path %li= link_to "Add Crop", new_crop_path .crop_wranglers diff --git a/app/views/gardens/_nav.haml b/app/views/gardens/_nav.haml index 36c828b87..da1efaa32 100644 --- a/app/views/gardens/_nav.haml +++ b/app/views/gardens/_nav.haml @@ -1,6 +1,6 @@ - content_for :buttonbar do - if current_member - = link_to 'My Gardens', gardens_by_owner_path(owner: current_member.slug), class: 'btn btn-default' + = link_to 'My Gardens', by_owner_gardens_path(owner: current_member.slug), class: 'btn btn-default' = link_to "Everyone's gardens", gardens_path, class: 'btn btn-default' diff --git a/app/views/harvests/_nav.haml b/app/views/harvests/_nav.haml index af79e49fd..089a6e7a3 100644 --- a/app/views/harvests/_nav.haml +++ b/app/views/harvests/_nav.haml @@ -10,6 +10,6 @@ - else # everyone's harvests = link_to 'Add harvest', new_harvest_path, class: 'btn btn-primary' - if current_member - = link_to 'View your harvests', harvests_by_owner_path(owner: current_member.slug), class: 'btn btn-default' + = link_to 'View your harvests', by_owner_harvests_path(owner: current_member.slug), class: 'btn btn-default' - else = render partial: 'shared/signin_signup', locals: { to: 'track your harvests' } diff --git a/app/views/harvests/index.html.haml b/app/views/harvests/index.html.haml index 4ef4a427b..f25b26c21 100644 --- a/app/views/harvests/index.html.haml +++ b/app/views/harvests/index.html.haml @@ -24,9 +24,9 @@ %ul.list-inline %li The data on this page is available in the following formats: - if @owner - %li= link_to "RSS", harvests_by_owner_path(@owner, format: 'rss') - %li= link_to "CSV", harvests_by_owner_path(@owner, format: 'csv') - %li= link_to "JSON", harvests_by_owner_path(@owner, format: 'json') + %li= link_to "RSS", by_owner_harvests_path(@owner, format: 'rss') + %li= link_to "CSV", by_owner_harvests_path(@owner, format: 'csv') + %li= link_to "JSON", by_owner_harvests_path(@owner, format: 'json') - else %li= link_to "RSS", harvests_path(format: 'rss') %li= link_to "CSV", harvests_path(format: 'csv') diff --git a/app/views/harvests/show.html.haml b/app/views/harvests/show.html.haml index a584389fe..848959c90 100644 --- a/app/views/harvests/show.html.haml +++ b/app/views/harvests/show.html.haml @@ -14,7 +14,7 @@ %b Owner: = link_to @harvest.owner, @harvest.owner — - = link_to "view all #{@harvest.owner}'s harvests", harvests_by_owner_path(owner: @harvest.owner.slug) + = link_to "view all #{@harvest.owner}'s harvests", by_owner_harvests_path(owner: @harvest.owner.slug) %p %b Plant part: - if @harvest.plant_part diff --git a/app/views/layouts/_header.html.haml b/app/views/layouts/_header.html.haml index d2b8fd01c..1b27df6a9 100644 --- a/app/views/layouts/_header.html.haml +++ b/app/views/layouts/_header.html.haml @@ -17,7 +17,7 @@ alt: ENV['GROWSTUFF_SITE_NAME']) .form.navbar-form.pull-left - = form_tag crops_search_path, method: :get, id: 'navbar-search' do + = form_tag search_crops_path, method: :get, id: 'navbar-search' do = label_tag :term, "Search crop database:", class: 'sr-only' .input .input-group @@ -58,11 +58,11 @@ %b.caret %ul.dropdown-menu %li= link_to t('.profile'), member_path(current_member) - %li= link_to t('.gardens'), gardens_by_owner_path(owner: current_member.slug) - %li= link_to t('.plantings'), plantings_by_owner_path(owner: current_member.slug) - %li= link_to t('.harvest'), harvests_by_owner_path(owner: current_member.slug) - %li= link_to t('.seeds'), seeds_by_owner_path(owner: current_member.slug) - %li= link_to t('.posts'), posts_by_author_path(author: current_member.slug) + %li= link_to t('.gardens'), by_owner_gardens_path(owner: current_member.slug) + %li= link_to t('.plantings'), by_owner_plantings_path(owner: current_member.slug) + %li= link_to t('.harvest'), by_owner_harvests_path(owner: current_member.slug) + %li= link_to t('.seeds'), by_owner_seeds_path(owner: current_member.slug) + %li= link_to t('.posts'), by_author_posts_path(author: current_member.slug) %li - if current_member.notifications.unread_count.positive? = link_to(t('.inbox_unread', unread_count: current_member.notifications.unread_count), diff --git a/app/views/members/_stats.html.haml b/app/views/members/_stats.html.haml index 2db447d4c..f175fcbcd 100644 --- a/app/views/members/_stats.html.haml +++ b/app/views/members/_stats.html.haml @@ -10,22 +10,22 @@ %ul.activity-list %li - if !member.plantings.empty? - = link_to localize_plural(member.plantings, Planting), plantings_by_owner_path(owner: member) + = link_to localize_plural(member.plantings, Planting), by_owner_plantings_path(owner: member) - else 0 plantings %li - if !member.harvests.empty? - = link_to localize_plural(member.harvests, Harvest), harvests_by_owner_path(owner: member) + = link_to localize_plural(member.harvests, Harvest), by_owner_harvests_path(owner: member) - else 0 harvests %li - if !member.seeds.empty? - = link_to localize_plural(member.seeds, Seed), seeds_by_owner_path(owner: member) + = link_to localize_plural(member.seeds, Seed), by_owner_seeds_path(owner: member) - else 0 seeds %li - if !member.posts.empty? - = link_to localize_plural(member.posts, Post), posts_by_author_path(author: member) + = link_to localize_plural(member.posts, Post), by_author_posts_path(author: member) - else 0 posts diff --git a/app/views/plantings/_nav.haml b/app/views/plantings/_nav.haml index 396d6e021..c7e37c399 100644 --- a/app/views/plantings/_nav.haml +++ b/app/views/plantings/_nav.haml @@ -1,9 +1,9 @@ - content_for :buttonbar do - if current_member - = link_to 'My Plantings', plantings_by_owner_path(owner: current_member.slug), class: 'btn btn-default' + = link_to 'My Plantings', by_owner_plantings_path(owner: current_member.slug), class: 'btn btn-default' - if owner && owner != current_member - = link_to "#{owner.login_name}'s Plantings", plantings_by_owner_path(owner: owner.slug), class: 'btn btn-default' + = link_to "#{owner.login_name}'s Plantings", by_owner_plantings_path(owner: owner.slug), class: 'btn btn-default' = link_to "Everyone's plantings", plantings_path, class: 'btn btn-default' = link_to plantings_active_tickbox_path(@owner, show_all) do diff --git a/app/views/plantings/index.html.haml b/app/views/plantings/index.html.haml index 2dc58ccde..c0f9ff44f 100644 --- a/app/views/plantings/index.html.haml +++ b/app/views/plantings/index.html.haml @@ -23,4 +23,4 @@ %li= t('.the_data_on_this_page_is_available_in_the_following_formats') - ['csv', 'json', 'rss'].each do |format| %li= link_to format.upcase, - (@owner ? plantings_by_owner_path(@owner, format: format) : plantings_path(format: format)) + (@owner ? by_owner_plantings_path(@owner, format: format) : plantings_path(format: format)) diff --git a/app/views/plantings/show.html.haml b/app/views/plantings/show.html.haml index 49be10fa5..f6a48a9c5 100644 --- a/app/views/plantings/show.html.haml +++ b/app/views/plantings/show.html.haml @@ -19,7 +19,7 @@ %dd = link_to @planting.owner, @planting.owner — - = link_to "view all #{@planting.owner}'s plantings", plantings_by_owner_path(owner: @planting.owner.slug) + = link_to "view all #{@planting.owner}'s plantings", by_owner_plantings_path(owner: @planting.owner.slug) %dt Planted on: %dd= @planting.planted_at ? @planting.planted_at : "not specified" diff --git a/app/views/posts/index.html.haml b/app/views/posts/index.html.haml index a099469bd..14a5c3a4b 100644 --- a/app/views/posts/index.html.haml +++ b/app/views/posts/index.html.haml @@ -10,7 +10,7 @@ - else # everyone's posts = link_to 'Post something', new_post_path, class: 'btn btn-primary' - if current_member - = link_to 'View your posts', posts_by_author_path(author: current_member.slug), class: 'btn btn-default' + = link_to 'View your posts', by_author_posts_path(author: current_member.slug), class: 'btn btn-default' - else = render partial: 'shared/signin_signup', locals: { to: 'write a post' } @@ -30,7 +30,7 @@ - if @author Subscribe to = succeed "." do - = link_to "#{@author}'s posts RSS feed", posts_by_author_path(format: 'rss', author: @author) + = link_to "#{@author}'s posts RSS feed", by_author_posts_path(format: 'rss', author: @author) - else Subscribe to the #{ENV['GROWSTUFF_SITE_NAME']} diff --git a/app/views/seeds/index.html.haml b/app/views/seeds/index.html.haml index 5e2eabece..9da4cc6bb 100644 --- a/app/views/seeds/index.html.haml +++ b/app/views/seeds/index.html.haml @@ -16,7 +16,7 @@ - else # everyone's seeds = link_to 'Add seeds', new_seed_path, class: 'btn btn-primary' - if current_member - = link_to 'View your seeds', seeds_by_owner_path(owner: current_member.slug), class: 'btn btn-default' + = link_to 'View your seeds', by_owner_seeds_path(owner: current_member.slug), class: 'btn btn-default' - else = render partial: 'shared/signin_signup', locals: { to: 'add seeds to your stash' } @@ -37,9 +37,9 @@ %ul.list-inline %li The data on this page is available in the following formats: - if @owner - %li= link_to "CSV", seeds_by_owner_path(@owner, format: 'csv') - %li= link_to "JSON", seeds_by_owner_path(@owner, format: 'json') - %li= link_to "RSS", seeds_by_owner_path(@owner, format: 'rss') + %li= link_to "CSV", by_owner_seeds_path(@owner, format: 'csv') + %li= link_to "JSON", by_owner_seeds_path(@owner, format: 'json') + %li= link_to "RSS", by_owner_seeds_path(@owner, format: 'rss') - else %li= link_to "CSV", seeds_path(format: 'csv') %li= link_to "JSON", seeds_path(format: 'json') diff --git a/app/views/seeds/show.html.haml b/app/views/seeds/show.html.haml index 681a21324..15a7d0e12 100644 --- a/app/views/seeds/show.html.haml +++ b/app/views/seeds/show.html.haml @@ -20,7 +20,7 @@ = link_to @seed.owner, @seed.owner — = link_to "view all #{@seed.owner}'s seeds", - seeds_by_owner_path(owner: @seed.owner.slug) + by_owner_seeds_path(owner: @seed.owner.slug) %dt Quantity: %dd= @seed.quantity.blank? ? "not specified" : @seed.quantity %dt Plant before: diff --git a/spec/features/crops/crop_detail_page_spec.rb b/spec/features/crops/crop_detail_page_spec.rb index cbc73cf9c..1334d2a63 100644 --- a/spec/features/crops/crop_detail_page_spec.rb +++ b/spec/features/crops/crop_detail_page_spec.rb @@ -173,7 +173,7 @@ feature "crop detail page", js: true do login_as(member) visit crop_path(seed.crop) click_link "View your seeds" - expect(current_path).to eq seeds_by_owner_path(owner: member.slug) + expect(current_path).to eq by_owner_seeds_path(owner: member.slug) end end diff --git a/spec/features/crops/crop_search_spec.rb b/spec/features/crops/crop_search_spec.rb index f2f86980c..0cea2e168 100644 --- a/spec/features/crops/crop_search_spec.rb +++ b/spec/features/crops/crop_search_spec.rb @@ -11,12 +11,12 @@ feature "crop search" do end scenario "search page with no search term shows suitable title" do - visit crops_search_path + visit search_crops_path expect(page).to have_css "h1", text: "Crop search" end scenario "search page has a search form on it" do - visit crops_search_path + visit search_crops_path expect(page).to have_css "form#crop-search" end end diff --git a/spec/features/harvests/harvesting_a_crop_spec.rb b/spec/features/harvests/harvesting_a_crop_spec.rb index 5f6d85fa2..cb4f50da9 100644 --- a/spec/features/harvests/harvesting_a_crop_spec.rb +++ b/spec/features/harvests/harvesting_a_crop_spec.rb @@ -57,7 +57,7 @@ feature "Harvesting a crop", :js, :elasticsearch do end scenario "Clicking link to owner's profile" do - visit harvests_by_owner_path(member) + visit by_owner_harvests_path(member) click_link "View #{member}'s profile >>" expect(current_path).to eq member_path member end diff --git a/spec/features/member_profile_spec.rb b/spec/features/member_profile_spec.rb index db7d4f595..ac58e2121 100644 --- a/spec/features/member_profile_spec.rb +++ b/spec/features/member_profile_spec.rb @@ -81,10 +81,10 @@ feature "member profile", js: true do create_list :seed, 4, owner: member create_list :post, 5, author: member visit member_path(member) - expect(page).to have_link "2 plantings", href: plantings_by_owner_path(owner: member) - expect(page).to have_link "3 harvests", href: harvests_by_owner_path(owner: member) - expect(page).to have_link "4 seeds", href: seeds_by_owner_path(owner: member) - expect(page).to have_link "5 posts", href: posts_by_author_path(author: member) + expect(page).to have_link "2 plantings", href: by_owner_plantings_path(owner: member) + expect(page).to have_link "3 harvests", href: by_owner_harvests_path(owner: member) + expect(page).to have_link "4 seeds", href: by_owner_seeds_path(owner: member) + expect(page).to have_link "5 posts", href: by_author_posts_path(author: member) end end diff --git a/spec/features/plantings/planting_a_crop_spec.rb b/spec/features/plantings/planting_a_crop_spec.rb index 1d8b7f745..92a68e30c 100644 --- a/spec/features/plantings/planting_a_crop_spec.rb +++ b/spec/features/plantings/planting_a_crop_spec.rb @@ -49,7 +49,7 @@ feature "Planting a crop", :js, :elasticsearch do end scenario "Clicking link to owner's profile" do - visit plantings_by_owner_path(member) + visit by_owner_plantings_path(member) click_link "View #{member}'s profile >>" expect(current_path).to eq member_path(member) end diff --git a/spec/features/seeds/misc_seeds_spec.rb b/spec/features/seeds/misc_seeds_spec.rb index e095ed390..528627fe4 100644 --- a/spec/features/seeds/misc_seeds_spec.rb +++ b/spec/features/seeds/misc_seeds_spec.rb @@ -29,7 +29,7 @@ feature "seeds", js: true do describe "Clicking link to owner's profile" do before do - visit seeds_by_owner_path(member) + visit by_owner_seeds_path(member) click_link "View #{member}'s profile >>" end it { expect(current_path).to eq member_path(member) } diff --git a/spec/views/layouts/_header_spec.rb b/spec/views/layouts/_header_spec.rb index 5060fc30d..cb2eb54a7 100644 --- a/spec/views/layouts/_header_spec.rb +++ b/spec/views/layouts/_header_spec.rb @@ -45,7 +45,7 @@ describe 'layouts/_header.html.haml', type: "view" do end it 'has a crop search' do - assert_select("form[action='#{crops_search_path}']") + assert_select("form[action='#{search_crops_path}']") assert_select("input#term") end end @@ -63,16 +63,16 @@ describe 'layouts/_header.html.haml', type: "view" do rendered.should have_content @member.login_name.to_s end it "should show link to member's gardens" do - assert_select("a[href='#{gardens_by_owner_path(owner: @member.slug)}']", "Gardens") + assert_select("a[href='#{by_owner_gardens_path(owner: @member.slug)}']", "Gardens") end it "should show link to member's plantings" do - assert_select("a[href='#{plantings_by_owner_path(owner: @member.slug)}']", "Plantings") + assert_select("a[href='#{by_owner_plantings_path(owner: @member.slug)}']", "Plantings") end it "should show link to member's seeds" do - assert_select("a[href='#{seeds_by_owner_path(owner: @member.slug)}']", "Seeds") + assert_select("a[href='#{by_owner_seeds_path(owner: @member.slug)}']", "Seeds") end it "should show link to member's posts" do - assert_select("a[href='#{posts_by_author_path(author: @member.slug)}']", "Posts") + assert_select("a[href='#{by_author_posts_path(author: @member.slug)}']", "Posts") end end From 6167d02e66439ccc92aa9fef6f5c215e5f317a16 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Tue, 1 Jan 2019 21:44:19 +1300 Subject: [PATCH 005/207] Fixed path in auto suggest helper --- app/helpers/auto_suggest_helper.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/helpers/auto_suggest_helper.rb b/app/helpers/auto_suggest_helper.rb index efa2e9ab6..6d4637d4e 100644 --- a/app/helpers/auto_suggest_helper.rb +++ b/app/helpers/auto_suggest_helper.rb @@ -10,7 +10,7 @@ module AutoSuggestHelper end resource = resource.class.name.downcase - source_path = Rails.application.routes.url_helpers.send("#{source}s_search_path") + source_path = Rails.application.routes.url_helpers.send("search_#{source}s_path") %( Date: Tue, 1 Jan 2019 22:03:24 +1300 Subject: [PATCH 006/207] Simplify places routes --- app/views/members/_location.html.haml | 2 +- config/routes.rb | 5 +---- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/app/views/members/_location.html.haml b/app/views/members/_location.html.haml index 884ff04b2..eff2aa6d9 100644 --- a/app/views/members/_location.html.haml +++ b/app/views/members/_location.html.haml @@ -2,4 +2,4 @@ - if member.location.blank? unknown location - else - = link_to member.location, place_path(place: member.location, anchor: "members") + = link_to member.location, place_path(member.location, anchor: "members") diff --git a/config/routes.rb b/config/routes.rb index 85491561a..64e8c053d 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -94,10 +94,7 @@ Rails.application.routes.draw do end resources :places do - collection do - get 'search' - get ':place' => 'places#show' - end + get 'search', on: :collection end get 'auth/:provider/callback' => 'authentications#create' From 37cba79a525b1fd435860300745f04542ff5b710 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Tue, 1 Jan 2019 22:04:57 +1300 Subject: [PATCH 007/207] Fixed newsletters route --- config/routes.rb | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/config/routes.rb b/config/routes.rb index 64e8c053d..d1dd3ac0c 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -101,9 +101,11 @@ Rails.application.routes.draw do get 'members/auth/:provider/callback' => 'authentications#create' resources :admin, only: :index do - get 'newsletter' resources :members - get ':action' => 'admin#:action', on: :collection + collection do + get 'newsletter' + get ':action' => 'admin#:action' + end end namespace :api do From 7a09e20b71131fd586d8119d254547bdb7d4980c Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Tue, 1 Jan 2019 22:31:54 +1300 Subject: [PATCH 008/207] Fixed admin routes. namespace, not a resource --- config/routes.rb | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/config/routes.rb b/config/routes.rb index d1dd3ac0c..662c6d905 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -100,12 +100,11 @@ Rails.application.routes.draw do get 'auth/:provider/callback' => 'authentications#create' get 'members/auth/:provider/callback' => 'authentications#create' - resources :admin, only: :index do + namespace :admin do resources :members - collection do - get 'newsletter' - get ':action' => 'admin#:action' - end + get '/' => 'admin#index' + get 'newsletter', as: :newsletter + get ':action' => 'admin#:action' end namespace :api do From 99a69bf192daaa262e8b6b25b9652bca8cac9c66 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Tue, 1 Jan 2019 22:37:32 +1300 Subject: [PATCH 009/207] Tidy up places routes --- app/controllers/places_controller.rb | 4 ++-- config/routes.rb | 2 +- spec/controllers/places_controller_spec.rb | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/app/controllers/places_controller.rb b/app/controllers/places_controller.rb index 4586b5d39..360b99426 100644 --- a/app/controllers/places_controller.rb +++ b/app/controllers/places_controller.rb @@ -17,8 +17,8 @@ class PlacesController < ApplicationController # GET /places/london # GET /places/london.json def show - @place = params[:place] # used for page title - @nearby_members = Member.nearest_to(params[:place]) + @place = params[:id] # used for page title + @nearby_members = Member.nearest_to(params[:id]) respond_to do |format| format.html # show.html.haml format.json do diff --git a/config/routes.rb b/config/routes.rb index 662c6d905..62d235d93 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -93,7 +93,7 @@ Rails.application.routes.draw do get 'reply', on: :member end - resources :places do + resources :places, only: [:index, :show] do get 'search', on: :collection end diff --git a/spec/controllers/places_controller_spec.rb b/spec/controllers/places_controller_spec.rb index d235b98c9..b49377bdf 100644 --- a/spec/controllers/places_controller_spec.rb +++ b/spec/controllers/places_controller_spec.rb @@ -12,12 +12,12 @@ describe PlacesController do end it "assigns place name" do - get :show, params: { place: @member_london.location } + get :show, params: { id: @member_london.location } assigns(:place).should eq @member_london.location end it "assigns nearby members" do - get :show, params: { place: @member_london.location } + get :show, params: { id: @member_london.location } assigns(:nearby_members).should eq [@member_london, @member_south_pole] end end From 57d53a5c0edfd4c40c7b102daf51fc744d400aca Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Tue, 1 Jan 2019 22:44:12 +1300 Subject: [PATCH 010/207] Fixed naming of member follows/following route --- config/routes.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/config/routes.rb b/config/routes.rb index 62d235d93..0879fe719 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -86,8 +86,8 @@ Rails.application.routes.draw do resources :follows, only: %i(create destroy) resources :likes, only: %i(create destroy) resources :members do - get 'follows' => 'members#view_follows', as: 'member_follows' - get 'followers' => 'members#view_followers', as: 'member_followers' + get 'follows' => 'members#view_follows' + get 'followers' => 'members#view_followers' end resources :notifications do get 'reply', on: :member From 387200abf7a716b931ccbb4a6318ceeaab511ba1 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Wed, 2 Jan 2019 13:10:05 +1300 Subject: [PATCH 011/207] Moving garden data under members --- app/controllers/gardens_controller.rb | 2 +- app/controllers/members_controller.rb | 6 ++--- app/controllers/plantings_controller.rb | 14 ++++++----- app/controllers/seeds_controller.rb | 18 +++++--------- app/helpers/application_helper.rb | 4 ++-- app/models/member.rb | 4 ++++ app/views/crops/show.html.haml | 2 +- app/views/gardens/_nav.haml | 2 +- app/views/harvests/_nav.haml | 2 +- app/views/harvests/index.html.haml | 6 ++--- app/views/harvests/show.html.haml | 2 +- app/views/layouts/_header.html.haml | 10 ++++---- app/views/members/_stats.html.haml | 8 +++---- app/views/plantings/_nav.haml | 4 ++-- app/views/plantings/index.html.haml | 2 +- app/views/plantings/show.html.haml | 2 +- app/views/posts/index.html.haml | 4 ++-- app/views/seeds/index.html.haml | 9 +++---- app/views/seeds/show.html.haml | 2 +- config/routes.rb | 24 +++++++++++-------- spec/controllers/member_controller_spec.rb | 14 +++++------ spec/features/crops/crop_detail_page_spec.rb | 2 +- .../harvests/harvesting_a_crop_spec.rb | 2 +- spec/features/member_profile_spec.rb | 8 +++---- .../plantings/planting_a_crop_spec.rb | 2 +- spec/features/seeds/misc_seeds_spec.rb | 2 +- spec/views/layouts/_header_spec.rb | 8 +++---- 27 files changed, 85 insertions(+), 80 deletions(-) diff --git a/app/controllers/gardens_controller.rb b/app/controllers/gardens_controller.rb index f1075ba35..f9381fabb 100644 --- a/app/controllers/gardens_controller.rb +++ b/app/controllers/gardens_controller.rb @@ -57,7 +57,7 @@ class GardensController < ApplicationController def destroy @garden.destroy flash[:notice] = I18n.t('gardens.deleted') - redirect_to(by_owner_gardens_path(owner: @garden.owner)) + redirect_to(member_gardens_path(owner: @garden.owner)) end private diff --git a/app/controllers/members_controller.rb b/app/controllers/members_controller.rb index 5ff82ab9f..772dbbbc9 100644 --- a/app/controllers/members_controller.rb +++ b/app/controllers/members_controller.rb @@ -13,7 +13,7 @@ class MembersController < ApplicationController end def show - @member = Member.confirmed.find(params[:id]) + @member = Member.confirmed.find_by!(login_name: params[:login_name]) @twitter_auth = @member.auth('twitter') @flickr_auth = @member.auth('flickr') @facebook_auth = @member.auth('facebook') @@ -39,12 +39,12 @@ class MembersController < ApplicationController end def view_follows - @member = Member.confirmed.find(params[:login_name]) + @member = Member.confirmed.find(params[:member_login_name]) @follows = @member.followed.paginate(page: params[:page]) end def view_followers - @member = Member.confirmed.find(params[:login_name]) + @member = Member.confirmed.find(params[:member_login_name]) @followers = @member.followers.paginate(page: params[:page]) end diff --git a/app/controllers/plantings_controller.rb b/app/controllers/plantings_controller.rb index fc3db888b..8903f569b 100644 --- a/app/controllers/plantings_controller.rb +++ b/app/controllers/plantings_controller.rb @@ -16,12 +16,6 @@ class PlantingsController < ApplicationController @plantings = plantings - specifics = if @owner - "#{@owner.login_name}-" - elsif @crop - "#{@crop.name}-" - end - @filename = "Growstuff-#{specifics}Plantings-#{Time.zone.now.to_s(:number)}.csv" respond_with(@plantings) @@ -104,4 +98,12 @@ class PlantingsController < ApplicationController .includes(:crop, :owner, :garden) .paginate(page: params[:page]) end + + def specifics + if @owner + "#{@owner.login_name}-" + elsif @crop + "#{@crop.name}-" + end + end end diff --git a/app/controllers/seeds_controller.rb b/app/controllers/seeds_controller.rb index b18e6090a..aae6af147 100644 --- a/app/controllers/seeds_controller.rb +++ b/app/controllers/seeds_controller.rb @@ -10,7 +10,11 @@ class SeedsController < ApplicationController def index @owner = Member.find_by(slug: params[:owner]) @crop = Crop.find_by(slug: params[:crop]) - @seeds = seeds(owner: @owner, crop: @crop) + + @seeds = @seeds.where(owner: @owner) if @owner.present? + @seeds = @seeds.where(crop: @crop) if @crop.present? + @seeds = @seeds.order(created_at: :desc).includes(:owner, :crop).paginate(page: params[:page]) + @filename = csv_filename respond_with(@seeds) @@ -64,17 +68,7 @@ class SeedsController < ApplicationController :finished, :finished_at ) end - - def seeds(owner: nil, crop: nil) - if owner - owner.seeds - elsif crop - crop.seeds - else - Seed - end.order(created_at: :desc).includes(:owner, :crop).paginate(page: params[:page]) - end - + def csv_filename if @owner "Growstuff-#{@owner}-Seeds-#{Time.zone.now.to_s(:number)}.csv" diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 8bd560114..e171b26a2 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -70,8 +70,8 @@ module ApplicationHelper def show_inactive_tickbox_path(type, owner, show_all) all = show_all ? '' : 1 if owner - return by_owner_plantings_path(owner: owner.slug, all: all) if type == 'plantings' - return by_owner_gardens_path(owner: owner.slug, all: all) if type == 'gardens' + return member_plantings_path(owner: owner.slug, all: all) if type == 'plantings' + return member_gardens_path(owner: owner.slug, all: all) if type == 'gardens' end return plantings_path(all: all) if type == 'plantings' diff --git a/app/models/member.rb b/app/models/member.rb index 2247bd038..d0e1b28dd 100644 --- a/app/models/member.rb +++ b/app/models/member.rb @@ -106,6 +106,10 @@ class Member < ApplicationRecord login_name end + def to_param + login_name + end + def role?(role_sym) roles.any? { |r| r.name.gsub(/\s+/, "_").underscore.to_sym == role_sym } end diff --git a/app/views/crops/show.html.haml b/app/views/crops/show.html.haml index 7ac05bde3..a88034d6c 100644 --- a/app/views/crops/show.html.haml +++ b/app/views/crops/show.html.haml @@ -23,7 +23,7 @@ .col-md-12 - if member_signed_in? = display_seed_availability(@current_member, @crop) - = link_to "View your seeds", by_owner_seeds_path(owner: current_member.slug) + = link_to "View your seeds", member_seeds_path(owner: current_member.slug) %h2 - if !@crop.plantings.empty? diff --git a/app/views/gardens/_nav.haml b/app/views/gardens/_nav.haml index da1efaa32..95cc1a7b7 100644 --- a/app/views/gardens/_nav.haml +++ b/app/views/gardens/_nav.haml @@ -1,6 +1,6 @@ - content_for :buttonbar do - if current_member - = link_to 'My Gardens', by_owner_gardens_path(owner: current_member.slug), class: 'btn btn-default' + = link_to 'My Gardens', member_gardens_path(owner: current_member.slug), class: 'btn btn-default' = link_to "Everyone's gardens", gardens_path, class: 'btn btn-default' diff --git a/app/views/harvests/_nav.haml b/app/views/harvests/_nav.haml index 089a6e7a3..014e9e7b9 100644 --- a/app/views/harvests/_nav.haml +++ b/app/views/harvests/_nav.haml @@ -10,6 +10,6 @@ - else # everyone's harvests = link_to 'Add harvest', new_harvest_path, class: 'btn btn-primary' - if current_member - = link_to 'View your harvests', by_owner_harvests_path(owner: current_member.slug), class: 'btn btn-default' + = link_to 'View your harvests', member_harvests_path(owner: current_member.slug), class: 'btn btn-default' - else = render partial: 'shared/signin_signup', locals: { to: 'track your harvests' } diff --git a/app/views/harvests/index.html.haml b/app/views/harvests/index.html.haml index f25b26c21..5438b11af 100644 --- a/app/views/harvests/index.html.haml +++ b/app/views/harvests/index.html.haml @@ -24,9 +24,9 @@ %ul.list-inline %li The data on this page is available in the following formats: - if @owner - %li= link_to "RSS", by_owner_harvests_path(@owner, format: 'rss') - %li= link_to "CSV", by_owner_harvests_path(@owner, format: 'csv') - %li= link_to "JSON", by_owner_harvests_path(@owner, format: 'json') + %li= link_to "RSS", member_harvests_path(@owner, format: 'rss') + %li= link_to "CSV", member_harvests_path(@owner, format: 'csv') + %li= link_to "JSON", member_harvests_path(@owner, format: 'json') - else %li= link_to "RSS", harvests_path(format: 'rss') %li= link_to "CSV", harvests_path(format: 'csv') diff --git a/app/views/harvests/show.html.haml b/app/views/harvests/show.html.haml index 848959c90..3e67305fa 100644 --- a/app/views/harvests/show.html.haml +++ b/app/views/harvests/show.html.haml @@ -14,7 +14,7 @@ %b Owner: = link_to @harvest.owner, @harvest.owner — - = link_to "view all #{@harvest.owner}'s harvests", by_owner_harvests_path(owner: @harvest.owner.slug) + = link_to "view all #{@harvest.owner}'s harvests", member_harvests_path(owner: @harvest.owner.slug) %p %b Plant part: - if @harvest.plant_part diff --git a/app/views/layouts/_header.html.haml b/app/views/layouts/_header.html.haml index 1b27df6a9..6d765b52e 100644 --- a/app/views/layouts/_header.html.haml +++ b/app/views/layouts/_header.html.haml @@ -58,11 +58,11 @@ %b.caret %ul.dropdown-menu %li= link_to t('.profile'), member_path(current_member) - %li= link_to t('.gardens'), by_owner_gardens_path(owner: current_member.slug) - %li= link_to t('.plantings'), by_owner_plantings_path(owner: current_member.slug) - %li= link_to t('.harvest'), by_owner_harvests_path(owner: current_member.slug) - %li= link_to t('.seeds'), by_owner_seeds_path(owner: current_member.slug) - %li= link_to t('.posts'), by_author_posts_path(author: current_member.slug) + %li= link_to t('.gardens'), member_gardens_path(owner: current_member.slug) + %li= link_to t('.plantings'), member_plantings_path(owner: current_member.slug) + %li= link_to t('.harvest'), member_harvests_path(owner: current_member.slug) + %li= link_to t('.seeds'), member_seeds_path(owner: current_member.slug) + %li= link_to t('.posts'), member_posts_path_path(author: current_member.slug) %li - if current_member.notifications.unread_count.positive? = link_to(t('.inbox_unread', unread_count: current_member.notifications.unread_count), diff --git a/app/views/members/_stats.html.haml b/app/views/members/_stats.html.haml index f175fcbcd..676705722 100644 --- a/app/views/members/_stats.html.haml +++ b/app/views/members/_stats.html.haml @@ -10,22 +10,22 @@ %ul.activity-list %li - if !member.plantings.empty? - = link_to localize_plural(member.plantings, Planting), by_owner_plantings_path(owner: member) + = link_to localize_plural(member.plantings, Planting), member_plantings_path(owner: member) - else 0 plantings %li - if !member.harvests.empty? - = link_to localize_plural(member.harvests, Harvest), by_owner_harvests_path(owner: member) + = link_to localize_plural(member.harvests, Harvest), member_harvests_path(owner: member) - else 0 harvests %li - if !member.seeds.empty? - = link_to localize_plural(member.seeds, Seed), by_owner_seeds_path(owner: member) + = link_to localize_plural(member.seeds, Seed), member_seeds_path(owner: member) - else 0 seeds %li - if !member.posts.empty? - = link_to localize_plural(member.posts, Post), by_author_posts_path(author: member) + = link_to localize_plural(member.posts, Post), member_posts_path_path(author: member) - else 0 posts diff --git a/app/views/plantings/_nav.haml b/app/views/plantings/_nav.haml index c7e37c399..67a59b673 100644 --- a/app/views/plantings/_nav.haml +++ b/app/views/plantings/_nav.haml @@ -1,9 +1,9 @@ - content_for :buttonbar do - if current_member - = link_to 'My Plantings', by_owner_plantings_path(owner: current_member.slug), class: 'btn btn-default' + = link_to 'My Plantings', member_plantings_path(owner: current_member.slug), class: 'btn btn-default' - if owner && owner != current_member - = link_to "#{owner.login_name}'s Plantings", by_owner_plantings_path(owner: owner.slug), class: 'btn btn-default' + = link_to "#{owner.login_name}'s Plantings", member_plantings_path(owner: owner.slug), class: 'btn btn-default' = link_to "Everyone's plantings", plantings_path, class: 'btn btn-default' = link_to plantings_active_tickbox_path(@owner, show_all) do diff --git a/app/views/plantings/index.html.haml b/app/views/plantings/index.html.haml index c0f9ff44f..11aca2270 100644 --- a/app/views/plantings/index.html.haml +++ b/app/views/plantings/index.html.haml @@ -23,4 +23,4 @@ %li= t('.the_data_on_this_page_is_available_in_the_following_formats') - ['csv', 'json', 'rss'].each do |format| %li= link_to format.upcase, - (@owner ? by_owner_plantings_path(@owner, format: format) : plantings_path(format: format)) + (@owner ? member_plantings_path(@owner, format: format) : plantings_path(format: format)) diff --git a/app/views/plantings/show.html.haml b/app/views/plantings/show.html.haml index f6a48a9c5..4ccd96ecd 100644 --- a/app/views/plantings/show.html.haml +++ b/app/views/plantings/show.html.haml @@ -19,7 +19,7 @@ %dd = link_to @planting.owner, @planting.owner — - = link_to "view all #{@planting.owner}'s plantings", by_owner_plantings_path(owner: @planting.owner.slug) + = link_to "view all #{@planting.owner}'s plantings", member_plantings_path(owner: @planting.owner.slug) %dt Planted on: %dd= @planting.planted_at ? @planting.planted_at : "not specified" diff --git a/app/views/posts/index.html.haml b/app/views/posts/index.html.haml index 14a5c3a4b..4aea8146e 100644 --- a/app/views/posts/index.html.haml +++ b/app/views/posts/index.html.haml @@ -10,7 +10,7 @@ - else # everyone's posts = link_to 'Post something', new_post_path, class: 'btn btn-primary' - if current_member - = link_to 'View your posts', by_author_posts_path(author: current_member.slug), class: 'btn btn-default' + = link_to 'View your posts', member_posts_path_path(author: current_member.slug), class: 'btn btn-default' - else = render partial: 'shared/signin_signup', locals: { to: 'write a post' } @@ -30,7 +30,7 @@ - if @author Subscribe to = succeed "." do - = link_to "#{@author}'s posts RSS feed", by_author_posts_path(format: 'rss', author: @author) + = link_to "#{@author}'s posts RSS feed", member_posts_path_path(format: 'rss', author: @author) - else Subscribe to the #{ENV['GROWSTUFF_SITE_NAME']} diff --git a/app/views/seeds/index.html.haml b/app/views/seeds/index.html.haml index 9da4cc6bb..02edddc82 100644 --- a/app/views/seeds/index.html.haml +++ b/app/views/seeds/index.html.haml @@ -1,4 +1,5 @@ - content_for :title, title('seeds', @owner, @crop, @planting) + - if @owner = link_to "View #{@owner}'s profile >>", member_path(@owner) @@ -16,7 +17,7 @@ - else # everyone's seeds = link_to 'Add seeds', new_seed_path, class: 'btn btn-primary' - if current_member - = link_to 'View your seeds', by_owner_seeds_path(owner: current_member.slug), class: 'btn btn-default' + = link_to 'View your seeds', member_seeds_path(owner: current_member.slug), class: 'btn btn-default' - else = render partial: 'shared/signin_signup', locals: { to: 'add seeds to your stash' } @@ -37,9 +38,9 @@ %ul.list-inline %li The data on this page is available in the following formats: - if @owner - %li= link_to "CSV", by_owner_seeds_path(@owner, format: 'csv') - %li= link_to "JSON", by_owner_seeds_path(@owner, format: 'json') - %li= link_to "RSS", by_owner_seeds_path(@owner, format: 'rss') + %li= link_to "CSV", member_seeds_path(@owner, format: 'csv') + %li= link_to "JSON", member_seeds_path(@owner, format: 'json') + %li= link_to "RSS", member_seeds_path(@owner, format: 'rss') - else %li= link_to "CSV", seeds_path(format: 'csv') %li= link_to "JSON", seeds_path(format: 'json') diff --git a/app/views/seeds/show.html.haml b/app/views/seeds/show.html.haml index 15a7d0e12..8b8c17049 100644 --- a/app/views/seeds/show.html.haml +++ b/app/views/seeds/show.html.haml @@ -20,7 +20,7 @@ = link_to @seed.owner, @seed.owner — = link_to "view all #{@seed.owner}'s seeds", - by_owner_seeds_path(owner: @seed.owner.slug) + member_seeds_path(owner: @seed.owner.slug) %dt Quantity: %dd= @seed.quantity.blank? ? "not specified" : @seed.quantity %dt Plant before: diff --git a/config/routes.rb b/config/routes.rb index 0879fe719..7a39324b5 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -21,15 +21,11 @@ Rails.application.routes.draw do resources :photos, only: :index end - concern :has_owner do - get 'owner/:owner' => 'gardens#index', as: :by_owner, on: :collection - end - - resources :gardens, concerns: [:has_photos, :has_owner] do + resources :gardens, concerns: :has_photos do get 'timeline' => 'charts/gardens#timeline', constraints: { format: 'json' } end - resources :plantings, concerns: [:has_photos, :has_owner] do + resources :plantings, concerns: :has_photos do resources :harvests resources :seeds collection do @@ -37,12 +33,12 @@ Rails.application.routes.draw do end end - resources :seeds, concerns: [:has_photos, :has_owner] do + resources :seeds, concerns: :has_photos do resources :plantings get 'crop/:crop' => 'seeds#index', as: 'seeds_by_crop', on: :collection end - resources :harvests, concerns: [:has_photos, :has_owner] do + resources :harvests, concerns: :has_photos do get 'crop/:crop' => 'harvests#index', as: 'harvests_by_crop', on: :collection end @@ -57,7 +53,7 @@ Rails.application.routes.draw do delete 'photo_associations' => 'photo_associations#destroy' - resources :crops, concerns: [:has_photos, :has_owner] do + resources :crops, concerns: :has_photos do get 'gardens' => 'gardens#index' get 'harvests' => 'harvests#index' get 'plantings' => 'plantings#index' @@ -85,10 +81,18 @@ Rails.application.routes.draw do resources :follows, only: %i(create destroy) resources :likes, only: %i(create destroy) - resources :members do + + resources :members, param: :login_name do get 'follows' => 'members#view_follows' get 'followers' => 'members#view_followers' + + resources :gardens + resources :seeds + resources :plantings + resources :harvests + resources :posts end + resources :notifications do get 'reply', on: :member end diff --git a/spec/controllers/member_controller_spec.rb b/spec/controllers/member_controller_spec.rb index 8e6b91283..783f4d433 100644 --- a/spec/controllers/member_controller_spec.rb +++ b/spec/controllers/member_controller_spec.rb @@ -24,40 +24,40 @@ describe MembersController do describe "GET show" do it "provides JSON for member profile" do - get :show, params: { id: @member.id }, format: 'json' + get :show, params: { login_name: @member.to_param }, format: 'json' response.should be_success end it "assigns @posts with the member's posts" do - get :show, params: { id: @member.id } + get :show, params: { login_name: @member.to_param } assigns(:posts).should eq(@posts) end it "assigns @twitter_auth" do - get :show, params: { id: @member.id } + get :show, params: { login_name: @member.to_param } assigns(:twitter_auth).should eq(@twitter_auth) end it "assigns @flickr_auth" do - get :show, params: { id: @member.id } + get :show, params: { login_name: @member.to_param } assigns(:flickr_auth).should eq(@flickr_auth) end it "doesn't show completely nonsense members" do - get :show, params: { id: 9999 } + get :show, params: { login_name: 9999 } expect(response).to have_http_status(:not_found) end it "doesn't show unconfirmed members" do @member2 = FactoryBot.create(:unconfirmed_member) - get :show, params: { id: @member2.id } + get :show, params: { login_name: @member2.id } expect(response).to have_http_status(:not_found) end end describe "GET member's RSS feed" do it "returns an RSS feed" do - get :show, params: { id: @member.to_param }, format: "rss" + get :show, params: { login_name: @member.to_param }, format: "rss" response.should be_success response.should render_template("members/show") response.content_type.should eq("application/rss+xml") diff --git a/spec/features/crops/crop_detail_page_spec.rb b/spec/features/crops/crop_detail_page_spec.rb index 1334d2a63..712c0feaf 100644 --- a/spec/features/crops/crop_detail_page_spec.rb +++ b/spec/features/crops/crop_detail_page_spec.rb @@ -173,7 +173,7 @@ feature "crop detail page", js: true do login_as(member) visit crop_path(seed.crop) click_link "View your seeds" - expect(current_path).to eq by_owner_seeds_path(owner: member.slug) + expect(current_path).to eq member_seeds_path(owner: member.slug) end end diff --git a/spec/features/harvests/harvesting_a_crop_spec.rb b/spec/features/harvests/harvesting_a_crop_spec.rb index cb4f50da9..8b812d266 100644 --- a/spec/features/harvests/harvesting_a_crop_spec.rb +++ b/spec/features/harvests/harvesting_a_crop_spec.rb @@ -57,7 +57,7 @@ feature "Harvesting a crop", :js, :elasticsearch do end scenario "Clicking link to owner's profile" do - visit by_owner_harvests_path(member) + visit member_harvests_path(member) click_link "View #{member}'s profile >>" expect(current_path).to eq member_path member end diff --git a/spec/features/member_profile_spec.rb b/spec/features/member_profile_spec.rb index ac58e2121..1798469ee 100644 --- a/spec/features/member_profile_spec.rb +++ b/spec/features/member_profile_spec.rb @@ -81,10 +81,10 @@ feature "member profile", js: true do create_list :seed, 4, owner: member create_list :post, 5, author: member visit member_path(member) - expect(page).to have_link "2 plantings", href: by_owner_plantings_path(owner: member) - expect(page).to have_link "3 harvests", href: by_owner_harvests_path(owner: member) - expect(page).to have_link "4 seeds", href: by_owner_seeds_path(owner: member) - expect(page).to have_link "5 posts", href: by_author_posts_path(author: member) + expect(page).to have_link "2 plantings", href: member_plantings_path(owner: member) + expect(page).to have_link "3 harvests", href: member_harvests_path(owner: member) + expect(page).to have_link "4 seeds", href: member_seeds_path(owner: member) + expect(page).to have_link "5 posts", href: member_posts_path_path(author: member) end end diff --git a/spec/features/plantings/planting_a_crop_spec.rb b/spec/features/plantings/planting_a_crop_spec.rb index 92a68e30c..e62eb8d1e 100644 --- a/spec/features/plantings/planting_a_crop_spec.rb +++ b/spec/features/plantings/planting_a_crop_spec.rb @@ -49,7 +49,7 @@ feature "Planting a crop", :js, :elasticsearch do end scenario "Clicking link to owner's profile" do - visit by_owner_plantings_path(member) + visit member_plantings_path(member) click_link "View #{member}'s profile >>" expect(current_path).to eq member_path(member) end diff --git a/spec/features/seeds/misc_seeds_spec.rb b/spec/features/seeds/misc_seeds_spec.rb index 528627fe4..dc1e41416 100644 --- a/spec/features/seeds/misc_seeds_spec.rb +++ b/spec/features/seeds/misc_seeds_spec.rb @@ -29,7 +29,7 @@ feature "seeds", js: true do describe "Clicking link to owner's profile" do before do - visit by_owner_seeds_path(member) + visit member_seeds_path(member) click_link "View #{member}'s profile >>" end it { expect(current_path).to eq member_path(member) } diff --git a/spec/views/layouts/_header_spec.rb b/spec/views/layouts/_header_spec.rb index cb2eb54a7..9c6d0e786 100644 --- a/spec/views/layouts/_header_spec.rb +++ b/spec/views/layouts/_header_spec.rb @@ -63,16 +63,16 @@ describe 'layouts/_header.html.haml', type: "view" do rendered.should have_content @member.login_name.to_s end it "should show link to member's gardens" do - assert_select("a[href='#{by_owner_gardens_path(owner: @member.slug)}']", "Gardens") + assert_select("a[href='#{member_gardens_path(owner: @member.slug)}']", "Gardens") end it "should show link to member's plantings" do - assert_select("a[href='#{by_owner_plantings_path(owner: @member.slug)}']", "Plantings") + assert_select("a[href='#{member_plantings_path(owner: @member.slug)}']", "Plantings") end it "should show link to member's seeds" do - assert_select("a[href='#{by_owner_seeds_path(owner: @member.slug)}']", "Seeds") + assert_select("a[href='#{member_seeds_path(owner: @member.slug)}']", "Seeds") end it "should show link to member's posts" do - assert_select("a[href='#{by_author_posts_path(author: @member.slug)}']", "Posts") + assert_select("a[href='#{member_posts_path_path(author: @member.slug)}']", "Posts") end end From 1e266a92f6e6845697ff01e57c0a1e9fcef6039f Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Wed, 2 Jan 2019 21:25:53 +1300 Subject: [PATCH 012/207] Members slug used in rotes --- app/controllers/crops_controller.rb | 2 +- app/controllers/gardens_controller.rb | 15 ++++++--------- app/controllers/harvests_controller.rb | 25 +++++++++---------------- app/controllers/members_controller.rb | 6 +++--- app/controllers/plantings_controller.rb | 11 +++++++++-- app/controllers/seeds_controller.rb | 4 ++-- app/helpers/application_helper.rb | 4 ++-- app/models/crop.rb | 4 ++++ app/views/crops/_find_seeds.html.haml | 2 +- app/views/crops/_photos.html.haml | 2 +- app/views/crops/_plantings.html.haml | 2 +- app/views/harvests/show.html.haml | 2 +- app/views/layouts/_header.html.haml | 10 +++++----- app/views/members/_stats.html.haml | 8 ++++---- app/views/plantings/show.html.haml | 2 +- app/views/posts/index.html.haml | 4 ++-- app/views/seeds/show.html.haml | 2 +- config/routes.rb | 4 ++-- spec/features/member_profile_spec.rb | 8 ++++---- spec/views/layouts/_header_spec.rb | 8 ++++---- 20 files changed, 63 insertions(+), 62 deletions(-) diff --git a/app/controllers/crops_controller.rb b/app/controllers/crops_controller.rb index abfb47a0e..ab0dc361a 100644 --- a/app/controllers/crops_controller.rb +++ b/app/controllers/crops_controller.rb @@ -49,7 +49,7 @@ class CropsController < ApplicationController end def show - @crop = Crop.includes(:scientific_names, plantings: :photos).find(params[:id]) + @crop = Crop.includes(:scientific_names, plantings: :photos).find(params[:slug]) @posts = @crop.posts.order(created_at: :desc).paginate(page: params[:page]) # respond_with(@crop) respond_to do |format| diff --git a/app/controllers/gardens_controller.rb b/app/controllers/gardens_controller.rb index f9381fabb..16095d468 100644 --- a/app/controllers/gardens_controller.rb +++ b/app/controllers/gardens_controller.rb @@ -7,9 +7,12 @@ class GardensController < ApplicationController # GET /gardens # GET /gardens.json def index - @owner = Member.find_by(slug: params[:owner]) + @owner = Member.find_by(slug: params[:member_slug]) @show_all = params[:all] == '1' - @gardens = gardens + + @gardens = @gardens.active unless @show_all + @gardens = @gardens.where(owner: @owner) if @owner.present? + @gardens = @gardens.joins(:owner).order(:name).paginate(page: params[:page]) respond_with(@gardens) end @@ -57,7 +60,7 @@ class GardensController < ApplicationController def destroy @garden.destroy flash[:notice] = I18n.t('gardens.deleted') - redirect_to(member_gardens_path(owner: @garden.owner)) + redirect_to(member_gardens_path(@garden.owner)) end private @@ -66,10 +69,4 @@ class GardensController < ApplicationController params.require(:garden).permit(:name, :slug, :description, :active, :location, :latitude, :longitude, :area, :area_unit) end - - def gardens - g = @owner ? @owner.gardens : Garden.all - g = g.active unless @show_all - g.joins(:owner).order(:name).paginate(page: params[:page]) - end end diff --git a/app/controllers/harvests_controller.rb b/app/controllers/harvests_controller.rb index 6ea5b32ca..2f252edf2 100644 --- a/app/controllers/harvests_controller.rb +++ b/app/controllers/harvests_controller.rb @@ -7,12 +7,17 @@ class HarvestsController < ApplicationController responders :flash def index - @owner = Member.find_by(slug: params[:owner]) if params[:owner] - @crop = Crop.find_by(slug: params[:crop]) if params[:crop] - @planting = Planting.find_by(slug: params[:planting_id]) if params[:planting_id] + @owner = Member.find_by(slug: params[:member_slug]) + @crop = Crop.find_by(slug: params[:crop_slug]) + @planting = Planting.find_by(slug: params[:planting_id]) - @harvests = harvests + @harvests = @harvests.where(owner: @owner) if @owner.present? + @harvests = @harvests.where(crop: @crop) if @crop.present? + @harvests = @harvests.where(planting: @planting) if @planting.present? + @harvests = @harvests.order(harvested_at: :desc).joins(:owner, :crop).paginate(page: params[:page]) + @filename = csv_filename + respond_with(@harvests) end @@ -67,18 +72,6 @@ class HarvestsController < ApplicationController .where('(finished_at IS NULL OR finished_at >= ?)', @harvest.harvested_at) end - def harvests - if @owner - @owner.harvests - elsif @crop - @crop.harvests - elsif @planting - @planting.harvests - else - Harvest.all - end.order(harvested_at: :desc).joins(:owner, :crop).paginate(page: params[:page]) - end - def csv_filename specifics = if @owner "#{@owner.login_name}-" diff --git a/app/controllers/members_controller.rb b/app/controllers/members_controller.rb index 772dbbbc9..80aac26c5 100644 --- a/app/controllers/members_controller.rb +++ b/app/controllers/members_controller.rb @@ -13,7 +13,7 @@ class MembersController < ApplicationController end def show - @member = Member.confirmed.find_by!(login_name: params[:login_name]) + @member = Member.confirmed.find_by!(slug: params[:slug]) @twitter_auth = @member.auth('twitter') @flickr_auth = @member.auth('flickr') @facebook_auth = @member.auth('facebook') @@ -39,12 +39,12 @@ class MembersController < ApplicationController end def view_follows - @member = Member.confirmed.find(params[:member_login_name]) + @member = Member.confirmed.find(params[:owner]) @follows = @member.followed.paginate(page: params[:page]) end def view_followers - @member = Member.confirmed.find(params[:member_login_name]) + @member = Member.confirmed.find(params[:owner]) @followers = @member.followers.paginate(page: params[:page]) end diff --git a/app/controllers/plantings_controller.rb b/app/controllers/plantings_controller.rb index 8903f569b..8d8c7b996 100644 --- a/app/controllers/plantings_controller.rb +++ b/app/controllers/plantings_controller.rb @@ -10,11 +10,18 @@ class PlantingsController < ApplicationController responders :flash def index - @owner = Member.find_by(slug: params[:owner]) if params[:owner] + @owner = Member.find_by(slug: params[:member_slug]) @crop = Crop.find_by(slug: params[:crop]) if params[:crop] + @show_all = params[:all] == '1' - @plantings = plantings + @plantings = @plantings.where(owner: @owner) if @owner.present? + @plantings = @plantings.where(crop: @crop) if @crop.present? + + @plantings = @plantings.joins(:owner, :crop, :garden) + .order(created_at: :desc) + .includes(:crop, :owner, :garden) + .paginate(page: params[:page]) @filename = "Growstuff-#{specifics}Plantings-#{Time.zone.now.to_s(:number)}.csv" diff --git a/app/controllers/seeds_controller.rb b/app/controllers/seeds_controller.rb index aae6af147..ce4e8ac40 100644 --- a/app/controllers/seeds_controller.rb +++ b/app/controllers/seeds_controller.rb @@ -8,8 +8,8 @@ class SeedsController < ApplicationController # GET /seeds # GET /seeds.json def index - @owner = Member.find_by(slug: params[:owner]) - @crop = Crop.find_by(slug: params[:crop]) + @owner = Member.find_by(slug: params[:member_slug]) + @crop = Crop.find_by(slug: params[:crop_slug]) @seeds = @seeds.where(owner: @owner) if @owner.present? @seeds = @seeds.where(crop: @crop) if @crop.present? diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index e171b26a2..f33c4e633 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -70,8 +70,8 @@ module ApplicationHelper def show_inactive_tickbox_path(type, owner, show_all) all = show_all ? '' : 1 if owner - return member_plantings_path(owner: owner.slug, all: all) if type == 'plantings' - return member_gardens_path(owner: owner.slug, all: all) if type == 'gardens' + return member_plantings_path(member_slug: owner.slug, all: all) if type == 'plantings' + return member_gardens_path(member_slug: owner.slug, all: all) if type == 'gardens' end return plantings_path(all: all) if type == 'plantings' diff --git a/app/models/crop.rb b/app/models/crop.rb index 2846b8a5f..c786d5b4d 100644 --- a/app/models/crop.rb +++ b/app/models/crop.rb @@ -110,6 +110,10 @@ class Crop < ApplicationRecord name end + def to_param + slug + end + def default_scientific_name scientific_names.first.name unless scientific_names.empty? end diff --git a/app/views/crops/_find_seeds.html.haml b/app/views/crops/_find_seeds.html.haml index 83967fc86..81b5d0abf 100644 --- a/app/views/crops/_find_seeds.html.haml +++ b/app/views/crops/_find_seeds.html.haml @@ -9,7 +9,7 @@ = link_to "#{seed.owner} will trade #{seed.tradable_to}.", seed_path(seed) = render partial: 'members/location', locals: { member: seed.owner } %p - = link_to "View all #{crop.name} seeds", seeds_by_crop_path(crop) + = link_to "View all #{crop.name} seeds", crop_seeds_path(crop) %p = link_to "Purchase seeds via Ebay", crop_ebay_seeds_url(crop), diff --git a/app/views/crops/_photos.html.haml b/app/views/crops/_photos.html.haml index b799876a9..efa42dcf1 100644 --- a/app/views/crops/_photos.html.haml +++ b/app/views/crops/_photos.html.haml @@ -12,4 +12,4 @@ .col-xs-6.col-md-2 = render "photos/thumbnail", photo: p .row - = link_to "more photos", crop_photos_path(crop_id: crop.id) + = link_to "more photos", crop_photos_path(crop) diff --git a/app/views/crops/_plantings.html.haml b/app/views/crops/_plantings.html.haml index ca05632a3..1da5c3644 100644 --- a/app/views/crops/_plantings.html.haml +++ b/app/views/crops/_plantings.html.haml @@ -12,7 +12,7 @@ = distance_of_time_in_words(planting.created_at, Time.zone.now) ago. %p - = link_to "View all #{crop.name} plantings", plantings_by_crop_path(crop) + = link_to "View all #{crop.name} plantings", crop_plantings_path(crop) - if crop.approved? - if current_member %p= link_to "Plant #{crop.name}", new_planting_path(crop_id: crop.id) diff --git a/app/views/harvests/show.html.haml b/app/views/harvests/show.html.haml index 3e67305fa..85469f430 100644 --- a/app/views/harvests/show.html.haml +++ b/app/views/harvests/show.html.haml @@ -14,7 +14,7 @@ %b Owner: = link_to @harvest.owner, @harvest.owner — - = link_to "view all #{@harvest.owner}'s harvests", member_harvests_path(owner: @harvest.owner.slug) + = link_to "view all #{@harvest.owner}'s harvests", member_harvests_path(@harvest.owner) %p %b Plant part: - if @harvest.plant_part diff --git a/app/views/layouts/_header.html.haml b/app/views/layouts/_header.html.haml index 6d765b52e..1728cc1c8 100644 --- a/app/views/layouts/_header.html.haml +++ b/app/views/layouts/_header.html.haml @@ -58,11 +58,11 @@ %b.caret %ul.dropdown-menu %li= link_to t('.profile'), member_path(current_member) - %li= link_to t('.gardens'), member_gardens_path(owner: current_member.slug) - %li= link_to t('.plantings'), member_plantings_path(owner: current_member.slug) - %li= link_to t('.harvest'), member_harvests_path(owner: current_member.slug) - %li= link_to t('.seeds'), member_seeds_path(owner: current_member.slug) - %li= link_to t('.posts'), member_posts_path_path(author: current_member.slug) + %li= link_to t('.gardens'), member_gardens_path(current_member) + %li= link_to t('.plantings'), member_plantings_path(current_member) + %li= link_to t('.harvest'), member_harvests_path(current_member) + %li= link_to t('.seeds'), member_seeds_path(current_member) + %li= link_to t('.posts'), member_posts_path(current_member) %li - if current_member.notifications.unread_count.positive? = link_to(t('.inbox_unread', unread_count: current_member.notifications.unread_count), diff --git a/app/views/members/_stats.html.haml b/app/views/members/_stats.html.haml index 676705722..83760dfd1 100644 --- a/app/views/members/_stats.html.haml +++ b/app/views/members/_stats.html.haml @@ -10,22 +10,22 @@ %ul.activity-list %li - if !member.plantings.empty? - = link_to localize_plural(member.plantings, Planting), member_plantings_path(owner: member) + = link_to localize_plural(member.plantings, Planting), member_plantings_path(member) - else 0 plantings %li - if !member.harvests.empty? - = link_to localize_plural(member.harvests, Harvest), member_harvests_path(owner: member) + = link_to localize_plural(member.harvests, Harvest), member_harvests_path(member) - else 0 harvests %li - if !member.seeds.empty? - = link_to localize_plural(member.seeds, Seed), member_seeds_path(owner: member) + = link_to localize_plural(member.seeds, Seed), member_seeds_path(member) - else 0 seeds %li - if !member.posts.empty? - = link_to localize_plural(member.posts, Post), member_posts_path_path(author: member) + = link_to localize_plural(member.posts, Post), member_posts_path(member) - else 0 posts diff --git a/app/views/plantings/show.html.haml b/app/views/plantings/show.html.haml index 4ccd96ecd..970aa43b7 100644 --- a/app/views/plantings/show.html.haml +++ b/app/views/plantings/show.html.haml @@ -19,7 +19,7 @@ %dd = link_to @planting.owner, @planting.owner — - = link_to "view all #{@planting.owner}'s plantings", member_plantings_path(owner: @planting.owner.slug) + = link_to "view all #{@planting.owner}'s plantings", member_plantings_path(@planting.owner) %dt Planted on: %dd= @planting.planted_at ? @planting.planted_at : "not specified" diff --git a/app/views/posts/index.html.haml b/app/views/posts/index.html.haml index 4aea8146e..47070db81 100644 --- a/app/views/posts/index.html.haml +++ b/app/views/posts/index.html.haml @@ -10,7 +10,7 @@ - else # everyone's posts = link_to 'Post something', new_post_path, class: 'btn btn-primary' - if current_member - = link_to 'View your posts', member_posts_path_path(author: current_member.slug), class: 'btn btn-default' + = link_to 'View your posts', member_posts_path(current_member), class: 'btn btn-default' - else = render partial: 'shared/signin_signup', locals: { to: 'write a post' } @@ -30,7 +30,7 @@ - if @author Subscribe to = succeed "." do - = link_to "#{@author}'s posts RSS feed", member_posts_path_path(format: 'rss', author: @author) + = link_to "#{@author}'s posts RSS feed", member_posts_path(format: 'rss', author: @author) - else Subscribe to the #{ENV['GROWSTUFF_SITE_NAME']} diff --git a/app/views/seeds/show.html.haml b/app/views/seeds/show.html.haml index 8b8c17049..e55faec48 100644 --- a/app/views/seeds/show.html.haml +++ b/app/views/seeds/show.html.haml @@ -20,7 +20,7 @@ = link_to @seed.owner, @seed.owner — = link_to "view all #{@seed.owner}'s seeds", - member_seeds_path(owner: @seed.owner.slug) + member_seeds_path(@seed.owner) %dt Quantity: %dd= @seed.quantity.blank? ? "not specified" : @seed.quantity %dt Plant before: diff --git a/config/routes.rb b/config/routes.rb index 7a39324b5..2324bc4ff 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -53,7 +53,7 @@ Rails.application.routes.draw do delete 'photo_associations' => 'photo_associations#destroy' - resources :crops, concerns: :has_photos do + resources :crops, param: :slug, concerns: :has_photos do get 'gardens' => 'gardens#index' get 'harvests' => 'harvests#index' get 'plantings' => 'plantings#index' @@ -82,7 +82,7 @@ Rails.application.routes.draw do resources :follows, only: %i(create destroy) resources :likes, only: %i(create destroy) - resources :members, param: :login_name do + resources :members, param: :slug do get 'follows' => 'members#view_follows' get 'followers' => 'members#view_followers' diff --git a/spec/features/member_profile_spec.rb b/spec/features/member_profile_spec.rb index 1798469ee..ab1a1fdbc 100644 --- a/spec/features/member_profile_spec.rb +++ b/spec/features/member_profile_spec.rb @@ -81,10 +81,10 @@ feature "member profile", js: true do create_list :seed, 4, owner: member create_list :post, 5, author: member visit member_path(member) - expect(page).to have_link "2 plantings", href: member_plantings_path(owner: member) - expect(page).to have_link "3 harvests", href: member_harvests_path(owner: member) - expect(page).to have_link "4 seeds", href: member_seeds_path(owner: member) - expect(page).to have_link "5 posts", href: member_posts_path_path(author: member) + expect(page).to have_link "2 plantings", href: member_plantings_path(member) + expect(page).to have_link "3 harvests", href: member_harvests_path(member) + expect(page).to have_link "4 seeds", href: member_seeds_path(member) + expect(page).to have_link "5 posts", href: member_posts_path(member) end end diff --git a/spec/views/layouts/_header_spec.rb b/spec/views/layouts/_header_spec.rb index 9c6d0e786..58509f589 100644 --- a/spec/views/layouts/_header_spec.rb +++ b/spec/views/layouts/_header_spec.rb @@ -63,16 +63,16 @@ describe 'layouts/_header.html.haml', type: "view" do rendered.should have_content @member.login_name.to_s end it "should show link to member's gardens" do - assert_select("a[href='#{member_gardens_path(owner: @member.slug)}']", "Gardens") + assert_select("a[href='#{member_gardens_path(@member)}']", "Gardens") end it "should show link to member's plantings" do - assert_select("a[href='#{member_plantings_path(owner: @member.slug)}']", "Plantings") + assert_select("a[href='#{member_plantings_path(@member)}']", "Plantings") end it "should show link to member's seeds" do - assert_select("a[href='#{member_seeds_path(owner: @member.slug)}']", "Seeds") + assert_select("a[href='#{member_seeds_path(@member)}']", "Seeds") end it "should show link to member's posts" do - assert_select("a[href='#{member_posts_path_path(author: @member.slug)}']", "Posts") + assert_select("a[href='#{member_posts_path(@member)}']", "Posts") end end From e313a7160ff460ef27a644cab9d8c1b427d2e1b8 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Wed, 2 Jan 2019 21:26:11 +1300 Subject: [PATCH 013/207] Active plantings option on plantings#index --- app/controllers/plantings_controller.rb | 2 ++ app/models/planting.rb | 1 + 2 files changed, 3 insertions(+) diff --git a/app/controllers/plantings_controller.rb b/app/controllers/plantings_controller.rb index 8d8c7b996..5fb09db73 100644 --- a/app/controllers/plantings_controller.rb +++ b/app/controllers/plantings_controller.rb @@ -18,6 +18,8 @@ class PlantingsController < ApplicationController @plantings = @plantings.where(owner: @owner) if @owner.present? @plantings = @plantings.where(crop: @crop) if @crop.present? + @plantings = @plantings.active unless params[:all] == '1' + @plantings = @plantings.joins(:owner, :crop, :garden) .order(created_at: :desc) .includes(:crop, :owner, :garden) diff --git a/app/models/planting.rb b/app/models/planting.rb index 984b55c03..f6dec4528 100644 --- a/app/models/planting.rb +++ b/app/models/planting.rb @@ -33,6 +33,7 @@ class Planting < ApplicationRecord ## ## Scopes default_scope { joins(:owner) } # Ensures the owner still exists + scope :active, -> { where(finished_at: nil)} scope :interesting, -> { has_photos.one_per_owner.order(planted_at: :desc) } scope :recent, -> { order(created_at: :desc) } scope :one_per_owner, lambda { From cd98f38c5d06450f87cf1ff06ec3cfc2ecf55058 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Wed, 2 Jan 2019 21:26:50 +1300 Subject: [PATCH 014/207] DRY the nav bars and make all the same --- app/views/gardens/_nav.haml | 10 ---------- app/views/gardens/index.html.haml | 2 +- app/views/harvests/_nav.haml | 15 --------------- app/views/harvests/index.html.haml | 3 ++- app/views/layouts/_nav.haml | 14 ++++++++++++++ app/views/plantings/_nav.haml | 17 ----------------- app/views/plantings/index.html.haml | 3 ++- app/views/seeds/index.html.haml | 14 +------------- 8 files changed, 20 insertions(+), 58 deletions(-) delete mode 100644 app/views/gardens/_nav.haml delete mode 100644 app/views/harvests/_nav.haml create mode 100644 app/views/layouts/_nav.haml delete mode 100644 app/views/plantings/_nav.haml diff --git a/app/views/gardens/_nav.haml b/app/views/gardens/_nav.haml deleted file mode 100644 index 95cc1a7b7..000000000 --- a/app/views/gardens/_nav.haml +++ /dev/null @@ -1,10 +0,0 @@ -- content_for :buttonbar do - - if current_member - = link_to 'My Gardens', member_gardens_path(owner: current_member.slug), class: 'btn btn-default' - - = link_to "Everyone's gardens", gardens_path, class: 'btn btn-default' - - - if can?(:create, Garden) - = link_to 'Add a garden', new_garden_path, class: 'btn btn-default' - - unless current_member - = render 'shared/signin_signup', to: 'add a new garden' diff --git a/app/views/gardens/index.html.haml b/app/views/gardens/index.html.haml index a09de73ff..aa9552041 100644 --- a/app/views/gardens/index.html.haml +++ b/app/views/gardens/index.html.haml @@ -1,6 +1,6 @@ - content_for :title, @owner ? "#{@owner}'s gardens" : "Everyone's gardens" -= render 'nav' += render 'layouts/nav', model: Garden = link_to gardens_active_tickbox_path(@owner, @show_all) do = check_box_tag 'active', 'all', @show_all diff --git a/app/views/harvests/_nav.haml b/app/views/harvests/_nav.haml deleted file mode 100644 index 014e9e7b9..000000000 --- a/app/views/harvests/_nav.haml +++ /dev/null @@ -1,15 +0,0 @@ -%p - - if can? :create, Harvest - - if @planting && @planting.owner == current_member - = link_to 'Add harvest', new_planting_harvest_path(planting: @planting), class: 'btn btn-primary' - - elsif @owner - %p - - if @owner == current_member - = link_to 'Add harvest', new_harvest_path, class: 'btn btn-primary' - = link_to "View everyone's harvests", harvests_path, class: 'btn btn-default' - - else # everyone's harvests - = link_to 'Add harvest', new_harvest_path, class: 'btn btn-primary' - - if current_member - = link_to 'View your harvests', member_harvests_path(owner: current_member.slug), class: 'btn btn-default' - - else - = render partial: 'shared/signin_signup', locals: { to: 'track your harvests' } diff --git a/app/views/harvests/index.html.haml b/app/views/harvests/index.html.haml index 5438b11af..186dd4f30 100644 --- a/app/views/harvests/index.html.haml +++ b/app/views/harvests/index.html.haml @@ -7,7 +7,8 @@ #{ENV['GROWSTUFF_SITE_NAME']} helps you track what you're harvesting from your home garden and see how productive it is. -= render "nav" += render 'layouts/nav', model: Harvest + .pagination = page_entries_info @harvests = will_paginate @harvests diff --git a/app/views/layouts/_nav.haml b/app/views/layouts/_nav.haml new file mode 100644 index 000000000..62310672c --- /dev/null +++ b/app/views/layouts/_nav.haml @@ -0,0 +1,14 @@ +- content_for :buttonbar do + - if current_member.present? + = link_to url_for([current_member, model]), class: 'btn btn-default' do + My #{model.model_name.human.pluralize} + + = link_to model, class: 'btn btn-default' do + Everyone's #{model.model_name.human.pluralize} + + - if can?(:create, model) + = link_to url_for([model, action: :new]), class: 'btn btn-default' do + Add a #{model.model_name.human} + + - unless current_member + = render 'shared/signin_signup', to: 'add a new seed' diff --git a/app/views/plantings/_nav.haml b/app/views/plantings/_nav.haml deleted file mode 100644 index 67a59b673..000000000 --- a/app/views/plantings/_nav.haml +++ /dev/null @@ -1,17 +0,0 @@ - -- content_for :buttonbar do - - if current_member - = link_to 'My Plantings', member_plantings_path(owner: current_member.slug), class: 'btn btn-default' - - if owner && owner != current_member - = link_to "#{owner.login_name}'s Plantings", member_plantings_path(owner: owner.slug), class: 'btn btn-default' - = link_to "Everyone's plantings", plantings_path, class: 'btn btn-default' - - = link_to plantings_active_tickbox_path(@owner, show_all) do - = check_box_tag 'active', 'all', show_all - include in-active - -- if current_member - - if can? :create, Planting - = link_to 'Plant something', new_planting_path, class: 'btn btn-primary' -- else - = render partial: 'shared/signin_signup', locals: { to: "track what you've planted" } diff --git a/app/views/plantings/index.html.haml b/app/views/plantings/index.html.haml index 11aca2270..4116021f3 100644 --- a/app/views/plantings/index.html.haml +++ b/app/views/plantings/index.html.haml @@ -1,6 +1,7 @@ - content_for :title, title('plantings', @owner, @crop, @planting) -= render 'nav', owner: @owner, show_all: @show_all += render 'layouts/nav', model: Planting + - if @owner = link_to t('.view_owners_profile', owner: @owner), member_path(@owner) diff --git a/app/views/seeds/index.html.haml b/app/views/seeds/index.html.haml index 02edddc82..9f81e4a98 100644 --- a/app/views/seeds/index.html.haml +++ b/app/views/seeds/index.html.haml @@ -7,19 +7,7 @@ #{ENV['GROWSTUFF_SITE_NAME']} helps you track your seed stash or trade seeds with other members. -%p - - if can? :create, Seed - - if @owner - %p - - if @owner == current_member - = link_to 'Add seeds', new_seed_path, class: 'btn btn-primary' - = link_to "View everyone's seeds", seeds_path, class: 'btn btn-default' - - else # everyone's seeds - = link_to 'Add seeds', new_seed_path, class: 'btn btn-primary' - - if current_member - = link_to 'View your seeds', member_seeds_path(owner: current_member.slug), class: 'btn btn-default' - - else - = render partial: 'shared/signin_signup', locals: { to: 'add seeds to your stash' } += render 'layouts/nav', model: Seed .pagination = page_entries_info @seeds From 1c44ef21929600cb283aeaab4d0e6b18a619b54f Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Wed, 2 Jan 2019 21:27:03 +1300 Subject: [PATCH 015/207] Active/not active tick box on plantings#index --- app/views/plantings/index.html.haml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/app/views/plantings/index.html.haml b/app/views/plantings/index.html.haml index 4116021f3..8950082ec 100644 --- a/app/views/plantings/index.html.haml +++ b/app/views/plantings/index.html.haml @@ -2,6 +2,9 @@ = render 'layouts/nav', model: Planting += link_to plantings_active_tickbox_path(@owner, @show_all) do + = check_box_tag 'active', 'all', @show_all + include in-active - if @owner = link_to t('.view_owners_profile', owner: @owner), member_path(@owner) From b2bceb58732d6132153e906267c2703fe9105ea0 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Wed, 2 Jan 2019 21:32:14 +1300 Subject: [PATCH 016/207] Fixed planting display by crop --- app/controllers/plantings_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/plantings_controller.rb b/app/controllers/plantings_controller.rb index 5fb09db73..ed4edf0e0 100644 --- a/app/controllers/plantings_controller.rb +++ b/app/controllers/plantings_controller.rb @@ -11,7 +11,7 @@ class PlantingsController < ApplicationController def index @owner = Member.find_by(slug: params[:member_slug]) - @crop = Crop.find_by(slug: params[:crop]) if params[:crop] + @crop = Crop.find_by(slug: params[:crop_slug]) @show_all = params[:all] == '1' From abc796605d12cb2398bf958699af754b018f4d25 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Wed, 2 Jan 2019 21:32:23 +1300 Subject: [PATCH 017/207] Tidier path the member data --- app/helpers/application_helper.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index f33c4e633..d93850629 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -70,8 +70,8 @@ module ApplicationHelper def show_inactive_tickbox_path(type, owner, show_all) all = show_all ? '' : 1 if owner - return member_plantings_path(member_slug: owner.slug, all: all) if type == 'plantings' - return member_gardens_path(member_slug: owner.slug, all: all) if type == 'gardens' + return member_plantings_path(owner, all: all) if type == 'plantings' + return member_gardens_path(owner, all: all) if type == 'gardens' end return plantings_path(all: all) if type == 'plantings' From 0a7137cae2fd588782bd8314c6a48f226130c792 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Wed, 2 Jan 2019 21:41:31 +1300 Subject: [PATCH 018/207] Fixed link to crop harvests --- app/views/crops/_harvests.html.haml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/crops/_harvests.html.haml b/app/views/crops/_harvests.html.haml index 4a70bb251..05d5cbe59 100644 --- a/app/views/crops/_harvests.html.haml +++ b/app/views/crops/_harvests.html.haml @@ -12,7 +12,7 @@ = distance_of_time_in_words(harvest.created_at, Time.zone.now) ago. %p - = link_to "View all #{crop.name} harvests", harvests_by_crop_path(crop) + = link_to "View all #{crop.name} harvests", crop_harvests_path(crop) - if crop.approved? - if current_member %p= link_to "Harvest #{crop.name}", new_harvest_path(crop_id: crop.id) From 42156dc9e941ae078676b8b55d8c13093f515ead Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Wed, 2 Jan 2019 21:41:43 +1300 Subject: [PATCH 019/207] Links to data by crop --- app/views/crops/show.html.haml | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/app/views/crops/show.html.haml b/app/views/crops/show.html.haml index a88034d6c..0d499ca3f 100644 --- a/app/views/crops/show.html.haml +++ b/app/views/crops/show.html.haml @@ -92,6 +92,24 @@ = render partial: 'wrangle', locals: { crop: @crop } + %p + %li + = link_to crop_seeds_path(@crop) do + View all #{@crop.name} seeds + (#{@crop.seeds.size}) + %li + = link_to crop_plantings_path(@crop) do + View all #{@crop.name} plantings + (#{@crop.plantings.size}) + %li + = link_to crop_harvests_path(@crop) do + View all #{@crop.name} harvests + (#{@crop.harvests.size}) + %p + - if member_signed_in? + = link_to member_seeds_path(current_member, crop_id: @crop.id) do + = display_seed_availability(@current_member, @crop) + %h4 How to grow #{@crop.name.pluralize} = render 'grown_for', crop: @crop From b85a8551b5b9ba5839c26a2fe4fc031ef606777a Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Wed, 2 Jan 2019 21:42:13 +1300 Subject: [PATCH 020/207] Don't duplicate seed availability info on page --- app/views/crops/show.html.haml | 3 --- 1 file changed, 3 deletions(-) diff --git a/app/views/crops/show.html.haml b/app/views/crops/show.html.haml index 0d499ca3f..664a7aa9e 100644 --- a/app/views/crops/show.html.haml +++ b/app/views/crops/show.html.haml @@ -21,9 +21,6 @@ .col-md-9 .row .col-md-12 - - if member_signed_in? - = display_seed_availability(@current_member, @crop) - = link_to "View your seeds", member_seeds_path(owner: current_member.slug) %h2 - if !@crop.plantings.empty? From c969a9f830a00d92cee5a25366f7990a0c0df249 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Thu, 3 Jan 2019 12:32:05 +1300 Subject: [PATCH 021/207] Use slug, not member name, for urls to members --- app/assets/javascripts/crops.js.erb | 2 +- app/assets/javascripts/members.js.erb | 2 +- app/models/member.rb | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/assets/javascripts/crops.js.erb b/app/assets/javascripts/crops.js.erb index cac1804f1..5c92b2adb 100644 --- a/app/assets/javascripts/crops.js.erb +++ b/app/assets/javascripts/crops.js.erb @@ -17,7 +17,7 @@ function showCropMap(cropmap) { var marker = new L.Marker(new L.LatLng(owner.latitude, owner.longitude)); var planting_url = "/plantings/" + planting.id; - var planting_link = "" + owner.login_name + "'s " + crop.name + ""; + var planting_link = "" + owner.slug + "'s " + crop.name + ""; var where = "

" + owner.location + "

"; diff --git a/app/assets/javascripts/members.js.erb b/app/assets/javascripts/members.js.erb index d7bb5020c..2d3752f53 100644 --- a/app/assets/javascripts/members.js.erb +++ b/app/assets/javascripts/members.js.erb @@ -18,7 +18,7 @@ if (document.getElementById("membermap") !== null) { var marker = new L.Marker(new L.LatLng(member.latitude, member.longitude)); var member_url = "/members/" + member.slug; - var member_link = "" + member.login_name + ""; + var member_link = "" + member.slug + ""; var where = "

" + member.location + "

"; diff --git a/app/models/member.rb b/app/models/member.rb index d0e1b28dd..834989eef 100644 --- a/app/models/member.rb +++ b/app/models/member.rb @@ -107,7 +107,7 @@ class Member < ApplicationRecord end def to_param - login_name + slug end def role?(role_sym) From 32e7016b5b9652a01d16f56e2f91594f3c854cee Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Thu, 3 Jan 2019 12:40:07 +1300 Subject: [PATCH 022/207] Fixed link to your own seeds --- app/views/crops/show.html.haml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/crops/show.html.haml b/app/views/crops/show.html.haml index 664a7aa9e..0b51e87f7 100644 --- a/app/views/crops/show.html.haml +++ b/app/views/crops/show.html.haml @@ -104,7 +104,7 @@ (#{@crop.harvests.size}) %p - if member_signed_in? - = link_to member_seeds_path(current_member, crop_id: @crop.id) do + = link_to member_seeds_path(current_member, crop_slug: @crop.slug) do = display_seed_availability(@current_member, @crop) %h4 How to grow #{@crop.name.pluralize} From ffb87a44327fc913940397b596f114f45afb7f76 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Thu, 3 Jan 2019 12:43:20 +1300 Subject: [PATCH 023/207] Validators of garden name uniquness, and slug name --- app/models/garden.rb | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/app/models/garden.rb b/app/models/garden.rb index 880dda91e..e712ce11c 100644 --- a/app/models/garden.rb +++ b/app/models/garden.rb @@ -18,8 +18,9 @@ class Garden < ApplicationRecord scope :active, -> { where(active: true) } scope :inactive, -> { where(active: false) } - validates :location, - length: { maximum: 255 } + validates :location, length: { maximum: 255 } + validates :slug, uniqueness: true + validates :name, uniqueness: { scope: :owner_id } validates :name, format: { From 07f06705af91b23c9a061b325b64cc6cc79b3ee8 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Thu, 3 Jan 2019 15:00:19 +1300 Subject: [PATCH 024/207] Fixed pi charts path --- app/controllers/charts/crops_controller.rb | 4 ++-- app/views/crops/show.html.haml | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/app/controllers/charts/crops_controller.rb b/app/controllers/charts/crops_controller.rb index b5fe3d4a7..6a1a0e6e8 100644 --- a/app/controllers/charts/crops_controller.rb +++ b/app/controllers/charts/crops_controller.rb @@ -11,7 +11,7 @@ module Charts end def harvested_for - @crop = Crop.find(params[:crop_id]) + @crop = Crop.find(params[:crop_slug]) render json: Harvest.joins(:plant_part) .where(crop: @crop) .group("plant_parts.name").count(:id) @@ -20,7 +20,7 @@ module Charts private def pie_chart_query(field) - @crop = Crop.find(params[:crop_id]) + @crop = Crop.find(params[:crop_slug]) render json: Planting.where(crop: @crop) .where.not(field.to_sym => nil) .where.not(field.to_sym => '') diff --git a/app/views/crops/show.html.haml b/app/views/crops/show.html.haml index 0b51e87f7..628ebd118 100644 --- a/app/views/crops/show.html.haml +++ b/app/views/crops/show.html.haml @@ -44,14 +44,14 @@ .row .col-md-3 %h2 Sunniness - = pie_chart crop_sunniness_path(@crop), legend: "bottom" + = pie_chart crop_sunniness_path(@crop, format: :json), legend: "bottom" .col-md-3 %h2 Planted from - = pie_chart crop_planted_from_path(@crop), legend: "bottom" + = pie_chart crop_planted_from_path(@crop, format: :json), legend: "bottom" .col-md-3 %h2 Harvested for - = pie_chart crop_harvested_for_path(@crop), legend: "bottom" + = pie_chart crop_harvested_for_path(@crop, format: :json), legend: "bottom" .row .col-md-12 From a219cc4f67a2c3cdb7268b800f0b8a6c2af33d13 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Thu, 3 Jan 2019 15:35:36 +1300 Subject: [PATCH 025/207] Update harvests controller spec for new routes --- spec/controllers/harvests_controller_spec.rb | 56 ++++++++++---------- 1 file changed, 27 insertions(+), 29 deletions(-) diff --git a/spec/controllers/harvests_controller_spec.rb b/spec/controllers/harvests_controller_spec.rb index aad371da5..b7259293e 100644 --- a/spec/controllers/harvests_controller_spec.rb +++ b/spec/controllers/harvests_controller_spec.rb @@ -13,26 +13,26 @@ describe HarvestsController do end describe "GET index" do - let(:member1) { FactoryBot.create(:member) } + let!(:member1) { FactoryBot.create(:member) } let(:member2) { FactoryBot.create(:member) } let(:tomato) { FactoryBot.create(:tomato) } let(:maize) { FactoryBot.create(:maize) } - let(:harvest1) { FactoryBot.create(:harvest, owner_id: member1.id, crop_id: tomato.id) } - let(:harvest2) { FactoryBot.create(:harvest, owner_id: member2.id, crop_id: maize.id) } + let!(:harvest1) { FactoryBot.create(:harvest, owner_id: member1.id, crop_id: tomato.id) } + let!(:harvest2) { FactoryBot.create(:harvest, owner_id: member2.id, crop_id: maize.id) } describe "assigns all harvests as @harvests" do before { get :index, params: {} } - it { assigns(:harvests).should =~ [harvest1, harvest2] } + it { expect(assigns(:harvests)).to eq [harvest1, harvest2] } end describe "picks up owner from params and shows owner's harvests only" do - before { get :index, params: { owner: member1.slug } } + before { get :index, params: { member_slug: member1.slug } } it { expect(assigns(:owner)).to eq member1 } it { expect(assigns(:harvests)).to eq [harvest1] } end describe "picks up crop from params and shows the harvests for the crop only" do - before { get :index, params: { crop: maize.name } } + before { get :index, params: { crop_slug: maize.name } } it { expect(assigns(:crop)).to eq maize } it { expect(assigns(:harvests)).to eq [harvest2] } end @@ -82,15 +82,15 @@ describe HarvestsController do end.to change(Harvest, :count).by(1) end - it "assigns a newly created harvest as @harvest" do - post :create, params: { harvest: valid_attributes } - assigns(:harvest).should be_a(Harvest) - assigns(:harvest).should be_persisted + describe "assigns a newly created harvest as @harvest" do + before { post :create, params: { harvest: valid_attributes } } + it { expect(assigns(:harvest)).to be_a(Harvest) } + it { expect(assigns(:harvest)).to be_persisted } end - it "redirects to the created harvest" do - post :create, params: { harvest: valid_attributes } - response.should redirect_to(Harvest.last) + describe "redirects to the created harvest" do + before { post :create, params: { harvest: valid_attributes } } + it { expect(response).to redirect_to(Harvest.last) } end describe "links to planting" do @@ -105,13 +105,13 @@ describe HarvestsController do # Trigger the behavior that occurs when invalid params are submitted Harvest.any_instance.stub(:save).and_return(false) post :create, params: { harvest: { "crop_id" => "invalid value" } } - assigns(:harvest).should be_a_new(Harvest) + expect(assigns(:harvest)).to be_a_new(Harvest) end - it "re-renders the 'new' template" do + describe "re-renders the 'new' template" do # Trigger the behavior that occurs when invalid params are submitted - post :create, params: { harvest: { "crop_id" => "invalid value" } } - response.should render_template("new") + before { post :create, params: { harvest: { "crop_id" => "invalid value" } } } + it { expect(response).to render_template("new") } end end @@ -132,8 +132,8 @@ describe HarvestsController do describe "PUT update" do describe "with valid params" do + let(:harvest) { Harvest.create! valid_attributes } it "updates the requested harvest" do - harvest = FactoryBot.create :harvest, valid_attributes new_crop = FactoryBot.create :crop expect do put :update, params: { id: harvest.to_param, harvest: { crop_id: new_crop.id } } @@ -141,16 +141,14 @@ describe HarvestsController do end.to change(harvest, :crop_id).to(new_crop.id) end - it "assigns the requested harvest as @harvest" do - harvest = Harvest.create! valid_attributes - put :update, params: { id: harvest.to_param, harvest: valid_attributes } - assigns(:harvest).should eq(harvest) + describe "assigns the requested harvest as @harvest" do + before { put :update, params: { id: harvest.to_param, harvest: valid_attributes } } + it { expect(assigns(:harvest)).to eq(harvest) } end - it "redirects to the harvest" do - harvest = Harvest.create! valid_attributes - put :update, params: { id: harvest.to_param, harvest: valid_attributes } - response.should redirect_to(harvest) + describe "redirects to the harvest" do + before { put :update, params: { id: harvest.to_param, harvest: valid_attributes } } + it { expect(response).to redirect_to(harvest) } end end @@ -160,13 +158,13 @@ describe HarvestsController do # Trigger the behavior that occurs when invalid params are submitted Harvest.any_instance.stub(:save).and_return(false) put :update, params: { id: harvest.to_param, harvest: { "crop_id" => "invalid value" } } - assigns(:harvest).should eq(harvest) + expect(assigns(:harvest)).to eq(harvest) end it "re-renders the 'edit' template" do harvest = Harvest.create! valid_attributes put :update, params: { id: harvest.to_param, harvest: { "crop_id" => "invalid value" } } - response.should render_template("edit") + expect(response).to render_template("edit") end end @@ -196,7 +194,7 @@ describe HarvestsController do it "redirects to the harvests list" do harvest = Harvest.create! valid_attributes delete :destroy, params: { id: harvest.to_param } - response.should redirect_to(harvests_url) + expect(response).to redirect_to(harvests_url) end end end From b92c2f9bae418dcb2b4bab7ec5ce0f77bded271e Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Thu, 3 Jan 2019 15:40:26 +1300 Subject: [PATCH 026/207] Use slugs for look up in spec --- spec/controllers/plantings_controller_spec.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spec/controllers/plantings_controller_spec.rb b/spec/controllers/plantings_controller_spec.rb index e2c6522be..c4a60d1a4 100644 --- a/spec/controllers/plantings_controller_spec.rb +++ b/spec/controllers/plantings_controller_spec.rb @@ -25,13 +25,13 @@ describe PlantingsController do end describe "picks up owner from params and shows owner's plantings only" do - before { get :index, params: { owner: member1.slug } } + before { get :index, params: { member_slug: member1.slug } } it { expect(assigns(:owner)).to eq member1 } it { expect(assigns(:plantings)).to eq [planting1] } end describe "picks up crop from params and shows the plantings for the crop only" do - before { get :index, params: { crop: maize.name } } + before { get :index, params: { crop_slug: maize.slug } } it { expect(assigns(:crop)).to eq maize } it { expect(assigns(:plantings)).to eq [planting2] } end From 0b116410033221c1d4c5a0802c1a7cd1e418f951 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Thu, 3 Jan 2019 15:53:27 +1300 Subject: [PATCH 027/207] Update params in charts/crops controller specs --- spec/controllers/charts/crops_controller_spec.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/spec/controllers/charts/crops_controller_spec.rb b/spec/controllers/charts/crops_controller_spec.rb index f487d4d37..962b57891 100644 --- a/spec/controllers/charts/crops_controller_spec.rb +++ b/spec/controllers/charts/crops_controller_spec.rb @@ -4,15 +4,15 @@ describe Charts::CropsController do describe 'GET charts' do let(:crop) { FactoryBot.create :crop } describe 'sunniness' do - before { get :sunniness, params: { crop_id: crop.to_param } } + before { get :sunniness, params: { crop_slug: crop.to_param } } it { expect(response).to be_success } end describe 'planted_from' do - before { get :planted_from, params: { crop_id: crop.to_param } } + before { get :planted_from, params: { crop_slug: crop.to_param } } it { expect(response).to be_success } end describe 'harvested_for' do - before { get :harvested_for, params: { crop_id: crop.to_param } } + before { get :harvested_for, params: { crop_slug: crop.to_param } } it { expect(response).to be_success } end end From bbb403be49a2dad49932095b1d51f1f85e33f59d Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Thu, 3 Jan 2019 16:20:21 +1300 Subject: [PATCH 028/207] Use slug to find a member --- spec/controllers/member_controller_spec.rb | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/spec/controllers/member_controller_spec.rb b/spec/controllers/member_controller_spec.rb index 783f4d433..34ef19c34 100644 --- a/spec/controllers/member_controller_spec.rb +++ b/spec/controllers/member_controller_spec.rb @@ -24,43 +24,43 @@ describe MembersController do describe "GET show" do it "provides JSON for member profile" do - get :show, params: { login_name: @member.to_param }, format: 'json' + get :show, params: { slug: @member.to_param }, format: 'json' response.should be_success end it "assigns @posts with the member's posts" do - get :show, params: { login_name: @member.to_param } + get :show, params: { slug: @member.to_param } assigns(:posts).should eq(@posts) end it "assigns @twitter_auth" do - get :show, params: { login_name: @member.to_param } + get :show, params: { slug: @member.to_param } assigns(:twitter_auth).should eq(@twitter_auth) end it "assigns @flickr_auth" do - get :show, params: { login_name: @member.to_param } + get :show, params: { slug: @member.to_param } assigns(:flickr_auth).should eq(@flickr_auth) end it "doesn't show completely nonsense members" do - get :show, params: { login_name: 9999 } + get :show, params: { slug: 9999 } expect(response).to have_http_status(:not_found) end it "doesn't show unconfirmed members" do @member2 = FactoryBot.create(:unconfirmed_member) - get :show, params: { login_name: @member2.id } + get :show, params: { slug: @member2.id } expect(response).to have_http_status(:not_found) end end describe "GET member's RSS feed" do - it "returns an RSS feed" do - get :show, params: { login_name: @member.to_param }, format: "rss" - response.should be_success - response.should render_template("members/show") - response.content_type.should eq("application/rss+xml") + describe "returns an RSS feed" do + before { get :show, params: { slug: @member.to_param }, format: "rss" } + it { response.should be_success } + it { response.should render_template("members/show") } + it { response.content_type.should eq("application/rss+xml") } end end end From 9760c02b7744ec58ab846ec0b2ec04fc5c5d20c3 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Thu, 3 Jan 2019 16:20:34 +1300 Subject: [PATCH 029/207] User owner's slug to filter seeds --- spec/controllers/seeds_controller_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/controllers/seeds_controller_spec.rb b/spec/controllers/seeds_controller_spec.rb index 0a5fe45b4..3c90841d1 100644 --- a/spec/controllers/seeds_controller_spec.rb +++ b/spec/controllers/seeds_controller_spec.rb @@ -6,7 +6,7 @@ describe SeedsController do describe "GET index" do let(:owner) { FactoryBot.create(:member) } describe "picks up owner from params" do - before { get :index, params: { owner: owner.slug } } + before { get :index, params: { member_slug: owner.slug } } it { expect(assigns(:owner)).to eq(owner) } end end From 59bc036565c77b7517e00522dbb3d07cdd8657b4 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Thu, 3 Jan 2019 16:41:04 +1300 Subject: [PATCH 030/207] Follow/Unfollow updated for routes --- app/controllers/follows_controller.rb | 12 ++++++------ app/views/members/show.html.haml | 4 ++-- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/app/controllers/follows_controller.rb b/app/controllers/follows_controller.rb index 04853bb20..98bd367d5 100644 --- a/app/controllers/follows_controller.rb +++ b/app/controllers/follows_controller.rb @@ -5,7 +5,7 @@ class FollowsController < ApplicationController # POST /follows def create - @follow = current_member.follows.build(followed_id: follow_params[:followed_id]) + @follow = current_member.follows.build(followed: Member.find(params[:followed])) if @follow.save flash[:notice] = "Followed #{@follow.followed.login_name}" @@ -17,17 +17,17 @@ class FollowsController < ApplicationController # DELETE /follows/1 def destroy - @follow = current_member.follows.find(follow_params[:id]) - unfollowed_name = @follow.followed.login_name + @follow = current_member.follows.find(params[:id]) + @unfollowed = @follow.followed @follow.destroy - flash[:notice] = "Unfollowed #{unfollowed_name}" - redirect_to root_path + flash[:notice] = "Unfollowed #{@unfollowed.login_name}" + redirect_to @unfollowed end private def follow_params - params.permit(:id, :followed_id, :follower_id, :authenticity_token, :_method) + params.permit(:id, :followed, :follower) end end diff --git a/app/views/members/show.html.haml b/app/views/members/show.html.haml index 621f35c51..cbf519ca7 100644 --- a/app/views/members/show.html.haml +++ b/app/views/members/show.html.haml @@ -11,12 +11,12 @@ - if can? :update, @member = link_to 'Edit profile', edit_member_registration_path, class: 'btn btn-default pull-right' - if can?(:create, Notification) && current_member != @member - = link_to 'Send message', new_notification_path(recipient_id: @member.id), class: 'btn btn-default pull-right' + = link_to 'Send message', new_notification_path(recipient_id: @member.slug), class: 'btn btn-default pull-right' - if current_member && current_member != @member # must be logged in, can't follow yourself - follow = current_member.get_follow(@member) - if !follow && can?(:create, Follow) # not already following - = link_to 'Follow', follows_path(followed_id: @member.id), method: :post, class: 'btn btn-default pull-right' + = link_to 'Follow', follows_path(followed: @member), method: :post, class: 'btn btn-default pull-right' - if follow && can?(:destroy, follow) # already following = link_to 'Unfollow', follow_path(follow), method: :delete, class: 'btn btn-default pull-right' From b44b7fdd2e821eac6573d0e1476d6f9fd8cb279a Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Thu, 3 Jan 2019 20:25:03 +1300 Subject: [PATCH 031/207] Move follows from members controller to follows controller --- app/controllers/follows_controller.rb | 15 ++++++++++-- app/controllers/members_controller.rb | 10 -------- .../followers.html.haml} | 0 .../index.html.haml} | 0 config/routes.rb | 6 ++--- spec/features/following_spec.rb | 23 +++++++------------ 6 files changed, 24 insertions(+), 30 deletions(-) rename app/views/{members/view_followers.html.haml => follows/followers.html.haml} (100%) rename app/views/{members/view_follows.html.haml => follows/index.html.haml} (100%) diff --git a/app/controllers/follows_controller.rb b/app/controllers/follows_controller.rb index 98bd367d5..dafddfc3a 100644 --- a/app/controllers/follows_controller.rb +++ b/app/controllers/follows_controller.rb @@ -1,9 +1,9 @@ class FollowsController < ApplicationController before_action :authenticate_member! + before_action :set_member, only: [:index, :followers] load_and_authorize_resource skip_load_resource only: :create - # POST /follows def create @follow = current_member.follows.build(followed: Member.find(params[:followed])) @@ -15,7 +15,6 @@ class FollowsController < ApplicationController redirect_back fallback_location: root_path end - # DELETE /follows/1 def destroy @follow = current_member.follows.find(params[:id]) @unfollowed = @follow.followed @@ -25,8 +24,20 @@ class FollowsController < ApplicationController redirect_to @unfollowed end + def index + @follows = @member.followed.paginate(page: params[:page]) + end + + def followers + @followers = @member.followers.paginate(page: params[:page]) + end + private + def set_member + @member = Member.confirmed.find(params[:member_slug]) + end + def follow_params params.permit(:id, :followed, :follower) end diff --git a/app/controllers/members_controller.rb b/app/controllers/members_controller.rb index 80aac26c5..d2a4b74c1 100644 --- a/app/controllers/members_controller.rb +++ b/app/controllers/members_controller.rb @@ -38,16 +38,6 @@ class MembersController < ApplicationController end end - def view_follows - @member = Member.confirmed.find(params[:owner]) - @follows = @member.followed.paginate(page: params[:page]) - end - - def view_followers - @member = Member.confirmed.find(params[:owner]) - @followers = @member.followers.paginate(page: params[:page]) - end - EMAIL_TYPE_STRING = { send_notification_email: "direct message notifications", send_planting_reminder: "planting reminders" diff --git a/app/views/members/view_followers.html.haml b/app/views/follows/followers.html.haml similarity index 100% rename from app/views/members/view_followers.html.haml rename to app/views/follows/followers.html.haml diff --git a/app/views/members/view_follows.html.haml b/app/views/follows/index.html.haml similarity index 100% rename from app/views/members/view_follows.html.haml rename to app/views/follows/index.html.haml diff --git a/config/routes.rb b/config/routes.rb index 2324bc4ff..f58e11d4b 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -83,14 +83,14 @@ Rails.application.routes.draw do resources :likes, only: %i(create destroy) resources :members, param: :slug do - get 'follows' => 'members#view_follows' - get 'followers' => 'members#view_followers' - resources :gardens resources :seeds resources :plantings resources :harvests resources :posts + + resources :follows + get 'followers' => 'follows#followers' end resources :notifications do diff --git a/spec/features/following_spec.rb b/spec/features/following_spec.rb index 735883e77..40e45f5de 100644 --- a/spec/features/following_spec.rb +++ b/spec/features/following_spec.rb @@ -26,12 +26,10 @@ feature "follows", :js do end context "following another member" do - background do - visit member_path(other_member) - end + background { visit member_path(other_member)} scenario "has a follow button" do - expect(page).to have_link "Follow", href: follows_path(followed_id: other_member.id) + expect(page).to have_link "Follow", href: follows_path(followed: other_member.slug) end scenario "has correct message and unfollow button" do @@ -43,12 +41,7 @@ feature "follows", :js do scenario "has a followed member listed in the following page" do click_link 'Follow' visit member_follows_path(member) - expect(page).to have_content other_member.login_name.to_s - end - - scenario "does not die when passed an authenticity_token" do - visit member_follows_path member, params: { authenticity_token: "Ultima ratio regum" } - expect(page.status_code).to equal 200 + expect(page).to have_content other_member.login_name end scenario "has correct message and follow button after unfollow" do @@ -56,28 +49,28 @@ feature "follows", :js do click_link 'Unfollow' expect(page).to have_content "Unfollowed #{other_member.login_name}" visit member_path(other_member) # unfollowing redirects to root - expect(page).to have_link "Follow", href: follows_path(followed_id: other_member.id) + expect(page).to have_link "Follow", href: follows_path(followed: other_member.slug) end scenario "has member in following list" do click_link 'Follow' visit member_follows_path(member) - expect(page).to have_content other_member.login_name.to_s + expect(page).to have_content other_member.login_name end scenario "appears in in followed member's followers list" do click_link 'Follow' visit member_followers_path(other_member) - expect(page).to have_content member.login_name.to_s + expect(page).to have_content member.login_name end scenario "removes members from following and followers lists after unfollow" do click_link 'Follow' click_link 'Unfollow' visit member_follows_path(member) - expect(page).not_to have_content other_member.login_name.to_s + expect(page).not_to have_content other_member.login_name visit member_followers_path(other_member) - expect(page).to have_content member.login_name.to_s + expect(page).to have_content member.login_name end end end From dcbfc4f9fac794f4a359d884ee06be0a8bec5c33 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Thu, 3 Jan 2019 20:41:47 +1300 Subject: [PATCH 032/207] Fixed spec to look for new DRY header template in gardens --- spec/features/gardens_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/features/gardens_spec.rb b/spec/features/gardens_spec.rb index 368389719..353f48d6c 100644 --- a/spec/features/gardens_spec.rb +++ b/spec/features/gardens_spec.rb @@ -14,7 +14,7 @@ feature "Planting a crop", js: true do scenario "View gardens" do visit gardens_path expect(page).to have_content "Everyone's gardens" - click_link "My Gardens" + click_link "My gardens" expect(page).to have_content "#{garden.owner.login_name}'s gardens" click_link "Everyone's gardens" expect(page).to have_content "Everyone's gardens" From 686b7f27d0b80b3d741f00ce79ec54a5ab00315c Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Thu, 3 Jan 2019 22:20:07 +1300 Subject: [PATCH 033/207] Fixed paths in gardens feature spec --- spec/features/gardens/actions_spec.rb | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/spec/features/gardens/actions_spec.rb b/spec/features/gardens/actions_spec.rb index a22ab6886..05dd960df 100644 --- a/spec/features/gardens/actions_spec.rb +++ b/spec/features/gardens/actions_spec.rb @@ -15,14 +15,14 @@ feature "Gardens" do it "has buttons bar at top" do within '.layout-actions' do is_expected.to have_link 'Add a garden' - is_expected.to have_link 'My Gardens' + is_expected.to have_link 'My gardens' is_expected.to have_link "Everyone's gardens" end end end context 'my gardens' do - before { visit gardens_path(owner: member) } + before { visit gardens_path(member_slug: member.slug) } include_examples "has buttons bar at top" it "has actions on garden" do @@ -43,12 +43,12 @@ feature "Gardens" do end context "other member's garden" do - before { visit gardens_path(owner: FactoryBot.create(:member)) } + before { visit gardens_path(member_slug: FactoryBot.create(:member).slug) } include_examples "has buttons bar at top" - it 'does not show actions on other member garden' do - is_expected.not_to have_link 'Plant something' - is_expected.not_to have_link 'Mark as inactive' + describe 'does not show actions on other member garden' do + it { is_expected.not_to have_link 'Plant something' } + it { is_expected.not_to have_link 'Mark as inactive' } end end end From 71ac88789d2ce1a433722e6c5feded07615534d7 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Thu, 3 Jan 2019 22:37:59 +1300 Subject: [PATCH 034/207] notification stays as member id --- app/views/members/show.html.haml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/members/show.html.haml b/app/views/members/show.html.haml index cbf519ca7..ae751d632 100644 --- a/app/views/members/show.html.haml +++ b/app/views/members/show.html.haml @@ -11,7 +11,7 @@ - if can? :update, @member = link_to 'Edit profile', edit_member_registration_path, class: 'btn btn-default pull-right' - if can?(:create, Notification) && current_member != @member - = link_to 'Send message', new_notification_path(recipient_id: @member.slug), class: 'btn btn-default pull-right' + = link_to 'Send message', new_notification_path(recipient_id: @member.id), class: 'btn btn-default pull-right' - if current_member && current_member != @member # must be logged in, can't follow yourself - follow = current_member.get_follow(@member) From 1381b619be79dc25dda57ed2e46173b7ef5e5429 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Thu, 3 Jan 2019 22:38:11 +1300 Subject: [PATCH 035/207] on collection, routes for notification --- config/routes.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/routes.rb b/config/routes.rb index f58e11d4b..56c538434 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -94,7 +94,7 @@ Rails.application.routes.draw do end resources :notifications do - get 'reply', on: :member + get 'reply', on: :collection end resources :places, only: [:index, :show] do From e8d2226ac6b59a0fdabecf0a72755b0f973d7bf4 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Fri, 4 Jan 2019 10:00:56 +1300 Subject: [PATCH 036/207] Look up crop by slug --- app/controllers/crops_controller.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/controllers/crops_controller.rb b/app/controllers/crops_controller.rb index ab0dc361a..e5d36302d 100644 --- a/app/controllers/crops_controller.rb +++ b/app/controllers/crops_controller.rb @@ -67,6 +67,7 @@ class CropsController < ApplicationController end def edit + @crop = Crop.find_by(slug: params[:slug]) @crop.alternate_names.build if @crop.alternate_names.blank? @crop.scientific_names.build if @crop.scientific_names.blank? end @@ -87,6 +88,7 @@ class CropsController < ApplicationController end def update + @crop = Crop.find_by(slug: params[:slug]) previous_status = @crop.approval_status @crop.creator = current_member if previous_status == "pending" From f008270ba2fd6b4030f69c2f0d1c55d1a9042f6a Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Fri, 4 Jan 2019 11:02:45 +1300 Subject: [PATCH 037/207] Update spec for finding your own seeds --- app/views/crops/show.html.haml | 6 ++---- spec/features/crops/crop_detail_page_spec.rb | 11 ++++------- 2 files changed, 6 insertions(+), 11 deletions(-) diff --git a/app/views/crops/show.html.haml b/app/views/crops/show.html.haml index 628ebd118..2a9835823 100644 --- a/app/views/crops/show.html.haml +++ b/app/views/crops/show.html.haml @@ -31,7 +31,6 @@ - else Nobody is growing this yet. You could be the first! - .row .col-md-12 %h2 Predictions @@ -45,7 +44,6 @@ .col-md-3 %h2 Sunniness = pie_chart crop_sunniness_path(@crop, format: :json), legend: "bottom" - .col-md-3 %h2 Planted from = pie_chart crop_planted_from_path(@crop, format: :json), legend: "bottom" @@ -102,8 +100,8 @@ = link_to crop_harvests_path(@crop) do View all #{@crop.name} harvests (#{@crop.harvests.size}) - %p - - if member_signed_in? + - if member_signed_in? + %p = link_to member_seeds_path(current_member, crop_slug: @crop.slug) do = display_seed_availability(@current_member, @crop) diff --git a/spec/features/crops/crop_detail_page_spec.rb b/spec/features/crops/crop_detail_page_spec.rb index 712c0feaf..04da3d7e9 100644 --- a/spec/features/crops/crop_detail_page_spec.rb +++ b/spec/features/crops/crop_detail_page_spec.rb @@ -157,23 +157,20 @@ feature "crop detail page", js: true do scenario "User not signed in" do visit crop_path(seed.crop) - expect(page).not_to have_content "You have 20 seeds of this crop" - expect(page).not_to have_content "You don't have any seeds of this crop" - expect(page).not_to have_link "View your seeds" + expect(page).not_to have_content "You have 20 seeds" end scenario "User signed in" do login_as(member) visit crop_path(seed.crop) - expect(page).to have_content "You have 20 seeds of this crop." - expect(page).to have_link "View your seeds" + expect(page).to have_link "You have 20 seeds of this crop." end scenario "click link to your owned seeds" do login_as(member) visit crop_path(seed.crop) - click_link "View your seeds" - expect(current_path).to eq member_seeds_path(owner: member.slug) + click_link "You have 20 seeds of this crop." + expect(current_path).to eq member_seeds_path(member_slug: member.slug) end end From 453bc0c6b405addf5bdc0a7e17af2aeac81fd6e0 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Fri, 4 Jan 2019 13:39:20 +1300 Subject: [PATCH 038/207] Update crop route specs --- spec/routing/crops_routing_spec.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/spec/routing/crops_routing_spec.rb b/spec/routing/crops_routing_spec.rb index 97c1a874c..2d135b5ea 100644 --- a/spec/routing/crops_routing_spec.rb +++ b/spec/routing/crops_routing_spec.rb @@ -11,11 +11,11 @@ describe CropsController do end it "routes to #show" do - get("/crops/1").should route_to("crops#show", id: "1") + get("/crops/lettuce").should route_to("crops#show", slug: 'lettuce') end it "routes to #edit" do - get("/crops/1/edit").should route_to("crops#edit", id: "1") + get("/crops/lettuce/edit").should route_to("crops#edit", slug: "lettuce") end it "routes to #create" do @@ -23,11 +23,11 @@ describe CropsController do end it "routes to #update" do - put("/crops/1").should route_to("crops#update", id: "1") + put("/crops/lettuce").should route_to("crops#update", slug: "lettuce") end it "routes to #destroy" do - delete("/crops/1").should route_to("crops#destroy", id: "1") + delete("/crops/lettuce").should route_to("crops#destroy", slug: "lettuce") end end end From 8b179ca2de8708cf334a1456182d2928f7102246 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Fri, 4 Jan 2019 13:40:54 +1300 Subject: [PATCH 039/207] Add new routes to spec --- spec/routing/crops_routing_spec.rb | 4 ++++ spec/routing/gardens_routing_spec.rb | 1 + spec/routing/harvests_routing_spec.rb | 1 + spec/routing/plantings_routing_spec.rb | 1 + spec/routing/seeds_routing_spec.rb | 1 + 5 files changed, 8 insertions(+) diff --git a/spec/routing/crops_routing_spec.rb b/spec/routing/crops_routing_spec.rb index 2d135b5ea..30f6004d3 100644 --- a/spec/routing/crops_routing_spec.rb +++ b/spec/routing/crops_routing_spec.rb @@ -14,6 +14,10 @@ describe CropsController do get("/crops/lettuce").should route_to("crops#show", slug: 'lettuce') end + it { get("/crops/lettuce/plantings").should route_to("plantings#index", crop_slug: 'lettuce') } + it { get("/crops/lettuce/harvests").should route_to("harvests#index", crop_slug: 'lettuce') } + it { get("/crops/lettuce/seeds").should route_to("seeds#index", crop_slug: 'lettuce') } + it "routes to #edit" do get("/crops/lettuce/edit").should route_to("crops#edit", slug: "lettuce") end diff --git a/spec/routing/gardens_routing_spec.rb b/spec/routing/gardens_routing_spec.rb index 6888f099f..02183eab0 100644 --- a/spec/routing/gardens_routing_spec.rb +++ b/spec/routing/gardens_routing_spec.rb @@ -4,6 +4,7 @@ describe GardensController do describe "routing" do it "routes to #index" do get("/gardens").should route_to("gardens#index") + get("/members/fred/gardens").should route_to("gardens#index", member_slug: 'fred') end it "routes to #new" do diff --git a/spec/routing/harvests_routing_spec.rb b/spec/routing/harvests_routing_spec.rb index c6890df15..af623c3fe 100644 --- a/spec/routing/harvests_routing_spec.rb +++ b/spec/routing/harvests_routing_spec.rb @@ -4,6 +4,7 @@ describe HarvestsController do describe "routing" do it "routes to #index" do get("/harvests").should route_to("harvests#index") + get("/members/fred/harvests").should route_to("harvests#index", member_slug: 'fred') end it "routes to #new" do diff --git a/spec/routing/plantings_routing_spec.rb b/spec/routing/plantings_routing_spec.rb index 473fe827e..d92d3a84f 100644 --- a/spec/routing/plantings_routing_spec.rb +++ b/spec/routing/plantings_routing_spec.rb @@ -4,6 +4,7 @@ describe PlantingsController do describe "routing" do it "routes to #index" do get("/plantings").should route_to("plantings#index") + get("/members/fred/plantings").should route_to("plantings#index", member_slug: 'fred') end it "routes to #new" do diff --git a/spec/routing/seeds_routing_spec.rb b/spec/routing/seeds_routing_spec.rb index 74f4aff64..9ebfbdb02 100644 --- a/spec/routing/seeds_routing_spec.rb +++ b/spec/routing/seeds_routing_spec.rb @@ -4,6 +4,7 @@ describe SeedsController do describe "routing" do it "routes to #index" do get("/seeds").should route_to("seeds#index") + get("/members/fred/seeds").should route_to("seeds#index", member_slug: 'fred') end it "routes to #new" do From 5528d9b5e917ba9beee4c88dd1d9158092fc799d Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Fri, 4 Jan 2019 14:03:37 +1300 Subject: [PATCH 040/207] Fix authors rss of posts link --- app/views/posts/index.html.haml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/posts/index.html.haml b/app/views/posts/index.html.haml index 47070db81..aa11d529b 100644 --- a/app/views/posts/index.html.haml +++ b/app/views/posts/index.html.haml @@ -30,7 +30,7 @@ - if @author Subscribe to = succeed "." do - = link_to "#{@author}'s posts RSS feed", member_posts_path(format: 'rss', author: @author) + = link_to "#{@author}'s posts RSS feed", member_posts_path(@author, format: 'rss') - else Subscribe to the #{ENV['GROWSTUFF_SITE_NAME']} From f638b9a5da7ed6bd955a4c34d584aeb6a242d4bc Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Fri, 4 Jan 2019 14:12:17 +1300 Subject: [PATCH 041/207] Update path to member gardens in spec --- .gitignore | 3 ++- spec/features/gardens/gardens_index_spec.rb | 8 ++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/.gitignore b/.gitignore index b09a40bc6..3e0822111 100644 --- a/.gitignore +++ b/.gitignore @@ -16,4 +16,5 @@ zeus.json .bundle .idea/** public/** -node_modules \ No newline at end of file +node_modules +/.byebug_history diff --git a/spec/features/gardens/gardens_index_spec.rb b/spec/features/gardens/gardens_index_spec.rb index ebe5f5547..fa047d8d8 100644 --- a/spec/features/gardens/gardens_index_spec.rb +++ b/spec/features/gardens/gardens_index_spec.rb @@ -10,7 +10,7 @@ feature "Gardens#index", :js do context "with 10 gardens" do before do FactoryBot.create_list :garden, 10, owner: member - visit gardens_path(owner: member.login_name) + visit member_gardens_path(member_slug: member.slug) end it "displays each of the gardens" do @@ -29,7 +29,7 @@ feature "Gardens#index", :js do let!(:active_garden) { FactoryBot.create :garden, name: "My active garden", owner: member } let!(:inactive_garden) { FactoryBot.create :inactive_garden, name: "retired garden", owner: member } - before { visit gardens_path(member: member) } + before { visit member_gardens_path(member_slug: member.slug) } it "show active garden" do expect(page).to have_text active_garden.name @@ -57,7 +57,7 @@ feature "Gardens#index", :js do end before do - visit gardens_path(member: member) + visit member_gardens_path(member_slug: member.slug) end it "shows planting in garden" do @@ -90,7 +90,7 @@ feature "Gardens#index", :js do garden.update! name: 'super awesome garden' assert planting - visit gardens_path(owner: member.login_name) + visit member_gardens_path(member_slug: member.slug) end describe 'harvest still growing' do From f8921d3dedc4f1246c663163d80a2bbcc51ca1cf Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Fri, 4 Jan 2019 14:14:14 +1300 Subject: [PATCH 042/207] Update reply notifications --- app/helpers/notifications_helper.rb | 2 +- spec/helpers/notifications_helper_spec.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/helpers/notifications_helper.rb b/app/helpers/notifications_helper.rb index bb3695851..36160f79b 100644 --- a/app/helpers/notifications_helper.rb +++ b/app/helpers/notifications_helper.rb @@ -5,7 +5,7 @@ module NotificationsHelper new_comment_url(post_id: notification.post.id) else # by default, reply link sends a PM in return - reply_notification_url(notification) + reply_notifications_url(notification) end end end diff --git a/spec/helpers/notifications_helper_spec.rb b/spec/helpers/notifications_helper_spec.rb index a00dabff3..39e212980 100644 --- a/spec/helpers/notifications_helper_spec.rb +++ b/spec/helpers/notifications_helper_spec.rb @@ -8,7 +8,7 @@ describe NotificationsHelper do notification = FactoryBot.create(:notification, recipient_id: member.id, post_id: nil) link = helper.reply_link(notification) link.should_not be_nil - link.should eq reply_notification_url(notification) + link.should eq reply_notifications_url(notification) end it "replies to post comments with post comments" do From bf6dd049ae83d053fc220d0b82add6bfee6552db Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Fri, 4 Jan 2019 14:25:57 +1300 Subject: [PATCH 043/207] Fixed up admin routes --- config/routes.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/config/routes.rb b/config/routes.rb index 56c538434..5c7ea4b15 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -104,10 +104,10 @@ Rails.application.routes.draw do get 'auth/:provider/callback' => 'authentications#create' get 'members/auth/:provider/callback' => 'authentications#create' - namespace :admin do - resources :members - get '/' => 'admin#index' - get 'newsletter', as: :newsletter + scope :admin do + resources :members, as: 'admin_members' + get '/' => 'admin#index', as: 'admin' + get '/newsletter' => 'admin#newsletter', as: 'admin_newsletter' get ':action' => 'admin#:action' end From 74e30aeb1d7c22e659c9a04abb91775a956f85ce Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Fri, 4 Jan 2019 14:28:33 +1300 Subject: [PATCH 044/207] move cms into admin scope --- config/routes.rb | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/config/routes.rb b/config/routes.rb index 5c7ea4b15..ae7f66311 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -108,7 +108,7 @@ Rails.application.routes.draw do resources :members, as: 'admin_members' get '/' => 'admin#index', as: 'admin' get '/newsletter' => 'admin#newsletter', as: 'admin_newsletter' - get ':action' => 'admin#:action' + comfy_route :cms_admin, path: '/cms' end namespace :api do @@ -125,6 +125,5 @@ Rails.application.routes.draw do get '/.well-known/acme-challenge/:id' => 'pages#letsencrypt' # CMS stuff -- must remain LAST - comfy_route :cms_admin, path: '/admin/cms' comfy_route :cms, path: '/', sitemap: false end From c2bcae47d2a4bff500fb7523de85eba6ba9c6e30 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Fri, 4 Jan 2019 14:31:55 +1300 Subject: [PATCH 045/207] Use the admin/members controller --- config/routes.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/config/routes.rb b/config/routes.rb index ae7f66311..2c87ec712 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -104,8 +104,9 @@ Rails.application.routes.draw do get 'auth/:provider/callback' => 'authentications#create' get 'members/auth/:provider/callback' => 'authentications#create' + scope :admin do - resources :members, as: 'admin_members' + resources :members, controller: 'admin/members', as: 'admin_members' get '/' => 'admin#index', as: 'admin' get '/newsletter' => 'admin#newsletter', as: 'admin_newsletter' comfy_route :cms_admin, path: '/cms' From 0e0bf98c3722d5cc213038f26b1198653f47f1c9 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Fri, 4 Jan 2019 14:39:23 +1300 Subject: [PATCH 046/207] Specs for admin routing --- spec/routing/admin_routing_spec.rb | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 spec/routing/admin_routing_spec.rb diff --git a/spec/routing/admin_routing_spec.rb b/spec/routing/admin_routing_spec.rb new file mode 100644 index 000000000..66b17bc16 --- /dev/null +++ b/spec/routing/admin_routing_spec.rb @@ -0,0 +1,9 @@ +require "rails_helper" + +describe AdminController do + describe "routing" do + it { expect(get("/admin/")).to route_to("admin#index") } + it { expect(get("/admin/members")).to route_to("admin/members#index") } + it { expect(get("/admin/newsletter")).to route_to("admin#newsletter") } + end +end From 62a8f6b8d3869caa8e60ac0e1a5cf7ab4964dc5c Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Fri, 4 Jan 2019 15:37:14 +1300 Subject: [PATCH 047/207] Fixed look up of reply notification --- app/controllers/notifications_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/notifications_controller.rb b/app/controllers/notifications_controller.rb index 7c3c1f322..d87518c07 100644 --- a/app/controllers/notifications_controller.rb +++ b/app/controllers/notifications_controller.rb @@ -27,7 +27,7 @@ class NotificationsController < ApplicationController # GET /notifications/1/reply def reply @notification = Notification.new - @sender_notification = Notification.find_by(id: params[:id], recipient: current_member) + @sender_notification = Notification.find_by!(id: params[:notification_id], recipient: current_member) @sender_notification.read = true @sender_notification.save @recipient = @sender_notification.sender From 1e6c204df2ecb98cd215d5ddae2f3b2de460117e Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Fri, 4 Jan 2019 15:37:35 +1300 Subject: [PATCH 048/207] Rubcop fix up --- app/controllers/follows_controller.rb | 2 +- app/controllers/gardens_controller.rb | 2 +- app/controllers/harvests_controller.rb | 2 +- app/controllers/plantings_controller.rb | 6 +++--- app/controllers/seeds_controller.rb | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/app/controllers/follows_controller.rb b/app/controllers/follows_controller.rb index dafddfc3a..15546742f 100644 --- a/app/controllers/follows_controller.rb +++ b/app/controllers/follows_controller.rb @@ -1,6 +1,6 @@ class FollowsController < ApplicationController before_action :authenticate_member! - before_action :set_member, only: [:index, :followers] + before_action :set_member, only: %i(index followers) load_and_authorize_resource skip_load_resource only: :create diff --git a/app/controllers/gardens_controller.rb b/app/controllers/gardens_controller.rb index 16095d468..e69fda623 100644 --- a/app/controllers/gardens_controller.rb +++ b/app/controllers/gardens_controller.rb @@ -9,7 +9,7 @@ class GardensController < ApplicationController def index @owner = Member.find_by(slug: params[:member_slug]) @show_all = params[:all] == '1' - + @gardens = @gardens.active unless @show_all @gardens = @gardens.where(owner: @owner) if @owner.present? @gardens = @gardens.joins(:owner).order(:name).paginate(page: params[:page]) diff --git a/app/controllers/harvests_controller.rb b/app/controllers/harvests_controller.rb index 2f252edf2..0192fe403 100644 --- a/app/controllers/harvests_controller.rb +++ b/app/controllers/harvests_controller.rb @@ -15,7 +15,7 @@ class HarvestsController < ApplicationController @harvests = @harvests.where(crop: @crop) if @crop.present? @harvests = @harvests.where(planting: @planting) if @planting.present? @harvests = @harvests.order(harvested_at: :desc).joins(:owner, :crop).paginate(page: params[:page]) - + @filename = csv_filename respond_with(@harvests) diff --git a/app/controllers/plantings_controller.rb b/app/controllers/plantings_controller.rb index ed4edf0e0..f75d95f37 100644 --- a/app/controllers/plantings_controller.rb +++ b/app/controllers/plantings_controller.rb @@ -110,9 +110,9 @@ class PlantingsController < ApplicationController def specifics if @owner - "#{@owner.login_name}-" - elsif @crop - "#{@crop.name}-" + "#{@owner.login_name}-" + elsif @crop + "#{@crop.name}-" end end end diff --git a/app/controllers/seeds_controller.rb b/app/controllers/seeds_controller.rb index ce4e8ac40..f1d34ecf1 100644 --- a/app/controllers/seeds_controller.rb +++ b/app/controllers/seeds_controller.rb @@ -68,7 +68,7 @@ class SeedsController < ApplicationController :finished, :finished_at ) end - + def csv_filename if @owner "Growstuff-#{@owner}-Seeds-#{Time.zone.now.to_s(:number)}.csv" From fb5c631ec912b06ee6d248e35b04434fa56b2232 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Fri, 4 Jan 2019 15:37:41 +1300 Subject: [PATCH 049/207] Fixed notification url in helper --- app/helpers/notifications_helper.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/helpers/notifications_helper.rb b/app/helpers/notifications_helper.rb index 36160f79b..2e551b3cb 100644 --- a/app/helpers/notifications_helper.rb +++ b/app/helpers/notifications_helper.rb @@ -5,7 +5,7 @@ module NotificationsHelper new_comment_url(post_id: notification.post.id) else # by default, reply link sends a PM in return - reply_notifications_url(notification) + notification_reply_url(notification) end end end From 106497c8419b5e52b51d2eea059c3e4c3bc46140 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Fri, 4 Jan 2019 15:37:53 +1300 Subject: [PATCH 050/207] Rubocop fix ups --- app/models/planting.rb | 2 +- config/routes.rb | 7 +++---- spec/features/following_spec.rb | 2 +- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/app/models/planting.rb b/app/models/planting.rb index f6dec4528..95908723b 100644 --- a/app/models/planting.rb +++ b/app/models/planting.rb @@ -33,7 +33,7 @@ class Planting < ApplicationRecord ## ## Scopes default_scope { joins(:owner) } # Ensures the owner still exists - scope :active, -> { where(finished_at: nil)} + scope :active, -> { where(finished_at: nil) } scope :interesting, -> { has_photos.one_per_owner.order(planted_at: :desc) } scope :recent, -> { order(created_at: :desc) } scope :one_per_owner, lambda { diff --git a/config/routes.rb b/config/routes.rb index 2c87ec712..a50d7f361 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -92,19 +92,18 @@ Rails.application.routes.draw do resources :follows get 'followers' => 'follows#followers' end - + resources :notifications do - get 'reply', on: :collection + get 'reply' end - resources :places, only: [:index, :show] do + resources :places, only: %i(index show) do get 'search', on: :collection end get 'auth/:provider/callback' => 'authentications#create' get 'members/auth/:provider/callback' => 'authentications#create' - scope :admin do resources :members, controller: 'admin/members', as: 'admin_members' get '/' => 'admin#index', as: 'admin' diff --git a/spec/features/following_spec.rb b/spec/features/following_spec.rb index 40e45f5de..0be64a4f0 100644 --- a/spec/features/following_spec.rb +++ b/spec/features/following_spec.rb @@ -26,7 +26,7 @@ feature "follows", :js do end context "following another member" do - background { visit member_path(other_member)} + background { visit member_path(other_member) } scenario "has a follow button" do expect(page).to have_link "Follow", href: follows_path(followed: other_member.slug) From 8846627096618d6814f3f2080bc33adbafddacc4 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Fri, 4 Jan 2019 17:21:05 +1300 Subject: [PATCH 051/207] Update notification controller spec to send notification_id --- .../notifications_controller_spec.rb | 19 +------------------ 1 file changed, 1 insertion(+), 18 deletions(-) diff --git a/spec/controllers/notifications_controller_spec.rb b/spec/controllers/notifications_controller_spec.rb index 55ba4b947..c606d9fe9 100644 --- a/spec/controllers/notifications_controller_spec.rb +++ b/spec/controllers/notifications_controller_spec.rb @@ -11,23 +11,6 @@ describe NotificationsController do } end - # this gets a bit confused because for most of the notification tests - # (reading, etc) the logged in member needs to be the recipient. - # However, for sending private messages (create, etc) the logged in - # member needs to be the sender. Hence this separate set of - # attributes. - def valid_attributes_for_sender - { - "sender_id" => subject.current_member.id, - "recipient_id" => FactoryBot.create(:member).id, - "subject" => 'test' - } - end - - def valid_session - {} - end - describe "GET index" do it "assigns all notifications as @notifications" do notification = FactoryBot.create(:notification, recipient_id: subject.current_member.id) @@ -65,7 +48,7 @@ describe NotificationsController do describe "GET reply" do it "marks notifications as read" do notification = FactoryBot.create(:notification, recipient_id: subject.current_member.id) - get :reply, params: { id: notification.to_param } + get :reply, params: { notification_id: notification.to_param } # we need to fetch it from the db again, can't test against the old one n = Notification.find(notification.id) n.read.should eq true From 90386221bcb0c8cb9dda97fdbbb1582a156c0c97 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Fri, 4 Jan 2019 17:50:08 +1300 Subject: [PATCH 052/207] Update notification reply url in helper spec --- spec/helpers/notifications_helper_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/helpers/notifications_helper_spec.rb b/spec/helpers/notifications_helper_spec.rb index 39e212980..68262fb9e 100644 --- a/spec/helpers/notifications_helper_spec.rb +++ b/spec/helpers/notifications_helper_spec.rb @@ -8,7 +8,7 @@ describe NotificationsHelper do notification = FactoryBot.create(:notification, recipient_id: member.id, post_id: nil) link = helper.reply_link(notification) link.should_not be_nil - link.should eq reply_notifications_url(notification) + link.should eq notification_reply_url(notification) end it "replies to post comments with post comments" do From df7a59c629ccea4376690f19c4f1cbdc7f53c857 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Fri, 4 Jan 2019 17:57:33 +1300 Subject: [PATCH 053/207] Use slug in filename, not name/login_name --- app/controllers/plantings_controller.rb | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/app/controllers/plantings_controller.rb b/app/controllers/plantings_controller.rb index f75d95f37..7907a7a73 100644 --- a/app/controllers/plantings_controller.rb +++ b/app/controllers/plantings_controller.rb @@ -109,10 +109,10 @@ class PlantingsController < ApplicationController end def specifics - if @owner - "#{@owner.login_name}-" - elsif @crop - "#{@crop.name}-" - end - end + if @owner.present? + "#{@owner.to_param}-" + elsif @crop.present? + "#{@crop.to_param}-" + end + end end From 061bd312209ddeb2e26471590f63b0d10a3b1b50 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Fri, 4 Jan 2019 17:59:09 +1300 Subject: [PATCH 054/207] Use owner param in filename --- app/controllers/seeds_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/seeds_controller.rb b/app/controllers/seeds_controller.rb index f1d34ecf1..a0cb68b6b 100644 --- a/app/controllers/seeds_controller.rb +++ b/app/controllers/seeds_controller.rb @@ -71,7 +71,7 @@ class SeedsController < ApplicationController def csv_filename if @owner - "Growstuff-#{@owner}-Seeds-#{Time.zone.now.to_s(:number)}.csv" + "Growstuff-#{@owner.to_param}-Seeds-#{Time.zone.now.to_s(:number)}.csv" else "Growstuff-Seeds-#{Time.zone.now.to_s(:number)}.csv" end From 4587dc711f5204d9fcade2f42fdaa54e5edfe4c8 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Fri, 4 Jan 2019 18:00:30 +1300 Subject: [PATCH 055/207] Use to_param to make parts of the csv filename --- app/controllers/harvests_controller.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/controllers/harvests_controller.rb b/app/controllers/harvests_controller.rb index 0192fe403..f1c98fe86 100644 --- a/app/controllers/harvests_controller.rb +++ b/app/controllers/harvests_controller.rb @@ -74,9 +74,9 @@ class HarvestsController < ApplicationController def csv_filename specifics = if @owner - "#{@owner.login_name}-" + "#{@owner.to_param}-" elsif @crop - "#{@crop.name}-" + "#{@crop.to_param}-" end "Growstuff-#{specifics}Harvests-#{Time.zone.now.to_s(:number)}.csv" end From 1660629cf9cf51eb593e3eb4a86b7e1648ab1dd8 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Fri, 4 Jan 2019 18:38:09 +1300 Subject: [PATCH 056/207] DRY crop.interesting? --- app/models/crop.rb | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/app/models/crop.rb b/app/models/crop.rb index c786d5b4d..4d004639c 100644 --- a/app/models/crop.rb +++ b/app/models/crop.rb @@ -156,12 +156,7 @@ class Crop < ApplicationRecord end def interesting? - min_plantings = 3 # needs this many plantings to be interesting - min_photos = 3 # needs this many photos to be interesting - return false unless photos.size >= min_photos - return false unless plantings_count >= min_plantings - - true + photos.size >= 3 || plantings_count >= 3 end def pending? From c0e957b05198233ade5793d522b1678b87e39464 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Fri, 4 Jan 2019 18:54:49 +1300 Subject: [PATCH 057/207] Places params is :place --- app/controllers/places_controller.rb | 4 ++-- config/routes.rb | 2 +- spec/controllers/places_controller_spec.rb | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/app/controllers/places_controller.rb b/app/controllers/places_controller.rb index 360b99426..4586b5d39 100644 --- a/app/controllers/places_controller.rb +++ b/app/controllers/places_controller.rb @@ -17,8 +17,8 @@ class PlacesController < ApplicationController # GET /places/london # GET /places/london.json def show - @place = params[:id] # used for page title - @nearby_members = Member.nearest_to(params[:id]) + @place = params[:place] # used for page title + @nearby_members = Member.nearest_to(params[:place]) respond_to do |format| format.html # show.html.haml format.json do diff --git a/config/routes.rb b/config/routes.rb index a50d7f361..84886fc50 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -97,7 +97,7 @@ Rails.application.routes.draw do get 'reply' end - resources :places, only: %i(index show) do + resources :places, only: %i(index show), param: :place do get 'search', on: :collection end diff --git a/spec/controllers/places_controller_spec.rb b/spec/controllers/places_controller_spec.rb index b49377bdf..d235b98c9 100644 --- a/spec/controllers/places_controller_spec.rb +++ b/spec/controllers/places_controller_spec.rb @@ -12,12 +12,12 @@ describe PlacesController do end it "assigns place name" do - get :show, params: { id: @member_london.location } + get :show, params: { place: @member_london.location } assigns(:place).should eq @member_london.location end it "assigns nearby members" do - get :show, params: { id: @member_london.location } + get :show, params: { place: @member_london.location } assigns(:nearby_members).should eq [@member_london, @member_south_pole] end end From 8cb9361462a5c2395dd4c8ce687b2380b759200a Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Fri, 4 Jan 2019 20:48:40 +1300 Subject: [PATCH 058/207] only look up member/crop if an slug is passed --- app/controllers/plantings_controller.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/controllers/plantings_controller.rb b/app/controllers/plantings_controller.rb index 7907a7a73..449a919bd 100644 --- a/app/controllers/plantings_controller.rb +++ b/app/controllers/plantings_controller.rb @@ -10,8 +10,8 @@ class PlantingsController < ApplicationController responders :flash def index - @owner = Member.find_by(slug: params[:member_slug]) - @crop = Crop.find_by(slug: params[:crop_slug]) + @owner = Member.find_by(slug: params[:member_slug]) if params[:member_slug] + @crop = Crop.find_by(slug: params[:crop_slug]) if params[:crop_slug] @show_all = params[:all] == '1' From 6c70044a7f09852ede39142b2ce0712a5cb8c0db Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Fri, 18 Jan 2019 14:13:11 +1300 Subject: [PATCH 059/207] Switch to SendGrid (remove sparkhost) --- Gemfile | 1 - Gemfile.lock | 3 --- app.json | 2 +- config/application.yml.example | 3 --- config/environments/production.rb | 13 +++++++------ 5 files changed, 8 insertions(+), 14 deletions(-) diff --git a/Gemfile b/Gemfile index c0cd21aa5..d52faad1c 100644 --- a/Gemfile +++ b/Gemfile @@ -109,7 +109,6 @@ group :production, :staging do gem 'memcachier' gem 'newrelic_rpm' gem 'rails_12factor' # supresses heroku plugin injection - gem 'sparkpost_rails' end group :development do diff --git a/Gemfile.lock b/Gemfile.lock index 66fc03724..2695da455 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -459,8 +459,6 @@ GEM json (>= 1.8, < 3) simplecov-html (~> 0.10.0) simplecov-html (0.10.2) - sparkpost_rails (1.5.1) - rails (>= 4.0, < 5.3) sprockets (3.7.2) concurrent-ruby (~> 1.0) rack (> 1, < 3) @@ -584,7 +582,6 @@ DEPENDENCIES sass-rails selenium-webdriver sidekiq - sparkpost_rails timecop uglifier unicorn diff --git a/app.json b/app.json index fc266aded..051e2bbf9 100644 --- a/app.json +++ b/app.json @@ -41,7 +41,7 @@ "bonsai-elasticsearch", "memcachier", "newrelic", - "sparkhost" + "sendgrid" ], "buildpacks": [ { diff --git a/config/application.yml.example b/config/application.yml.example index 1ff6b5f99..e0f0f67d2 100644 --- a/config/application.yml.example +++ b/config/application.yml.example @@ -81,7 +81,6 @@ GROWSTUFF_EMAIL: 'noreply@dev.growstuff.org' test: GROWSTUFF_SITE_NAME: Growstuff (test) GROWSTUFF_CAPYBARA_DRIVER: poltergeist - GROWSTUFF_EMAIL: 'noreply@test.growstuff.org' # Note: there is no good way to deploy settings from Figaro to # Travis-CI. If you need env vars set there in order for tests to pass, @@ -90,9 +89,7 @@ test: staging: GROWSTUFF_SITE_NAME: Growstuff (staging) GROWSTUFF_ELASTICSEARCH: "true" - GROWSTUFF_EMAIL: 'noreply@staging.growstuff.org' production: GROWSTUFF_SITE_NAME: Growstuff GROWSTUFF_ELASTICSEARCH: "true" - GROWSTUFF_EMAIL: 'noreply@growstuff.org' diff --git a/config/environments/production.rb b/config/environments/production.rb index b9ab1a14e..9175f85f1 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -82,12 +82,13 @@ Rails.application.configure do # Growstuff configuration config.action_mailer.default_url_options = { host: ENV['MAIL_SENDER_HOST'] } - ActionMailer::Base.smtp_settings = { - port: ENV['SPARKPOST_SMTP_PORT'], - address: ENV['SPARKPOST_SMTP_HOST'], - user_name: ENV['SPARKPOST_SMTP_USERNAME'], - password: ENV['SPARKPOST_SMTP_PASSWORD'], - authentication: :login, + config.action_mailer.smtp_settings = { + user_name: ENV['SENDGRID_USERNAME'], + password: ENV['SENDGRID_PASSWORD'], + domain: ENV['GROWSTUFF_EMAIL_DOMAIN'], + address: 'smtp.sendgrid.net', + port: 587, + authentication: :plain, enable_starttls_auto: true } ActionMailer::Base.delivery_method = :smtp From 03c8d75899983eb73428484f0f8d7bcb95ac7c68 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Fri, 18 Jan 2019 14:48:04 +1300 Subject: [PATCH 060/207] Fixing the app.json for Bonsai --- app.json | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/app.json b/app.json index fc266aded..2d9096437 100644 --- a/app.json +++ b/app.json @@ -38,10 +38,15 @@ }, "addons": [ "heroku-postgresql", - "bonsai-elasticsearch", "memcachier", "newrelic", - "sparkhost" + "sparkhost", + { + "plan": "bonsai:sandbox-6", + "options": { + "version": "6.2.3" + } + } ], "buildpacks": [ { From 1fc70e5a2b3eb1d6f7969cdab10c5d2f6cdebcf7 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Fri, 18 Jan 2019 14:54:24 +1300 Subject: [PATCH 061/207] Rubocop linting --- config/environments/production.rb | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/config/environments/production.rb b/config/environments/production.rb index 464bef857..d4f2bcddf 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -83,12 +83,12 @@ Rails.application.configure do config.action_mailer.default_url_options = { host: ENV['MAIL_SENDER_HOST'] } config.action_mailer.smtp_settings = { - user_name: ENV['SENDGRID_USERNAME'], - password: ENV['SENDGRID_PASSWORD'], - domain: ENV['GROWSTUFF_EMAIL_DOMAIN'], - address: 'smtp.sendgrid.net', - port: 587, - authentication: :plain, + user_name: ENV['SENDGRID_USERNAME'], + password: ENV['SENDGRID_PASSWORD'], + domain: ENV['GROWSTUFF_EMAIL_DOMAIN'], + address: 'smtp.sendgrid.net', + port: 587, + authentication: :plain, enable_starttls_auto: true } ActionMailer::Base.delivery_method = :smtp From a06516b80fd2a9ee68e100a5274dd208c2a4ffce Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Fri, 18 Jan 2019 20:00:31 +1300 Subject: [PATCH 062/207] Put displayed link back to using login_name --- app/assets/javascripts/crops.js.erb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/assets/javascripts/crops.js.erb b/app/assets/javascripts/crops.js.erb index 5c92b2adb..409e7a9f2 100644 --- a/app/assets/javascripts/crops.js.erb +++ b/app/assets/javascripts/crops.js.erb @@ -17,7 +17,7 @@ function showCropMap(cropmap) { var marker = new L.Marker(new L.LatLng(owner.latitude, owner.longitude)); var planting_url = "/plantings/" + planting.id; - var planting_link = "" + owner.slug + "'s " + crop.name + ""; + var planting_link = "" + owner.login_name + "'s " + crop.name + ""; var where = "

" + owner.location + "

"; @@ -54,4 +54,4 @@ $(document).ready(function() { $('.btn.toggle.crop-hierarchy').click(function () { $('.toggle.crop-hierarchy').toggleClass('hide'); }); -}); \ No newline at end of file +}); From e337fcb7f7454be87ca122b611a8ad6a0cd67588 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Fri, 18 Jan 2019 20:00:59 +1300 Subject: [PATCH 063/207] Put displayed member back to using member.slug --- app/assets/javascripts/members.js.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/assets/javascripts/members.js.erb b/app/assets/javascripts/members.js.erb index 2d3752f53..d7bb5020c 100644 --- a/app/assets/javascripts/members.js.erb +++ b/app/assets/javascripts/members.js.erb @@ -18,7 +18,7 @@ if (document.getElementById("membermap") !== null) { var marker = new L.Marker(new L.LatLng(member.latitude, member.longitude)); var member_url = "/members/" + member.slug; - var member_link = "" + member.slug + ""; + var member_link = "" + member.login_name + ""; var where = "

" + member.location + "

"; From cb6a06feb64d9e9884a099afd3d244f62de02037 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Fri, 18 Jan 2019 20:02:15 +1300 Subject: [PATCH 064/207] find by slug --- app/controllers/charts/crops_controller.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/controllers/charts/crops_controller.rb b/app/controllers/charts/crops_controller.rb index 6a1a0e6e8..9626a76b9 100644 --- a/app/controllers/charts/crops_controller.rb +++ b/app/controllers/charts/crops_controller.rb @@ -11,7 +11,7 @@ module Charts end def harvested_for - @crop = Crop.find(params[:crop_slug]) + @crop = Crop.find_by!(slug: params[:crop_slug]) render json: Harvest.joins(:plant_part) .where(crop: @crop) .group("plant_parts.name").count(:id) @@ -20,7 +20,7 @@ module Charts private def pie_chart_query(field) - @crop = Crop.find(params[:crop_slug]) + @crop = Crop.find_by!(slug: params[:crop_slug]) render json: Planting.where(crop: @crop) .where.not(field.to_sym => nil) .where.not(field.to_sym => '') From 3212f748b49e97981e0d30ea835b78b001ce67a3 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Fri, 18 Jan 2019 20:03:22 +1300 Subject: [PATCH 065/207] Update crops_controller.rb --- app/controllers/crops_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/crops_controller.rb b/app/controllers/crops_controller.rb index e5d36302d..ce64ef0f7 100644 --- a/app/controllers/crops_controller.rb +++ b/app/controllers/crops_controller.rb @@ -49,7 +49,7 @@ class CropsController < ApplicationController end def show - @crop = Crop.includes(:scientific_names, plantings: :photos).find(params[:slug]) + @crop = Crop.includes(:scientific_names, plantings: :photos).find_by!(slug: params[:slug]) @posts = @crop.posts.order(created_at: :desc).paginate(page: params[:page]) # respond_with(@crop) respond_to do |format| From d1a3f41462722f6210a02dcc7f17cc657b527ea8 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Fri, 18 Jan 2019 20:04:19 +1300 Subject: [PATCH 066/207] Throw if can't find the @crop --- app/controllers/crops_controller.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/controllers/crops_controller.rb b/app/controllers/crops_controller.rb index ce64ef0f7..73019a827 100644 --- a/app/controllers/crops_controller.rb +++ b/app/controllers/crops_controller.rb @@ -67,7 +67,7 @@ class CropsController < ApplicationController end def edit - @crop = Crop.find_by(slug: params[:slug]) + @crop = Crop.find_by!(slug: params[:slug]) @crop.alternate_names.build if @crop.alternate_names.blank? @crop.scientific_names.build if @crop.scientific_names.blank? end @@ -88,7 +88,7 @@ class CropsController < ApplicationController end def update - @crop = Crop.find_by(slug: params[:slug]) + @crop = Crop.find_by!(slug: params[:slug]) previous_status = @crop.approval_status @crop.creator = current_member if previous_status == "pending" From b35d13d5e5cc9ffb78aee341d227e516a6902b61 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Fri, 18 Jan 2019 20:05:41 +1300 Subject: [PATCH 067/207] Update seeds_controller.rb --- app/controllers/seeds_controller.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/controllers/seeds_controller.rb b/app/controllers/seeds_controller.rb index a0cb68b6b..cbed89e5c 100644 --- a/app/controllers/seeds_controller.rb +++ b/app/controllers/seeds_controller.rb @@ -8,8 +8,8 @@ class SeedsController < ApplicationController # GET /seeds # GET /seeds.json def index - @owner = Member.find_by(slug: params[:member_slug]) - @crop = Crop.find_by(slug: params[:crop_slug]) + @owner = Member.find_by(slug: params[:member_slug]) if params[:member_slug].present? + @crop = Crop.find_by(slug: params[:crop_slug]) if params[:crop_slug].present? @seeds = @seeds.where(owner: @owner) if @owner.present? @seeds = @seeds.where(crop: @crop) if @crop.present? From 5b732fedaec429f1b5c925604e3e887863347cc8 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Sat, 19 Jan 2019 12:36:27 +1300 Subject: [PATCH 068/207] Remove references to MANDRILL --- config/application.yml.example | 2 -- config/environments/development.rb | 7 ------- 2 files changed, 9 deletions(-) diff --git a/config/application.yml.example b/config/application.yml.example index e0f0f67d2..568a276c7 100644 --- a/config/application.yml.example +++ b/config/application.yml.example @@ -35,8 +35,6 @@ GROWSTUFF_SITE_NAME: Growstuff (dev) # confirmations). If using Heroku connect to Mandrill via Heroku addons # list then go to tools menu (upper right) and choose "SMTP and API # Credentials" -GROWSTUFF_MANDRILL_USERNAME: "dummy" -GROWSTUFF_MANDRILL_APIKEY: "dummy" # Mailchimp is used for subscribing/unsubscribing people from the newsletter # To fetch list IDs using Gibbon (and thus find the ID of your newsletter): diff --git a/config/environments/development.rb b/config/environments/development.rb index 888bee353..46106e08d 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -63,13 +63,6 @@ Rails.application.configure do config.action_mailer.default_url_options = { host: 'localhost:3000' } config.action_mailer.delivery_method = :letter_opener - config.action_mailer.smtp_settings = { - port: '587', - address: 'smtp.mandrillapp.com', - user_name: ENV['GROWSTUFF_MANDRILL_USERNAME'], - password: ENV['GROWSTUFF_MANDRILL_APIKEY'], - authentication: :login - } config.host = 'localhost:3000' config.analytics_code = '' From 24ead96a71b216c977bcf2783211c1ffd0e40a5e Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Mon, 21 Jan 2019 11:46:50 +1300 Subject: [PATCH 069/207] Call t() on button labels --- app/views/shared/buttons/_add_photo.haml | 2 +- app/views/shared/buttons/_delete.haml | 6 +++--- app/views/shared/buttons/_edit.haml | 4 ++-- app/views/shared/buttons/_finish_planting.html.haml | 4 ++-- app/views/shared/buttons/_finish_seeds.haml | 4 ++-- app/views/shared/buttons/_harvest_planting.haml | 4 ++-- app/views/shared/buttons/_save_seeds.haml | 4 ++-- 7 files changed, 14 insertions(+), 14 deletions(-) diff --git a/app/views/shared/buttons/_add_photo.haml b/app/views/shared/buttons/_add_photo.haml index 71e97c0e9..09199c208 100644 --- a/app/views/shared/buttons/_add_photo.haml +++ b/app/views/shared/buttons/_add_photo.haml @@ -1,4 +1,4 @@ - if can?(:create, Photo) = link_to path, class: 'btn btn-default btn-xs' do %span.glyphicon.glyphicon-camera{ title: "Add photo" } - Add photo + =t(:add_photo) diff --git a/app/views/shared/buttons/_delete.haml b/app/views/shared/buttons/_delete.haml index b7490837b..635b652c0 100644 --- a/app/views/shared/buttons/_delete.haml +++ b/app/views/shared/buttons/_delete.haml @@ -1,4 +1,4 @@ = link_to path, method: :delete, - data: { confirm: 'Are you sure?' }, class: 'btn btn-default btn-xs' do - %span.glyphicon.glyphicon-trash{ title: "Delete" } - Delete + data: { confirm: t(:are_you_sure?) }, class: 'btn btn-default btn-xs' do + %span.glyphicon.glyphicon-trash{ title: t(:delete) } + =t :delete diff --git a/app/views/shared/buttons/_edit.haml b/app/views/shared/buttons/_edit.haml index 87d464023..f45fc529e 100644 --- a/app/views/shared/buttons/_edit.haml +++ b/app/views/shared/buttons/_edit.haml @@ -1,3 +1,3 @@ = link_to path, class: 'btn btn-default btn-xs' do - %span.glyphicon.glyphicon-pencil{ title: "Edit" } - Edit + %span.glyphicon.glyphicon-pencil{ title: t(:edit) } + =t :edit diff --git a/app/views/shared/buttons/_finish_planting.html.haml b/app/views/shared/buttons/_finish_planting.html.haml index 7b1ba8319..166bb6817 100644 --- a/app/views/shared/buttons/_finish_planting.html.haml +++ b/app/views/shared/buttons/_finish_planting.html.haml @@ -1,5 +1,5 @@ - if can?(:edit, planting) && !planting.finished = link_to planting_path(planting, planting: { finished: 1 }), method: :put, class: 'btn btn-default btn-xs append-date' do - %span.glyphicon.glyphicon-ok{ title: "Finished" } - Mark as finished + %span.glyphicon.glyphicon-ok{ title: t(:finished) } + =t :mark_as_finished diff --git a/app/views/shared/buttons/_finish_seeds.haml b/app/views/shared/buttons/_finish_seeds.haml index 211e3ec8b..54a4d68b5 100644 --- a/app/views/shared/buttons/_finish_seeds.haml +++ b/app/views/shared/buttons/_finish_seeds.haml @@ -1,5 +1,5 @@ - unless seed.finished = link_to seed_path(seed, seed: { finished: 1 }), method: :put, class: 'btn btn-default btn-xs append-date' do - %span.glyphicon.glyphicon-ok{ title: "Finished" } - Mark as finished + %span.glyphicon.glyphicon-ok{ title: t(:finished) } + =t(:mark_as_finished) diff --git a/app/views/shared/buttons/_harvest_planting.haml b/app/views/shared/buttons/_harvest_planting.haml index c90e163ad..f18d948bd 100644 --- a/app/views/shared/buttons/_harvest_planting.haml +++ b/app/views/shared/buttons/_harvest_planting.haml @@ -1,4 +1,4 @@ - planting.active? && if can?(:create, Harvest) && can?(:edit, planting) = link_to new_planting_harvest_path(planting), class: 'btn btn-default btn-xs' do - %span.glyphicon.glyphicon-leaf{ title: "Harvest" } - Harvest + %span.glyphicon.glyphicon-leaf{ title: :harvest } + =t(:harvest) diff --git a/app/views/shared/buttons/_save_seeds.haml b/app/views/shared/buttons/_save_seeds.haml index 00d5febb0..c1664de35 100644 --- a/app/views/shared/buttons/_save_seeds.haml +++ b/app/views/shared/buttons/_save_seeds.haml @@ -1,4 +1,4 @@ - if planting.active? = link_to new_planting_seed_path(planting), class: 'btn btn-default btn-xs' do - %span.glyphicon.glyphicon-heart{ title: "Save seeds" } - Save seeds + %span.glyphicon.glyphicon-heart{ title: t(:save_seeds) } + =t(:save_seeds) From 0914caae88df5cadb1f08df6db7764f127a40fbe Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Mon, 21 Jan 2019 11:47:25 +1300 Subject: [PATCH 070/207] Move the action buttons to EVERY page --- app/views/home/index.html.haml | 7 ------- app/views/layouts/application.html.haml | 1 + app/views/shared/_global_actions.html.haml | 6 ++++++ 3 files changed, 7 insertions(+), 7 deletions(-) create mode 100644 app/views/shared/_global_actions.html.haml diff --git a/app/views/home/index.html.haml b/app/views/home/index.html.haml index d05d6a37a..0259ce590 100644 --- a/app/views/home/index.html.haml +++ b/app/views/home/index.html.haml @@ -4,13 +4,6 @@ %h1= t('.welcome', site_name: ENV['GROWSTUFF_SITE_NAME'], member_name: current_member) = render 'stats' - %p - .btn-group - = link_to t('.plant'), new_planting_path, class: 'btn btn-default' - = link_to t('.harvest'), new_harvest_path, class: 'btn btn-default' - = link_to t('.add_seeds'), new_seed_path, class: 'btn btn-default' - = link_to t('.post'), new_post_path, class: 'btn btn-default' - - else .hidden-xs .jumbotron diff --git a/app/views/layouts/application.html.haml b/app/views/layouts/application.html.haml index 070ed73db..34dbbdfe5 100644 --- a/app/views/layouts/application.html.haml +++ b/app/views/layouts/application.html.haml @@ -8,6 +8,7 @@ #maincontainer .row .col-md-12 + = render 'shared/global_actions' - if content_for?(:title) %h1#title = yield(:title) diff --git a/app/views/shared/_global_actions.html.haml b/app/views/shared/_global_actions.html.haml new file mode 100644 index 000000000..d4b4a5e97 --- /dev/null +++ b/app/views/shared/_global_actions.html.haml @@ -0,0 +1,6 @@ +%p + .btn-group + = link_to t(:plant_something), new_planting_path, class: 'btn btn-default' + = link_to t(:harvest_something), new_harvest_path, class: 'btn btn-default' + = link_to t(:save_seeds), new_seed_path, class: 'btn btn-default' + = link_to t(:write_blog_post), new_post_path, class: 'btn btn-default' From 47e11c5b7cb8c3357ada3bc50ab56416be7f0d2e Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Mon, 21 Jan 2019 13:37:58 +1300 Subject: [PATCH 071/207] Put buttons translations under buttons namespace --- app/views/shared/buttons/_add_photo.haml | 2 +- app/views/shared/buttons/_delete.haml | 2 +- app/views/shared/buttons/_edit.haml | 2 +- app/views/shared/buttons/_finish_planting.html.haml | 2 +- app/views/shared/buttons/_finish_seeds.haml | 2 +- app/views/shared/buttons/_harvest_planting.haml | 2 +- app/views/shared/buttons/_save_seeds.haml | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) diff --git a/app/views/shared/buttons/_add_photo.haml b/app/views/shared/buttons/_add_photo.haml index 09199c208..c2c87f315 100644 --- a/app/views/shared/buttons/_add_photo.haml +++ b/app/views/shared/buttons/_add_photo.haml @@ -1,4 +1,4 @@ - if can?(:create, Photo) = link_to path, class: 'btn btn-default btn-xs' do %span.glyphicon.glyphicon-camera{ title: "Add photo" } - =t(:add_photo) + =t('buttons.add_photo') diff --git a/app/views/shared/buttons/_delete.haml b/app/views/shared/buttons/_delete.haml index 635b652c0..d89a51d2d 100644 --- a/app/views/shared/buttons/_delete.haml +++ b/app/views/shared/buttons/_delete.haml @@ -1,4 +1,4 @@ = link_to path, method: :delete, data: { confirm: t(:are_you_sure?) }, class: 'btn btn-default btn-xs' do %span.glyphicon.glyphicon-trash{ title: t(:delete) } - =t :delete + =t('buttons.delete') diff --git a/app/views/shared/buttons/_edit.haml b/app/views/shared/buttons/_edit.haml index f45fc529e..3e00821c5 100644 --- a/app/views/shared/buttons/_edit.haml +++ b/app/views/shared/buttons/_edit.haml @@ -1,3 +1,3 @@ = link_to path, class: 'btn btn-default btn-xs' do %span.glyphicon.glyphicon-pencil{ title: t(:edit) } - =t :edit + =t('buttons.edit') diff --git a/app/views/shared/buttons/_finish_planting.html.haml b/app/views/shared/buttons/_finish_planting.html.haml index 166bb6817..c38ba3185 100644 --- a/app/views/shared/buttons/_finish_planting.html.haml +++ b/app/views/shared/buttons/_finish_planting.html.haml @@ -2,4 +2,4 @@ = link_to planting_path(planting, planting: { finished: 1 }), method: :put, class: 'btn btn-default btn-xs append-date' do %span.glyphicon.glyphicon-ok{ title: t(:finished) } - =t :mark_as_finished + =t('buttons.mark_as_finished') diff --git a/app/views/shared/buttons/_finish_seeds.haml b/app/views/shared/buttons/_finish_seeds.haml index 54a4d68b5..49c34ac17 100644 --- a/app/views/shared/buttons/_finish_seeds.haml +++ b/app/views/shared/buttons/_finish_seeds.haml @@ -2,4 +2,4 @@ = link_to seed_path(seed, seed: { finished: 1 }), method: :put, class: 'btn btn-default btn-xs append-date' do %span.glyphicon.glyphicon-ok{ title: t(:finished) } - =t(:mark_as_finished) + =t('buttons.mark_as_finished') diff --git a/app/views/shared/buttons/_harvest_planting.haml b/app/views/shared/buttons/_harvest_planting.haml index f18d948bd..8845e4c01 100644 --- a/app/views/shared/buttons/_harvest_planting.haml +++ b/app/views/shared/buttons/_harvest_planting.haml @@ -1,4 +1,4 @@ - planting.active? && if can?(:create, Harvest) && can?(:edit, planting) = link_to new_planting_harvest_path(planting), class: 'btn btn-default btn-xs' do %span.glyphicon.glyphicon-leaf{ title: :harvest } - =t(:harvest) + =t('buttons.harvest') diff --git a/app/views/shared/buttons/_save_seeds.haml b/app/views/shared/buttons/_save_seeds.haml index c1664de35..312f54cf4 100644 --- a/app/views/shared/buttons/_save_seeds.haml +++ b/app/views/shared/buttons/_save_seeds.haml @@ -1,4 +1,4 @@ - if planting.active? = link_to new_planting_seed_path(planting), class: 'btn btn-default btn-xs' do %span.glyphicon.glyphicon-heart{ title: t(:save_seeds) } - =t(:save_seeds) + =t('buttons.save_seeds') From e6dea3193503e67fc63c2a852a611e7165297263 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Mon, 21 Jan 2019 13:40:56 +1300 Subject: [PATCH 072/207] Use buttons.* translations for glyphicons titles --- app/views/shared/_global_actions.html.haml | 8 ++++---- app/views/shared/buttons/_add_photo.haml | 2 +- app/views/shared/buttons/_delete.haml | 2 +- app/views/shared/buttons/_edit.haml | 2 +- app/views/shared/buttons/_finish_planting.html.haml | 2 +- app/views/shared/buttons/_finish_seeds.haml | 2 +- app/views/shared/buttons/_harvest_planting.haml | 4 ++-- app/views/shared/buttons/_save_seeds.haml | 4 ++-- config/locales/en.yml | 10 ++++++++++ 9 files changed, 23 insertions(+), 13 deletions(-) diff --git a/app/views/shared/_global_actions.html.haml b/app/views/shared/_global_actions.html.haml index d4b4a5e97..59481c858 100644 --- a/app/views/shared/_global_actions.html.haml +++ b/app/views/shared/_global_actions.html.haml @@ -1,6 +1,6 @@ %p .btn-group - = link_to t(:plant_something), new_planting_path, class: 'btn btn-default' - = link_to t(:harvest_something), new_harvest_path, class: 'btn btn-default' - = link_to t(:save_seeds), new_seed_path, class: 'btn btn-default' - = link_to t(:write_blog_post), new_post_path, class: 'btn btn-default' + = link_to t('buttons.plant_something'), new_planting_path, class: 'btn btn-default' + = link_to t('buttons.harvest_something'), new_harvest_path, class: 'btn btn-default' + = link_to t('buttons.save_seeds'), new_seed_path, class: 'btn btn-default' + = link_to t('buttons.write_blog_post'), new_post_path, class: 'btn btn-default' diff --git a/app/views/shared/buttons/_add_photo.haml b/app/views/shared/buttons/_add_photo.haml index c2c87f315..425ca52fc 100644 --- a/app/views/shared/buttons/_add_photo.haml +++ b/app/views/shared/buttons/_add_photo.haml @@ -1,4 +1,4 @@ - if can?(:create, Photo) = link_to path, class: 'btn btn-default btn-xs' do - %span.glyphicon.glyphicon-camera{ title: "Add photo" } + %span.glyphicon.glyphicon-camera{ title: t('buttons.add_photo') } =t('buttons.add_photo') diff --git a/app/views/shared/buttons/_delete.haml b/app/views/shared/buttons/_delete.haml index d89a51d2d..f4ae4f5cd 100644 --- a/app/views/shared/buttons/_delete.haml +++ b/app/views/shared/buttons/_delete.haml @@ -1,4 +1,4 @@ = link_to path, method: :delete, data: { confirm: t(:are_you_sure?) }, class: 'btn btn-default btn-xs' do - %span.glyphicon.glyphicon-trash{ title: t(:delete) } + %span.glyphicon.glyphicon-trash{ title: t('buttons.delete') } =t('buttons.delete') diff --git a/app/views/shared/buttons/_edit.haml b/app/views/shared/buttons/_edit.haml index 3e00821c5..1ad2fc77e 100644 --- a/app/views/shared/buttons/_edit.haml +++ b/app/views/shared/buttons/_edit.haml @@ -1,3 +1,3 @@ = link_to path, class: 'btn btn-default btn-xs' do - %span.glyphicon.glyphicon-pencil{ title: t(:edit) } + %span.glyphicon.glyphicon-pencil{ title: t('buttons.edit') } =t('buttons.edit') diff --git a/app/views/shared/buttons/_finish_planting.html.haml b/app/views/shared/buttons/_finish_planting.html.haml index c38ba3185..5d49418a1 100644 --- a/app/views/shared/buttons/_finish_planting.html.haml +++ b/app/views/shared/buttons/_finish_planting.html.haml @@ -1,5 +1,5 @@ - if can?(:edit, planting) && !planting.finished = link_to planting_path(planting, planting: { finished: 1 }), method: :put, class: 'btn btn-default btn-xs append-date' do - %span.glyphicon.glyphicon-ok{ title: t(:finished) } + %span.glyphicon.glyphicon-ok{ title: t('buttons.finished') } =t('buttons.mark_as_finished') diff --git a/app/views/shared/buttons/_finish_seeds.haml b/app/views/shared/buttons/_finish_seeds.haml index 49c34ac17..4589e50f2 100644 --- a/app/views/shared/buttons/_finish_seeds.haml +++ b/app/views/shared/buttons/_finish_seeds.haml @@ -1,5 +1,5 @@ - unless seed.finished = link_to seed_path(seed, seed: { finished: 1 }), method: :put, class: 'btn btn-default btn-xs append-date' do - %span.glyphicon.glyphicon-ok{ title: t(:finished) } + %span.glyphicon.glyphicon-ok{ title: t('buttons.finished') } =t('buttons.mark_as_finished') diff --git a/app/views/shared/buttons/_harvest_planting.haml b/app/views/shared/buttons/_harvest_planting.haml index 8845e4c01..d81b18fa2 100644 --- a/app/views/shared/buttons/_harvest_planting.haml +++ b/app/views/shared/buttons/_harvest_planting.haml @@ -1,4 +1,4 @@ - planting.active? && if can?(:create, Harvest) && can?(:edit, planting) = link_to new_planting_harvest_path(planting), class: 'btn btn-default btn-xs' do - %span.glyphicon.glyphicon-leaf{ title: :harvest } - =t('buttons.harvest') + %span.glyphicon.glyphicon-leaf{ title: = t('buttons.harvest') } + = t('buttons.harvest') diff --git a/app/views/shared/buttons/_save_seeds.haml b/app/views/shared/buttons/_save_seeds.haml index 312f54cf4..d18807b2b 100644 --- a/app/views/shared/buttons/_save_seeds.haml +++ b/app/views/shared/buttons/_save_seeds.haml @@ -1,4 +1,4 @@ - if planting.active? = link_to new_planting_seed_path(planting), class: 'btn btn-default btn-xs' do - %span.glyphicon.glyphicon-heart{ title: t(:save_seeds) } - =t('buttons.save_seeds') + %span.glyphicon.glyphicon-heart{ title: t('buttons.save_seeds') } + = t('buttons.save_seeds') diff --git a/config/locales/en.yml b/config/locales/en.yml index 879d7c51c..7f2778983 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -63,6 +63,16 @@ en: seed: one: seed other: seeds + buttons: + add_photo: Add photo + delete: Delete + edit: Edit + harvest: Harvest + harvest_something: Harvest something + mark_as_finished: Mark as finished + plant_something: Plant something + save_seeds: Save seeds + write_blog_post: Write blog post crops: index: subtitle: "%{crops_size} total" From 73fa667c1db6a341b53f1bef40e9990d2054bd25 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Mon, 21 Jan 2019 14:13:12 +1300 Subject: [PATCH 073/207] Dry the gglypicons --- app/views/shared/_glyphicon.html.haml | 1 + app/views/shared/buttons/_add_photo.haml | 2 +- app/views/shared/buttons/_delete.haml | 2 +- app/views/shared/buttons/_edit.haml | 2 +- app/views/shared/buttons/_finish_planting.html.haml | 4 ++-- app/views/shared/buttons/_finish_seeds.haml | 2 +- app/views/shared/buttons/_harvest_planting.haml | 2 +- app/views/shared/buttons/_save_seeds.haml | 2 +- 8 files changed, 9 insertions(+), 8 deletions(-) create mode 100644 app/views/shared/_glyphicon.html.haml diff --git a/app/views/shared/_glyphicon.html.haml b/app/views/shared/_glyphicon.html.haml new file mode 100644 index 000000000..39f2546cf --- /dev/null +++ b/app/views/shared/_glyphicon.html.haml @@ -0,0 +1 @@ +%span{class: "glyphicon.glyphicon-#{icon}", title: t(title) } \ No newline at end of file diff --git a/app/views/shared/buttons/_add_photo.haml b/app/views/shared/buttons/_add_photo.haml index 425ca52fc..0e4a75c07 100644 --- a/app/views/shared/buttons/_add_photo.haml +++ b/app/views/shared/buttons/_add_photo.haml @@ -1,4 +1,4 @@ - if can?(:create, Photo) = link_to path, class: 'btn btn-default btn-xs' do - %span.glyphicon.glyphicon-camera{ title: t('buttons.add_photo') } + = render 'shared/glyphicon', icon: 'camera', title: 'buttons.add_photo' =t('buttons.add_photo') diff --git a/app/views/shared/buttons/_delete.haml b/app/views/shared/buttons/_delete.haml index f4ae4f5cd..8be23926a 100644 --- a/app/views/shared/buttons/_delete.haml +++ b/app/views/shared/buttons/_delete.haml @@ -1,4 +1,4 @@ = link_to path, method: :delete, data: { confirm: t(:are_you_sure?) }, class: 'btn btn-default btn-xs' do - %span.glyphicon.glyphicon-trash{ title: t('buttons.delete') } + = render 'shared/glyphicon', icon: 'trash', title: 'buttons.delete' =t('buttons.delete') diff --git a/app/views/shared/buttons/_edit.haml b/app/views/shared/buttons/_edit.haml index 1ad2fc77e..f7f75ea36 100644 --- a/app/views/shared/buttons/_edit.haml +++ b/app/views/shared/buttons/_edit.haml @@ -1,3 +1,3 @@ = link_to path, class: 'btn btn-default btn-xs' do - %span.glyphicon.glyphicon-pencil{ title: t('buttons.edit') } + = render 'shared/glyphicon', icon: 'pencil', title: 'buttons.edit' =t('buttons.edit') diff --git a/app/views/shared/buttons/_finish_planting.html.haml b/app/views/shared/buttons/_finish_planting.html.haml index 5d49418a1..d0a931b41 100644 --- a/app/views/shared/buttons/_finish_planting.html.haml +++ b/app/views/shared/buttons/_finish_planting.html.haml @@ -1,5 +1,5 @@ - if can?(:edit, planting) && !planting.finished = link_to planting_path(planting, planting: { finished: 1 }), method: :put, class: 'btn btn-default btn-xs append-date' do - %span.glyphicon.glyphicon-ok{ title: t('buttons.finished') } - =t('buttons.mark_as_finished') + = render 'shared/glyphicon', icon: 'ok', title: 'buttons.finished' + = t('buttons.mark_as_finished') diff --git a/app/views/shared/buttons/_finish_seeds.haml b/app/views/shared/buttons/_finish_seeds.haml index 4589e50f2..23316d861 100644 --- a/app/views/shared/buttons/_finish_seeds.haml +++ b/app/views/shared/buttons/_finish_seeds.haml @@ -1,5 +1,5 @@ - unless seed.finished = link_to seed_path(seed, seed: { finished: 1 }), method: :put, class: 'btn btn-default btn-xs append-date' do - %span.glyphicon.glyphicon-ok{ title: t('buttons.finished') } + = render 'shared/glyphicon', icon: 'ok', title: 'buttons.finished' =t('buttons.mark_as_finished') diff --git a/app/views/shared/buttons/_harvest_planting.haml b/app/views/shared/buttons/_harvest_planting.haml index d81b18fa2..296ee30a0 100644 --- a/app/views/shared/buttons/_harvest_planting.haml +++ b/app/views/shared/buttons/_harvest_planting.haml @@ -1,4 +1,4 @@ - planting.active? && if can?(:create, Harvest) && can?(:edit, planting) = link_to new_planting_harvest_path(planting), class: 'btn btn-default btn-xs' do - %span.glyphicon.glyphicon-leaf{ title: = t('buttons.harvest') } + = render 'shared/glyphicon', icon: 'leaf', title: 'buttons.harvest' = t('buttons.harvest') diff --git a/app/views/shared/buttons/_save_seeds.haml b/app/views/shared/buttons/_save_seeds.haml index d18807b2b..d4cf794f5 100644 --- a/app/views/shared/buttons/_save_seeds.haml +++ b/app/views/shared/buttons/_save_seeds.haml @@ -1,4 +1,4 @@ - if planting.active? = link_to new_planting_seed_path(planting), class: 'btn btn-default btn-xs' do - %span.glyphicon.glyphicon-heart{ title: t('buttons.save_seeds') } + = render 'shared/glyphicon', icon: 'heart', title: 'buttons.save_seeds' = t('buttons.save_seeds') From e8a4cc61ea9cada270b43929ce3a060e4b811ed9 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Mon, 21 Jan 2019 14:13:36 +1300 Subject: [PATCH 074/207] Move global buttons and search --- app/views/crops/_search_bar.haml | 9 ++ app/views/layouts/_header.html.haml | 107 +++++++++++------------- app/views/layouts/application.html.haml | 21 ++--- 3 files changed, 69 insertions(+), 68 deletions(-) create mode 100644 app/views/crops/_search_bar.haml diff --git a/app/views/crops/_search_bar.haml b/app/views/crops/_search_bar.haml new file mode 100644 index 000000000..390c32390 --- /dev/null +++ b/app/views/crops/_search_bar.haml @@ -0,0 +1,9 @@ += form_tag crops_search_path, method: :get, id: 'navbar-search' do + = label_tag :term, "Search crop database:", class: 'sr-only' + .input + .input-group + = text_field_tag 'term', nil, class: 'search-query input-medium form-control', placeholder: 'Search crops' + .input-group-btn + %button.btn.btn-default{ style: "height: 34px;" } + = submit_tag "Search", class: 'btn sr-only' + %span.glyphicon.glyphicon-search diff --git a/app/views/layouts/_header.html.haml b/app/views/layouts/_header.html.haml index d2b8fd01c..ca6bf15bc 100644 --- a/app/views/layouts/_header.html.haml +++ b/app/views/layouts/_header.html.haml @@ -17,72 +17,67 @@ alt: ENV['GROWSTUFF_SITE_NAME']) .form.navbar-form.pull-left - = form_tag crops_search_path, method: :get, id: 'navbar-search' do - = label_tag :term, "Search crop database:", class: 'sr-only' - .input - .input-group - = text_field_tag 'term', nil, class: 'search-query input-medium form-control', placeholder: 'Search crops' - .input-group-btn - %button.btn.btn-default{ style: "height: 34px;" } - = submit_tag "Search", class: 'btn sr-only' - %span.glyphicon.glyphicon-search + = render 'crops/search_bar' .navbar-collapse.collapse#navbar-collapse - %ul.nav.navbar-nav.navbar-right - %li.dropdown< - %a.dropdown-toggle{ 'data-toggle': 'dropdown', href: crops_path } - = t('.crops') - %b.caret - %ul.dropdown-menu - %li= link_to t('.browse_crops'), crops_path - %li= link_to t('.seeds'), seeds_path - %li= link_to t('.plantings'), plantings_path - %li= link_to t('.harvests'), harvests_path - %li.dropdown< - %a.dropdown-toggle{ 'data-toggle': 'dropdown', href: members_path } - = t('.community') - %b.caret - %ul.dropdown-menu - %li= link_to t('.community_map'), places_path - %li= link_to t('.browse_members'), members_path - %li= link_to t('.posts'), posts_path - %li= link_to t('.forums'), forums_path - - - if member_signed_in? + .navbar-right + = render 'shared/global_actions' + %ul.nav.navbar-nav.navbar-right %li.dropdown< - %a.dropdown-toggle{ 'data-toggle': 'dropdown', href: root_path } - - if current_member.notifications.unread_count.positive? - = t('.your_stuff', unread_count: current_member.notifications.unread_count) - - else - = t('.current_memberlogin_name', current_memberlogin_name: current_member.login_name) + %a.dropdown-toggle{ 'data-toggle': 'dropdown', href: crops_path } + = t('.crops') %b.caret %ul.dropdown-menu - %li= link_to t('.profile'), member_path(current_member) - %li= link_to t('.gardens'), gardens_by_owner_path(owner: current_member.slug) - %li= link_to t('.plantings'), plantings_by_owner_path(owner: current_member.slug) - %li= link_to t('.harvest'), harvests_by_owner_path(owner: current_member.slug) - %li= link_to t('.seeds'), seeds_by_owner_path(owner: current_member.slug) - %li= link_to t('.posts'), posts_by_author_path(author: current_member.slug) - %li + %li= link_to t('.browse_crops'), crops_path + %li= link_to t('.seeds'), seeds_path + %li= link_to t('.plantings'), plantings_path + %li= link_to t('.harvests'), harvests_path + %li.dropdown< + %a.dropdown-toggle{ 'data-toggle': 'dropdown', href: members_path } + = t('.community') + %b.caret + %ul.dropdown-menu + %li= link_to t('.community_map'), places_path + %li= link_to t('.browse_members'), members_path + %li= link_to t('.posts'), posts_path + %li= link_to t('.forums'), forums_path + + - if member_signed_in? + %li.dropdown< + %a.dropdown-toggle{ 'data-toggle': 'dropdown', href: root_path } - if current_member.notifications.unread_count.positive? - = link_to(t('.inbox_unread', unread_count: current_member.notifications.unread_count), - notifications_path) + = t('.your_stuff', unread_count: current_member.notifications.unread_count) - else - = link_to(t('.inbox'), notifications_path) - - if current_member.role?(:crop_wrangler) || current_member.role?(:admin) - %li.divider{ role: 'presentation' } - - if current_member.role?(:crop_wrangler) - %li= link_to t('.crop_wrangling'), wrangle_crops_path - - if current_member.role?(:admin) - %li= link_to t('.admin'), admin_path + = t('.current_memberlogin_name', current_memberlogin_name: current_member.login_name) + %b.caret + %ul.dropdown-menu + %li= link_to t('.profile'), member_path(current_member) + %li= link_to t('.gardens'), gardens_by_owner_path(owner: current_member.slug) + %li= link_to t('.plantings'), plantings_by_owner_path(owner: current_member.slug) + %li= link_to t('.harvest'), harvests_by_owner_path(owner: current_member.slug) + %li= link_to t('.seeds'), seeds_by_owner_path(owner: current_member.slug) + %li= link_to t('.posts'), posts_by_author_path(author: current_member.slug) + %li + - if current_member.notifications.unread_count.positive? + = link_to(t('.inbox_unread', unread_count: current_member.notifications.unread_count), + notifications_path) + - else + = link_to(t('.inbox'), notifications_path) + - if current_member.role?(:crop_wrangler) || current_member.role?(:admin) + %li.divider{ role: 'presentation' } + - if current_member.role?(:crop_wrangler) + %li= link_to t('.crop_wrangling'), wrangle_crops_path + - if current_member.role?(:admin) + %li= link_to t('.admin'), admin_path - %li= link_to t('.sign_out'), destroy_member_session_path, method: :delete - - - else - %li= link_to t('.sign_in'), new_member_session_path, id: 'navbar-signin' - %li= link_to t('.sign_up'), new_member_registration_path, id: 'navbar-signup' + %li= link_to t('.sign_out'), destroy_member_session_path, method: :delete + - else + %li= link_to t('.sign_in'), new_member_session_path, id: 'navbar-signin' + %li= link_to t('.sign_up'), new_member_registration_path, id: 'navbar-signup' + -# anchor tag for accessibility link to skip the navigation menu %a{ name: 'skipnav' } + diff --git a/app/views/layouts/application.html.haml b/app/views/layouts/application.html.haml index 34dbbdfe5..8fc527ff1 100644 --- a/app/views/layouts/application.html.haml +++ b/app/views/layouts/application.html.haml @@ -6,19 +6,16 @@ = render partial: "layouts/header" #maincontainer - .row - .col-md-12 - = render 'shared/global_actions' - - if content_for?(:title) - %h1#title - = yield(:title) - - if content_for?(:subtitle) - %small= yield(:subtitle) + - if content_for?(:title) + %h1#title + = yield(:title) + - if content_for?(:subtitle) + %small= yield(:subtitle) - - if content_for?(:buttonbar) - .btn-group.layout-actions= yield(:buttonbar) - = render partial: "shared/flash_messages", flash: flash - = yield + - if content_for?(:buttonbar) + .btn-group.layout-actions= yield(:buttonbar) + = render partial: "shared/flash_messages", flash: flash + = yield %footer = render partial: "layouts/footer" From bc359412afabd059975d5e3037ba816427934d4c Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Mon, 21 Jan 2019 14:19:40 +1300 Subject: [PATCH 075/207] Adding missing translations for plantings --- config/locales/en.yml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/config/locales/en.yml b/config/locales/en.yml index 7f2778983..4b104ab81 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -225,6 +225,13 @@ en: index: title: "%{site_name} Community Map" plantings: + badges: + days_until_finished: days until finished + days_until_harvest: days until harvest + harvesting_now: harvesting now + late_finishing: late finishing + sharedbuttonsfinish_planting: shared/buttons/finish_planting + super_late: super late form: finish_helper: > A planting is finished when you've harvested all of the crop, or it dies, or it's otherwise From fbc958b76a720fac83c0fea79017d9bac4faef93 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Mon, 21 Jan 2019 18:41:51 +1300 Subject: [PATCH 076/207] Moved global actions - only show if no buttonbar --- app/views/layouts/_header.html.haml | 1 - app/views/layouts/application.html.haml | 24 ++++++++++++++++-------- 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/app/views/layouts/_header.html.haml b/app/views/layouts/_header.html.haml index ca6bf15bc..990a23c76 100644 --- a/app/views/layouts/_header.html.haml +++ b/app/views/layouts/_header.html.haml @@ -21,7 +21,6 @@ .navbar-collapse.collapse#navbar-collapse .navbar-right - = render 'shared/global_actions' %ul.nav.navbar-nav.navbar-right %li.dropdown< %a.dropdown-toggle{ 'data-toggle': 'dropdown', href: crops_path } diff --git a/app/views/layouts/application.html.haml b/app/views/layouts/application.html.haml index 8fc527ff1..2b1c2e982 100644 --- a/app/views/layouts/application.html.haml +++ b/app/views/layouts/application.html.haml @@ -6,15 +6,23 @@ = render partial: "layouts/header" #maincontainer - - if content_for?(:title) - %h1#title - = yield(:title) - - if content_for?(:subtitle) - %small= yield(:subtitle) - - - if content_for?(:buttonbar) - .btn-group.layout-actions= yield(:buttonbar) = render partial: "shared/flash_messages", flash: flash + .row + .col-md-8 + - if content_for?(:title) + %h1#title + = yield(:title) + - if content_for?(:subtitle) + %small= yield(:subtitle) + + + + .col-md-4 + - if content_for?(:buttonbar) + .btn-group.layout-actions= yield(:buttonbar) + - else + = render 'shared/global_actions' + = yield %footer From 9f61d7212c2ce203caa9c2d192a442bb67b807b4 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Mon, 21 Jan 2019 18:42:02 +1300 Subject: [PATCH 077/207] Moving actions to the button bar --- app/views/crops/_wrangle.html.haml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/app/views/crops/_wrangle.html.haml b/app/views/crops/_wrangle.html.haml index 8e8f87558..16b7ed23b 100644 --- a/app/views/crops/_wrangle.html.haml +++ b/app/views/crops/_wrangle.html.haml @@ -4,11 +4,11 @@ You are a = succeed "." do %strong CROP WRANGLER - %p + - content_for(:buttonbar) do - if can? :edit, crop - = link_to 'Edit crop', edit_crop_path(crop), class: 'btn btn-default btn-xs' + = link_to t(:edit_crop), edit_crop_path(crop), class: 'btn btn-default' - if can? :destroy, crop = link_to 'Delete crop', crop, method: :delete, - data: { confirm: 'Are you sure?' }, - class: 'btn btn-default btn-xs' + data: { confirm: t('are_you_sure') }, + class: 'btn btn-default' From f52bb9737d6201e5ed00a60c3e5c938df63829dd Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Mon, 21 Jan 2019 18:42:13 +1300 Subject: [PATCH 078/207] Moving garden actions to button bar --- app/views/gardens/show.html.haml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/app/views/gardens/show.html.haml b/app/views/gardens/show.html.haml index 8b45b0b16..b71f09c78 100644 --- a/app/views/gardens/show.html.haml +++ b/app/views/gardens/show.html.haml @@ -16,7 +16,8 @@ .row .col-md-9 - = render 'gardens/actions', garden: @garden + -content_for(:buttonbar) do + = render 'gardens/actions', garden: @garden - unless @garden.active @@ -57,7 +58,7 @@ - if @finished_plantings.size.positive? - @finished_plantings.each do |planting| .col-xs-6.col-md-2 - = render partial: "plantings/thumbnail", locals: { planting: planting } + = render "plantings/thumbnail", planting: planting - else %p Nothing has been planted here. .col-md-3 From f5a61ba48611518137ad40fd6c25196710b10403 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Mon, 21 Jan 2019 18:42:21 +1300 Subject: [PATCH 079/207] More button label translations --- config/locales/en.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/config/locales/en.yml b/config/locales/en.yml index 4b104ab81..17a7acc36 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -63,14 +63,17 @@ en: seed: one: seed other: seeds + are_you_sure: 'Are you sure?' buttons: add_photo: Add photo delete: Delete edit: Edit harvest: Harvest + harvest_crop: Harvest %{crop_name} harvest_something: Harvest something mark_as_finished: Mark as finished plant_something: Plant something + plant_crop: Plant %{crop_name} save_seeds: Save seeds write_blog_post: Write blog post crops: From dcd6e3d27c32caf6541af1ab69c4049ce11a8e5e Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Mon, 21 Jan 2019 18:42:34 +1300 Subject: [PATCH 080/207] Bigger buttons --- app/views/shared/_global_actions.html.haml | 13 +++++++------ app/views/shared/buttons/_edit.haml | 2 +- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/app/views/shared/_global_actions.html.haml b/app/views/shared/_global_actions.html.haml index 59481c858..2b5ca1168 100644 --- a/app/views/shared/_global_actions.html.haml +++ b/app/views/shared/_global_actions.html.haml @@ -1,6 +1,7 @@ -%p - .btn-group - = link_to t('buttons.plant_something'), new_planting_path, class: 'btn btn-default' - = link_to t('buttons.harvest_something'), new_harvest_path, class: 'btn btn-default' - = link_to t('buttons.save_seeds'), new_seed_path, class: 'btn btn-default' - = link_to t('buttons.write_blog_post'), new_post_path, class: 'btn btn-default' +.btn-group + = link_to t('buttons.plant_something'), new_planting_path, class: 'btn btn-default' + = link_to t('buttons.harvest_something'), new_harvest_path, class: 'btn btn-default' + = link_to t('buttons.save_seeds'), new_seed_path, class: 'btn btn-default' + +.btn-group + = link_to t('buttons.write_blog_post'), new_post_path, class: 'btn btn-default' diff --git a/app/views/shared/buttons/_edit.haml b/app/views/shared/buttons/_edit.haml index f7f75ea36..f80cdf917 100644 --- a/app/views/shared/buttons/_edit.haml +++ b/app/views/shared/buttons/_edit.haml @@ -1,3 +1,3 @@ -= link_to path, class: 'btn btn-default btn-xs' do += link_to path, class: 'btn btn-default' do = render 'shared/glyphicon', icon: 'pencil', title: 'buttons.edit' =t('buttons.edit') From 9a6bd714cbd0dded2d93e70ae26ed1d4655a3b78 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Mon, 21 Jan 2019 18:42:44 +1300 Subject: [PATCH 081/207] Button for planting stuff --- app/views/shared/buttons/_plant.html.haml | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 app/views/shared/buttons/_plant.html.haml diff --git a/app/views/shared/buttons/_plant.html.haml b/app/views/shared/buttons/_plant.html.haml new file mode 100644 index 000000000..8044dddef --- /dev/null +++ b/app/views/shared/buttons/_plant.html.haml @@ -0,0 +1,3 @@ += link_to new_planting_path(garden_id: garden.id), class: 'btn btn-default' do + = render 'shared/glyphicon', icon: 'grain', title: 'buttons.plant' + = t('buttons.plant_something_here') \ No newline at end of file From 207e9625018b64984be3508948a11e8e7d0f2f93 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Mon, 21 Jan 2019 18:42:52 +1300 Subject: [PATCH 082/207] Fixed glyphicons --- app/views/shared/_glyphicon.html.haml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/shared/_glyphicon.html.haml b/app/views/shared/_glyphicon.html.haml index 39f2546cf..dd34405cc 100644 --- a/app/views/shared/_glyphicon.html.haml +++ b/app/views/shared/_glyphicon.html.haml @@ -1 +1 @@ -%span{class: "glyphicon.glyphicon-#{icon}", title: t(title) } \ No newline at end of file +%span.glyphicon{class: "glyphicon-#{icon}", title: t(title) } \ No newline at end of file From d6fa35099e0b6f3b4a558fd621142cef6d702435 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Mon, 21 Jan 2019 18:43:07 +1300 Subject: [PATCH 083/207] Wrapping crop actions in btn-group --- app/views/crops/_actions.html.haml | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/app/views/crops/_actions.html.haml b/app/views/crops/_actions.html.haml index e15979f61..b27f4b89a 100644 --- a/app/views/crops/_actions.html.haml +++ b/app/views/crops/_actions.html.haml @@ -1,9 +1,10 @@ .crop-actions - - if can? :create, Planting - = link_to "Plant this", new_planting_path(crop_id: crop.id), class: 'btn btn-default' + .btn-group + - if can? :create, Planting + = link_to t('buttons.plant_crop', crop_name: crop.name), new_planting_path(crop_id: crop.id), class: 'btn btn-default' - - if can? :create, Harvest - = link_to "Harvest this", new_harvest_path(crop_id: crop.id), class: 'btn btn-default' + - if can? :create, Harvest + = link_to t('buttons.harvest_crop', crop_name: crop.name), new_harvest_path(crop_id: crop.id), class: 'btn btn-default' - - if can? :create, Seed - = link_to 'Add seeds to stash', new_seed_path(params: { crop_id: crop.id }), class: 'btn btn-default' + - if can? :create, Seed + = link_to t('buttons.add_seed_to_stash'), new_seed_path(params: { crop_id: crop.id }), class: 'btn btn-default' From acab1db135916be0be4b2474f2b7d9e2a952d233 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Mon, 21 Jan 2019 18:43:25 +1300 Subject: [PATCH 084/207] Move homepage title to the :title content --- app/views/home/index.html.haml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/home/index.html.haml b/app/views/home/index.html.haml index 0259ce590..be274c930 100644 --- a/app/views/home/index.html.haml +++ b/app/views/home/index.html.haml @@ -1,7 +1,7 @@ .homepage.row .col-md-12 - if member_signed_in? - %h1= t('.welcome', site_name: ENV['GROWSTUFF_SITE_NAME'], member_name: current_member) + - content_for :title, t('.welcome', site_name: ENV['GROWSTUFF_SITE_NAME'], member_name: current_member) = render 'stats' - else From 42d3db9ba48951fdb0e9fc4c6cbc570eb34739e3 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Mon, 21 Jan 2019 18:43:37 +1300 Subject: [PATCH 085/207] More translations in garden actions --- app/views/gardens/_actions.html.haml | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/app/views/gardens/_actions.html.haml b/app/views/gardens/_actions.html.haml index a5187991e..5ff23e09a 100644 --- a/app/views/gardens/_actions.html.haml +++ b/app/views/gardens/_actions.html.haml @@ -2,28 +2,29 @@ - if can?(:edit, garden) .btn-group - if garden.active - = link_to new_planting_path(garden_id: garden.id), class: 'btn btn-default btn-xs' do - %span.glyphicon.glyphicon-grain{ title: "Plant" } - Plant something - = link_to "Mark as inactive", garden_path(garden, garden: { active: 0 }), - method: :put, class: 'btn btn-default btn-xs', + = render 'shared/buttons/plant', garden: garden + = render 'shared/glyphicon', icon: 'ban', title: 'buttons.mark_as_inactive' + = link_to t('buttons.mark_as_inactive'), garden_path(garden, garden: { active: 0 }), + method: :put, class: 'btn btn-default', data: { confirm: 'All plantings associated with this garden will be marked as finished. Are you sure?' } - else + = render 'shared/glyphicon', icon: 'check', title: 'buttons.mark_active' = link_to "Mark as active", garden_path(garden, garden: { active: 1 }), method: :put + = render 'shared/buttons/edit', path: edit_garden_path(garden) - if can?(:edit, garden) && can?(:create, Photo) = link_to new_photo_path(type: "garden", id: garden.id), - class: 'btn btn-default btn-xs' do + class: 'btn btn-default' do %span.glyphicon.glyphicon-camera{ title: "Add photo" } - Add photo + = t('buttons.add_a_photo') - if can?(:destroy, garden) .pull-right = link_to garden_path(garden), method: :delete, data: { confirm: 'All plantings associated with this garden will also be deleted. Are you sure?' }, - class: 'btn btn-default btn-xs', id: 'delete_garden_link' do + class: 'btn btn-default', id: 'delete_garden_link' do %span.glyphicon.glyphicon-trash{ title: "Delete" } - Delete + = t('buttons.delete_this_garden') From d418745e872a39ceda27826e69d1df17f0937c1d Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Tue, 22 Jan 2019 15:19:24 +1300 Subject: [PATCH 086/207] Moving buttons to the right of page (with translations) --- app/helpers/buttons_helper.rb | 66 ++++++++++++++++++++++ app/views/crops/_actions.html.haml | 9 ++- app/views/crops/_wrangle.html.haml | 14 +++-- app/views/gardens/_actions.html.haml | 25 ++------ app/views/layouts/application.html.haml | 11 ++-- app/views/plantings/_actions.html.haml | 17 +++--- app/views/shared/_global_actions.html.haml | 24 ++++++-- app/views/shared/_glyphicon.html.haml | 3 +- config/locales/en.yml | 36 ++++++++---- 9 files changed, 144 insertions(+), 61 deletions(-) create mode 100644 app/helpers/buttons_helper.rb diff --git a/app/helpers/buttons_helper.rb b/app/helpers/buttons_helper.rb new file mode 100644 index 000000000..4dbf7015a --- /dev/null +++ b/app/helpers/buttons_helper.rb @@ -0,0 +1,66 @@ +module ButtonsHelper + def garden_plant_something_button(garden) + button(new_planting_path(garden_id: garden.id), 'buttons.plant_something_here', 'leaf') + end + + def garden_mark_active(garden) + link_to t('buttons.mark_as_active'), garden_path(garden, garden: { active: 1 }), method: :put, class: 'btn btn-default btn-xs' + end + + def garden_mark_inactive(garden) + link_to t('buttons.mark_as_inactive'), + garden_path(garden, garden: { active: 0 }), + method: :put, class: 'btn btn-default btn-xs', + data: { confirm: 'All plantings associated with this garden will be marked as finished. Are you sure?' } + end + + def garden_add_photo_button(garden) + button(new_photo_path(id: garden.id, type: "garden"), 'buttons.add_a_photo', 'camera') + end + + def garden_edit_button(garden) + button(edit_garden_path(garden), 'buttons.edit', 'pencil') + end + + def planting_edit_button(planting) + button(edit_planting_path(planting), 'buttons.edit', 'pencil') + end + + def planting_add_photo_button(planting) + button(new_photo_path(id: planting.id, type: 'planting'), 'buttons.add_photo', 'camera') + end + + def planting_finish_button(planting) + if can?(:edit, planting) + button( + planting_path(planting, planting: { finished: 1 }), + 'buttons.mark_as_finished', + 'ok' + ) + end + end + + def planting_harvest_button(planting) + if planting.active? && can?(:create, Harvest) && can?(:edit, planting) + button(new_planting_harvest_path(planting), 'buttons.harvest', 'apple') + end + end + + def planting_save_seeds_button(planting) + button(new_planting_seed_path(planting), 'buttons.save_seeds', 'heart') if can?(:edit, planting) + end + + def delete_button(model, message: 'are_you_sure') + link_to model, method: :delete, data: { confirm: t(message) }, class: 'btn btn-default btn-xs' do + render 'shared/glyphicon', icon: 'trash', title: 'buttons.delete' + end + end + + private + + def button(path, title, icon, size = 'btn-xs') + link_to path, class: "btn btn-default #{size}" do + render 'shared/glyphicon', icon: icon, title: title + end + end +end diff --git a/app/views/crops/_actions.html.haml b/app/views/crops/_actions.html.haml index b27f4b89a..5cc80036b 100644 --- a/app/views/crops/_actions.html.haml +++ b/app/views/crops/_actions.html.haml @@ -1,10 +1,13 @@ .crop-actions .btn-group - if can? :create, Planting - = link_to t('buttons.plant_crop', crop_name: crop.name), new_planting_path(crop_id: crop.id), class: 'btn btn-default' + = link_to new_planting_path(crop_id: crop.id), class: 'btn btn-default' do + = t('buttons.plant_crop', crop_name: crop.name) - if can? :create, Harvest - = link_to t('buttons.harvest_crop', crop_name: crop.name), new_harvest_path(crop_id: crop.id), class: 'btn btn-default' + = link_to new_harvest_path(crop_id: crop.id), class: 'btn btn-default' do + = t('buttons.harvest_crop', crop_name: crop.name) - if can? :create, Seed - = link_to t('buttons.add_seed_to_stash'), new_seed_path(params: { crop_id: crop.id }), class: 'btn btn-default' + = link_to new_seed_path(crop_id: crop.id), class: 'btn btn-default' do + = t('buttons.add_seed_to_stash', crop_name: crop.name) diff --git a/app/views/crops/_wrangle.html.haml b/app/views/crops/_wrangle.html.haml index 16b7ed23b..fafafd490 100644 --- a/app/views/crops/_wrangle.html.haml +++ b/app/views/crops/_wrangle.html.haml @@ -4,11 +4,13 @@ You are a = succeed "." do %strong CROP WRANGLER - - content_for(:buttonbar) do - - if can? :edit, crop + + - if can? :edit, crop + %p = link_to t(:edit_crop), edit_crop_path(crop), class: 'btn btn-default' - - if can? :destroy, crop + - if can? :destroy, crop + %p = link_to 'Delete crop', crop, - method: :delete, - data: { confirm: t('are_you_sure') }, - class: 'btn btn-default' + method: :delete, + data: { confirm: t('are_you_sure') }, + class: 'btn btn-default' diff --git a/app/views/gardens/_actions.html.haml b/app/views/gardens/_actions.html.haml index 5ff23e09a..54842b577 100644 --- a/app/views/gardens/_actions.html.haml +++ b/app/views/gardens/_actions.html.haml @@ -2,29 +2,16 @@ - if can?(:edit, garden) .btn-group - if garden.active - = render 'shared/buttons/plant', garden: garden - = render 'shared/glyphicon', icon: 'ban', title: 'buttons.mark_as_inactive' - = link_to t('buttons.mark_as_inactive'), garden_path(garden, garden: { active: 0 }), - method: :put, class: 'btn btn-default', - data: { confirm: 'All plantings associated with this garden will be marked as finished. Are you sure?' } + = garden_plant_something_button(garden) + = garden_mark_inactive(garden) - else - = render 'shared/glyphicon', icon: 'check', title: 'buttons.mark_active' - = link_to "Mark as active", garden_path(garden, garden: { active: 1 }), - method: :put + = garden_mark_active(garden) - = render 'shared/buttons/edit', path: edit_garden_path(garden) + = garden_edit_button(garden) - if can?(:edit, garden) && can?(:create, Photo) - = link_to new_photo_path(type: "garden", id: garden.id), - class: 'btn btn-default' do - %span.glyphicon.glyphicon-camera{ title: "Add photo" } - = t('buttons.add_a_photo') + = garden_add_photo_button(garden) - if can?(:destroy, garden) .pull-right - = link_to garden_path(garden), - method: :delete, - data: { confirm: 'All plantings associated with this garden will also be deleted. Are you sure?' }, - class: 'btn btn-default', id: 'delete_garden_link' do - %span.glyphicon.glyphicon-trash{ title: "Delete" } - = t('buttons.delete_this_garden') + = delete_button(garden, message: 'All plantings associated with this garden will also be deleted. Are you sure?') diff --git a/app/views/layouts/application.html.haml b/app/views/layouts/application.html.haml index 2b1c2e982..3ac9f7cf6 100644 --- a/app/views/layouts/application.html.haml +++ b/app/views/layouts/application.html.haml @@ -14,15 +14,14 @@ = yield(:title) - if content_for?(:subtitle) %small= yield(:subtitle) - - + + - if content_for?(:buttonbar) + .btn-group.layout-actions + = yield(:buttonbar) .col-md-4 - - if content_for?(:buttonbar) - .btn-group.layout-actions= yield(:buttonbar) - - else - = render 'shared/global_actions' + = render 'shared/global_actions' = yield %footer diff --git a/app/views/plantings/_actions.html.haml b/app/views/plantings/_actions.html.haml index 6f5b1b93d..ca3fceefc 100644 --- a/app/views/plantings/_actions.html.haml +++ b/app/views/plantings/_actions.html.haml @@ -1,12 +1,13 @@ - if can?(:edit, planting) - .btn-group.planting-actions - = render 'shared/buttons/edit', path: edit_planting_path(planting) - = render 'shared/buttons/add_photo', path: new_photo_path(id: planting.id, type: 'planting') + .planting-actions + .btn-group + = planting_edit_button(planting) + = planting_add_photo_button(planting) - - if planting.active? - = render 'shared/buttons/finish_planting', planting: planting - = render 'shared/buttons/harvest_planting', planting: planting - = render 'shared/buttons/save_seeds', planting: planting + - if planting.active? + = planting_finish_button(planting) + = planting_harvest_button(planting) + = planting_save_seeds_button(planting) - if can? :destroy, planting - = render 'shared/buttons/delete', path: planting + = delete_button(planting) diff --git a/app/views/shared/_global_actions.html.haml b/app/views/shared/_global_actions.html.haml index 2b5ca1168..29b2f1ef3 100644 --- a/app/views/shared/_global_actions.html.haml +++ b/app/views/shared/_global_actions.html.haml @@ -1,7 +1,19 @@ -.btn-group - = link_to t('buttons.plant_something'), new_planting_path, class: 'btn btn-default' - = link_to t('buttons.harvest_something'), new_harvest_path, class: 'btn btn-default' - = link_to t('buttons.save_seeds'), new_seed_path, class: 'btn btn-default' +- if signed_in? + .global-actions + .btn-group + = link_to gardens_by_owner_path(owner: current_member.slug), class: 'btn btn-default' do + = t('links.my_gardens') -.btn-group - = link_to t('buttons.write_blog_post'), new_post_path, class: 'btn btn-default' + .btn-group + = link_to new_planting_path, class: 'btn btn-default' do + = t('buttons.plant') + = link_to new_harvest_path, class: 'btn btn-default' do + = t('buttons.harvest') + = link_to new_seed_path, class: 'btn btn-default' do + = t('buttons.save_seeds') + + .btn-group + = link_to t('buttons.write_blog_post'), new_post_path, class: 'btn btn-default' + +- content_for(:attributions) do + seed by Template from the Noun Project \ No newline at end of file diff --git a/app/views/shared/_glyphicon.html.haml b/app/views/shared/_glyphicon.html.haml index dd34405cc..65cba2bdd 100644 --- a/app/views/shared/_glyphicon.html.haml +++ b/app/views/shared/_glyphicon.html.haml @@ -1 +1,2 @@ -%span.glyphicon{class: "glyphicon-#{icon}", title: t(title) } \ No newline at end of file +%span.glyphicon{class: "glyphicon-#{icon}", title: t(title) } +=t(title) \ No newline at end of file diff --git a/config/locales/en.yml b/config/locales/en.yml index 17a7acc36..d850060b2 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -63,17 +63,27 @@ en: seed: one: seed other: seeds - are_you_sure: 'Are you sure?' + application_helper: + title: + title: + default: Default + are_you_sure: Are you sure? buttons: + add: Add add_photo: Add photo + add_seed_to_stash: Add %{crop_name} seeds to stash delete: Delete edit: Edit harvest: Harvest harvest_crop: Harvest %{crop_name} harvest_something: Harvest something + mark_as_active: Mark as active mark_as_finished: Mark as finished - plant_something: Plant something + mark_as_inactive: Mark as inactive + plant: Plant plant_crop: Plant %{crop_name} + plant_something: Plant something + plant_something_here: Plant something here save_seeds: Save seeds write_blog_post: Write blog post crops: @@ -84,6 +94,7 @@ en: link: You have %{number_crops} crops awaiting approval subtitle: Pending approval title: Requested crops + edit_crop: Edit crop forms: optional: "(Optional)" forums: @@ -95,28 +106,25 @@ en: form: location_helper: If you have a location set in your profile, it will be used when you create a new garden. location: "%{owner}'s %{garden}" - updated: Garden was successfully updated. overview: - gardensphoto: gardens/photo - plantingsthumbnail: plantings/thumbnail - no_plantings: no plantings gardensactions: gardens/actions + gardensphoto: gardens/photo + no_plantings: no plantings + plantingsthumbnail: plantings/thumbnail + updated: Garden was successfully updated. harvests: created: Harvest was successfully created. index: title: crop_harvests: Everyone's %{crop} harvests - planting_harvests: Harvests from %{planting} default: Everyone's harvests owner_harvests: "%{owner} harvests" + planting_harvests: Harvests from %{planting} updated: Harvest was successfully updated. home: blurb: already_html: Or %{sign_in} if you already have an account - intro: > - %{site_name} is a community of food gardeners. We're building an open source - platform to help you learn about growing food, track what you plant and harvest, - and swap seeds and produce with other gardeners near you. + intro: "%{site_name} is a community of food gardeners. We're building an open source platform to help you learn about growing food, track what you plant and harvest, and swap seeds and produce with other gardeners near you.\n" perks: Join now for your free garden journal, seed sharing, forums, and more. sign_in_linktext: sign in sign_up: Sign up @@ -135,6 +143,7 @@ en: harvest: Harvest plant: Plant post: Post + recently_added: Recently added welcome: Welcome to %{site_name}, %{member_name} members: title: Some of our members @@ -164,6 +173,8 @@ en: talk_linktext: Growstuff Talk why_linktext: why Growstuff is open source wiki_linktext: Growstuff Wiki + plantings: + recently_planted: Recently planted seeds: crop: Crop description: Description @@ -208,6 +219,8 @@ en: support_growstuff: Support Growstuff toggle_navigation: Toggle Navigation your_stuff: Your Stuff (%{unread_count}) + links: + my_gardens: My gardens members: index: title: "%{site_name} members" @@ -250,7 +263,6 @@ en: badges: late_finishing: late finishing super_late: super late - sharedbuttonsfinish_planting: shared/buttons/finish_planting days_until_finished: days until finished harvesting_now: harvesting now days_until_harvest: days until harvest From 90b0d0956e205651a103e5e47e31b5aa7831ff32 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Tue, 22 Jan 2019 15:55:41 +1300 Subject: [PATCH 087/207] Titles of pages consistent with buttons to pages --- app/views/harvests/new.html.haml | 2 +- app/views/plantings/new.html.haml | 2 +- app/views/posts/new.html.haml | 2 +- app/views/seeds/new.html.haml | 2 +- config/locales/en.yml | 4 ++++ 5 files changed, 8 insertions(+), 4 deletions(-) diff --git a/app/views/harvests/new.html.haml b/app/views/harvests/new.html.haml index 5b5004622..f3a9dbe75 100644 --- a/app/views/harvests/new.html.haml +++ b/app/views/harvests/new.html.haml @@ -1,3 +1,3 @@ -- content_for :title, "New Harvest" +- content_for :title, t('harvests.harvest_something') = render 'form' diff --git a/app/views/plantings/new.html.haml b/app/views/plantings/new.html.haml index f28af6b19..c509e5646 100644 --- a/app/views/plantings/new.html.haml +++ b/app/views/plantings/new.html.haml @@ -1,3 +1,3 @@ -= content_for :title, "Plant something" += content_for :title, t('plantings.plant_something') = render 'form' diff --git a/app/views/posts/new.html.haml b/app/views/posts/new.html.haml index 75b111f6e..748c290b8 100644 --- a/app/views/posts/new.html.haml +++ b/app/views/posts/new.html.haml @@ -1,3 +1,3 @@ -= content_for :title, @forum ? "Post in #{@forum.name}" : "Post something" += content_for :title, @forum ? "Post in #{@forum.name}" : t('posts.write_blog_post') = render 'form' diff --git a/app/views/seeds/new.html.haml b/app/views/seeds/new.html.haml index 834c958d8..6a59b7050 100644 --- a/app/views/seeds/new.html.haml +++ b/app/views/seeds/new.html.haml @@ -1,3 +1,3 @@ -- content_for :title, "Add seeds" +- content_for :title, t('seeds.save_seeds') = render 'form' diff --git a/config/locales/en.yml b/config/locales/en.yml index d850060b2..850492e09 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -114,6 +114,7 @@ en: updated: Garden was successfully updated. harvests: created: Harvest was successfully created. + harvest_something: Harvest something index: title: crop_harvests: Everyone's %{crop} harvests @@ -248,6 +249,7 @@ en: late_finishing: late finishing sharedbuttonsfinish_planting: shared/buttons/finish_planting super_late: super late + plant_something: Plant something form: finish_helper: > A planting is finished when you've harvested all of the crop, or it dies, or it's otherwise @@ -269,6 +271,7 @@ en: progress: progress_0_not_planted_yet: 'Progress: 0% - not planted yet' posts: + write_blog_post: Write blog post index: title: author_posts: "%{author} posts" @@ -284,6 +287,7 @@ en: crop_seeds: Everyone's %{crop} seeds default: Everyone's seeds owner_seeds: "%{owner} seeds" + save_seeds: Save seeds string: "%{crop} seeds belonging to %{owner}" unauthorized: create: From 8ead646bf9b4050df38780598662a3186903a323 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Tue, 22 Jan 2019 16:46:44 +1300 Subject: [PATCH 088/207] Use same t() for the button for writing blog posts --- app/views/shared/_global_actions.html.haml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/shared/_global_actions.html.haml b/app/views/shared/_global_actions.html.haml index 29b2f1ef3..771033c8a 100644 --- a/app/views/shared/_global_actions.html.haml +++ b/app/views/shared/_global_actions.html.haml @@ -13,7 +13,7 @@ = t('buttons.save_seeds') .btn-group - = link_to t('buttons.write_blog_post'), new_post_path, class: 'btn btn-default' + = link_to t('posts.write_blog_post'), new_post_path, class: 'btn btn-default' - content_for(:attributions) do seed by Template from the Noun Project \ No newline at end of file From 72c957967d8fe91c5f7845e1942d6ff890a55669 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Tue, 22 Jan 2019 16:48:57 +1300 Subject: [PATCH 089/207] Rubocop fix ups --- app/helpers/buttons_helper.rb | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/app/helpers/buttons_helper.rb b/app/helpers/buttons_helper.rb index 4dbf7015a..f6fe45346 100644 --- a/app/helpers/buttons_helper.rb +++ b/app/helpers/buttons_helper.rb @@ -4,7 +4,9 @@ module ButtonsHelper end def garden_mark_active(garden) - link_to t('buttons.mark_as_active'), garden_path(garden, garden: { active: 1 }), method: :put, class: 'btn btn-default btn-xs' + link_to t('buttons.mark_as_active'), + garden_path(garden, garden: { active: 1 }), + method: :put, class: 'btn btn-default btn-xs' end def garden_mark_inactive(garden) @@ -31,19 +33,19 @@ module ButtonsHelper end def planting_finish_button(planting) - if can?(:edit, planting) - button( - planting_path(planting, planting: { finished: 1 }), - 'buttons.mark_as_finished', - 'ok' - ) - end + return unless can?(:edit, planting) + + button( + planting_path(planting, planting: { finished: 1 }), + 'buttons.mark_as_finished', + 'ok' + ) end def planting_harvest_button(planting) - if planting.active? && can?(:create, Harvest) && can?(:edit, planting) - button(new_planting_harvest_path(planting), 'buttons.harvest', 'apple') - end + return unless planting.active? && can?(:create, Harvest) && can?(:edit, planting) + + button(new_planting_harvest_path(planting), 'buttons.harvest', 'apple') end def planting_save_seeds_button(planting) From 57bcac8b02b7a1f8f1eddb5ff9bba3402265b3c7 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Tue, 22 Jan 2019 16:54:25 +1300 Subject: [PATCH 090/207] Update link label in spec --- spec/features/seeds/misc_seeds_spec.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spec/features/seeds/misc_seeds_spec.rb b/spec/features/seeds/misc_seeds_spec.rb index e095ed390..941d25f00 100644 --- a/spec/features/seeds/misc_seeds_spec.rb +++ b/spec/features/seeds/misc_seeds_spec.rb @@ -21,10 +21,10 @@ feature "seeds", js: true do describe "button on front page to add seeds" do before do visit root_path - click_link "Add seeds" + click_link "Save seeds" end it { expect(current_path).to eq new_seed_path } - it { expect(page).to have_content 'Add seeds' } + it { expect(page).to have_content 'Save seeds' } end describe "Clicking link to owner's profile" do From 1809ca274621ab3b311ab1fb531fe7bd056c9f1b Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Tue, 22 Jan 2019 16:54:54 +1300 Subject: [PATCH 091/207] Seperate specs --- spec/features/gardens/actions_spec.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/spec/features/gardens/actions_spec.rb b/spec/features/gardens/actions_spec.rb index a22ab6886..0f4545714 100644 --- a/spec/features/gardens/actions_spec.rb +++ b/spec/features/gardens/actions_spec.rb @@ -46,9 +46,9 @@ feature "Gardens" do before { visit gardens_path(owner: FactoryBot.create(:member)) } include_examples "has buttons bar at top" - it 'does not show actions on other member garden' do - is_expected.not_to have_link 'Plant something' - is_expected.not_to have_link 'Mark as inactive' + describe 'does not show actions on other member garden' do + it { is_expected.not_to have_link 'Plant something' } + it { is_expected.not_to have_link 'Mark as inactive' } end end end From adf3853c0930f75209246fe17e8ce062e70aa5e8 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Tue, 22 Jan 2019 16:58:13 +1300 Subject: [PATCH 092/207] suffix _button to button helpers --- app/helpers/buttons_helper.rb | 4 ++-- app/views/gardens/_actions.html.haml | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/helpers/buttons_helper.rb b/app/helpers/buttons_helper.rb index f6fe45346..b3ed95a25 100644 --- a/app/helpers/buttons_helper.rb +++ b/app/helpers/buttons_helper.rb @@ -3,13 +3,13 @@ module ButtonsHelper button(new_planting_path(garden_id: garden.id), 'buttons.plant_something_here', 'leaf') end - def garden_mark_active(garden) + def garden_mark_active_button(garden) link_to t('buttons.mark_as_active'), garden_path(garden, garden: { active: 1 }), method: :put, class: 'btn btn-default btn-xs' end - def garden_mark_inactive(garden) + def garden_mark_inactive_button(garden) link_to t('buttons.mark_as_inactive'), garden_path(garden, garden: { active: 0 }), method: :put, class: 'btn btn-default btn-xs', diff --git a/app/views/gardens/_actions.html.haml b/app/views/gardens/_actions.html.haml index 54842b577..656bc0b58 100644 --- a/app/views/gardens/_actions.html.haml +++ b/app/views/gardens/_actions.html.haml @@ -3,9 +3,9 @@ .btn-group - if garden.active = garden_plant_something_button(garden) - = garden_mark_inactive(garden) + = garden_mark_inactive_button(garden) - else - = garden_mark_active(garden) + = garden_mark_active_button(garden) = garden_edit_button(garden) From 431572a77ab772d144619612657a0150ecab2051 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Tue, 22 Jan 2019 17:03:34 +1300 Subject: [PATCH 093/207] Removed un-used viewss --- app/views/shared/buttons/_harvest_planting.haml | 4 ---- app/views/shared/buttons/_plant.html.haml | 3 --- app/views/shared/buttons/_save_seeds.haml | 4 ---- 3 files changed, 11 deletions(-) delete mode 100644 app/views/shared/buttons/_harvest_planting.haml delete mode 100644 app/views/shared/buttons/_plant.html.haml delete mode 100644 app/views/shared/buttons/_save_seeds.haml diff --git a/app/views/shared/buttons/_harvest_planting.haml b/app/views/shared/buttons/_harvest_planting.haml deleted file mode 100644 index 296ee30a0..000000000 --- a/app/views/shared/buttons/_harvest_planting.haml +++ /dev/null @@ -1,4 +0,0 @@ -- planting.active? && if can?(:create, Harvest) && can?(:edit, planting) - = link_to new_planting_harvest_path(planting), class: 'btn btn-default btn-xs' do - = render 'shared/glyphicon', icon: 'leaf', title: 'buttons.harvest' - = t('buttons.harvest') diff --git a/app/views/shared/buttons/_plant.html.haml b/app/views/shared/buttons/_plant.html.haml deleted file mode 100644 index 8044dddef..000000000 --- a/app/views/shared/buttons/_plant.html.haml +++ /dev/null @@ -1,3 +0,0 @@ -= link_to new_planting_path(garden_id: garden.id), class: 'btn btn-default' do - = render 'shared/glyphicon', icon: 'grain', title: 'buttons.plant' - = t('buttons.plant_something_here') \ No newline at end of file diff --git a/app/views/shared/buttons/_save_seeds.haml b/app/views/shared/buttons/_save_seeds.haml deleted file mode 100644 index d4cf794f5..000000000 --- a/app/views/shared/buttons/_save_seeds.haml +++ /dev/null @@ -1,4 +0,0 @@ -- if planting.active? - = link_to new_planting_seed_path(planting), class: 'btn btn-default btn-xs' do - = render 'shared/glyphicon', icon: 'heart', title: 'buttons.save_seeds' - = t('buttons.save_seeds') From dc4292f94870c6edc69339f53c7825710144bc11 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Tue, 22 Jan 2019 17:11:22 +1300 Subject: [PATCH 094/207] Moved harvest buttons to match other #show pages --- app/views/harvests/show.html.haml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/views/harvests/show.html.haml b/app/views/harvests/show.html.haml index a584389fe..c2c773819 100644 --- a/app/views/harvests/show.html.haml +++ b/app/views/harvests/show.html.haml @@ -8,6 +8,9 @@ = tag("meta", property: "og:url", content: request.original_url) = tag("meta", property: "og:site_name", content: ENV['GROWSTUFF_SITE_NAME']) +-content_for(:buttonbar) do + = render 'harvests/actions', harvest: @harvest + .row .col-md-6 %p @@ -32,7 +35,6 @@ %b Quantity: = display_quantity(@harvest) - = render 'harvests/actions', harvest: @harvest .col-md-6 = render partial: "crops/index_card", locals: { crop: @harvest.crop } From 01a7b7fd3794364e2cfb5d97e67081a6059e88f9 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Tue, 22 Jan 2019 17:11:30 +1300 Subject: [PATCH 095/207] Added missing harvest actions --- app/helpers/buttons_helper.rb | 8 ++++++++ app/views/harvests/_actions.html.haml | 10 ++++------ 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/app/helpers/buttons_helper.rb b/app/helpers/buttons_helper.rb index b3ed95a25..89b3c95e6 100644 --- a/app/helpers/buttons_helper.rb +++ b/app/helpers/buttons_helper.rb @@ -1,4 +1,12 @@ module ButtonsHelper + def harvest_add_photo_button(harvest) + button(new_photo_path(id: harvest.id, type: "harvest"), 'buttons.add_a_photo', 'camera') + end + + def harvest_edit_button(harvest) + button(edit_harvest_path(harvest), 'buttons.edit', 'pencil') + end + def garden_plant_something_button(garden) button(new_planting_path(garden_id: garden.id), 'buttons.plant_something_here', 'leaf') end diff --git a/app/views/harvests/_actions.html.haml b/app/views/harvests/_actions.html.haml index 2ebfbc8f9..a86cbdb18 100644 --- a/app/views/harvests/_actions.html.haml +++ b/app/views/harvests/_actions.html.haml @@ -1,7 +1,5 @@ .harvest-actions - - if can?(:edit, harvest) || can?(:destroy, harvest) - .btn-group - - if can? :edit, harvest - = render 'shared/buttons/edit', path: edit_harvest_path(harvest) - - if can? :destroy, harvest - .pull-right= render 'shared/buttons/delete', path: harvest_path(harvest) + .btn-group + = harvest_edit_button(harvest) if can? :edit, harvest + = harvest_add_photo_button(harvest) + = delete_button(harvest) if can? :destroy, harvest From a2b9a36615007b35f9305e5d0bbfc17953a22eef Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Tue, 22 Jan 2019 17:11:50 +1300 Subject: [PATCH 096/207] Moved garden actions code to top of view --- app/views/gardens/show.html.haml | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/app/views/gardens/show.html.haml b/app/views/gardens/show.html.haml index b71f09c78..2c8ec76d6 100644 --- a/app/views/gardens/show.html.haml +++ b/app/views/gardens/show.html.haml @@ -14,12 +14,11 @@ = javascript_include_tag "charts" = javascript_include_tag "https://www.gstatic.com/charts/loader.js" +-content_for(:buttonbar) do + = render 'gardens/actions', garden: @garden + .row .col-md-9 - -content_for(:buttonbar) do - = render 'gardens/actions', garden: @garden - - - unless @garden.active .alert.alert-warning This garden is inactive. From e1bc635b0414c34d7f52d1183b2d716fbb7cb60e Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Tue, 22 Jan 2019 17:15:25 +1300 Subject: [PATCH 097/207] Move seed buttongs to buttons helper --- app/helpers/buttons_helper.rb | 8 ++++++++ app/views/seeds/_actions.html.haml | 7 +++---- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/app/helpers/buttons_helper.rb b/app/helpers/buttons_helper.rb index 89b3c95e6..c1121a04f 100644 --- a/app/helpers/buttons_helper.rb +++ b/app/helpers/buttons_helper.rb @@ -1,4 +1,12 @@ module ButtonsHelper + def seed_add_photo_button(seed) + button(new_photo_path(id: seed.id, type: "seed"), 'buttons.add_a_photo', 'camera') + end + + def seed_edit_button(seed) + button(edit_seed_path(seed), 'buttons.edit', 'pencil') + end + def harvest_add_photo_button(harvest) button(new_photo_path(id: harvest.id, type: "harvest"), 'buttons.add_a_photo', 'camera') end diff --git a/app/views/seeds/_actions.html.haml b/app/views/seeds/_actions.html.haml index 6e1cef334..ea731c16b 100644 --- a/app/views/seeds/_actions.html.haml +++ b/app/views/seeds/_actions.html.haml @@ -1,8 +1,8 @@ .seed-actions - if can? :edit, seed .btn-group - = render 'shared/buttons/edit', path: edit_seed_path(seed) - = render 'shared/buttons/add_photo', path: new_photo_path(id: seed.id, type: 'seed') + = seed_edit_button(seed) + = seed_add_photo_button(seed) - if can?(:create, Planting) && seed.active? = link_to new_planting_path(seed_id: seed), class: 'btn btn-default btn-xs' do @@ -11,5 +11,4 @@ = render 'shared/buttons/finish_seeds', seed: seed - - if can? :destroy, seed - = render 'shared/buttons/delete', path: seed + = delete_button(seed) if can? :destroy, seed From 0350d634c67ec4d0087ddbc34362d302c83f3c87 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Tue, 22 Jan 2019 17:20:34 +1300 Subject: [PATCH 098/207] DRY the edit buttons --- app/helpers/buttons_helper.rb | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/app/helpers/buttons_helper.rb b/app/helpers/buttons_helper.rb index c1121a04f..206322dab 100644 --- a/app/helpers/buttons_helper.rb +++ b/app/helpers/buttons_helper.rb @@ -2,18 +2,10 @@ module ButtonsHelper def seed_add_photo_button(seed) button(new_photo_path(id: seed.id, type: "seed"), 'buttons.add_a_photo', 'camera') end - - def seed_edit_button(seed) - button(edit_seed_path(seed), 'buttons.edit', 'pencil') - end def harvest_add_photo_button(harvest) button(new_photo_path(id: harvest.id, type: "harvest"), 'buttons.add_a_photo', 'camera') end - - def harvest_edit_button(harvest) - button(edit_harvest_path(harvest), 'buttons.edit', 'pencil') - end def garden_plant_something_button(garden) button(new_planting_path(garden_id: garden.id), 'buttons.plant_something_here', 'leaf') @@ -35,13 +27,21 @@ module ButtonsHelper def garden_add_photo_button(garden) button(new_photo_path(id: garden.id, type: "garden"), 'buttons.add_a_photo', 'camera') end + + def seed_edit_button(seed) + edit_button(edit_seed_path(seed)) + end + + def harvest_edit_button(harvest) + edit_button(edit_harvest_path(harvest)) + end def garden_edit_button(garden) - button(edit_garden_path(garden), 'buttons.edit', 'pencil') + edit_button(edit_garden_path(garden)) end def planting_edit_button(planting) - button(edit_planting_path(planting), 'buttons.edit', 'pencil') + edit_button(edit_planting_path(planting)) end def planting_add_photo_button(planting) @@ -68,6 +68,10 @@ module ButtonsHelper button(new_planting_seed_path(planting), 'buttons.save_seeds', 'heart') if can?(:edit, planting) end + def edit_button(path) + button(path, 'buttons.edit', 'pencil') + end + def delete_button(model, message: 'are_you_sure') link_to model, method: :delete, data: { confirm: t(message) }, class: 'btn btn-default btn-xs' do render 'shared/glyphicon', icon: 'trash', title: 'buttons.delete' From f7eaf90b770727aaceae961cfb17259a5dddd560 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Tue, 22 Jan 2019 17:20:52 +1300 Subject: [PATCH 099/207] Update labels on button in crop detail spec --- spec/features/crops/crop_detail_page_spec.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/spec/features/crops/crop_detail_page_spec.rb b/spec/features/crops/crop_detail_page_spec.rb index cbc73cf9c..523770bcb 100644 --- a/spec/features/crops/crop_detail_page_spec.rb +++ b/spec/features/crops/crop_detail_page_spec.rb @@ -105,13 +105,13 @@ feature "crop detail page", js: true do background { subject } scenario "has a link to plant the crop" do - expect(page).to have_link "Plant this", href: new_planting_path(crop_id: crop.id) + expect(page).to have_link "Plant #{crop.name}", href: new_planting_path(crop_id: crop.id) end scenario "has a link to harvest the crop" do - expect(page).to have_link "Harvest this", href: new_harvest_path(crop_id: crop.id) + expect(page).to have_link "Harvest #{crop.name}", href: new_harvest_path(crop_id: crop.id) end scenario "has a link to add seeds" do - expect(page).to have_link "Add seeds to stash", href: new_seed_path(crop_id: crop.id) + expect(page).to have_link "Add #{crop.name} seeds to stash", href: new_seed_path(crop_id: crop.id) end end From a5d1303918129004f52460ade20c7c7da814cf1f Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Wed, 23 Jan 2019 08:03:57 +1300 Subject: [PATCH 100/207] DRY the add photo buttons --- app/helpers/buttons_helper.rb | 33 +++++++++++++------------- app/views/gardens/_actions.html.haml | 4 +--- app/views/harvests/_actions.html.haml | 4 ++-- app/views/plantings/_actions.html.haml | 2 +- app/views/seeds/_actions.html.haml | 2 +- 5 files changed, 21 insertions(+), 24 deletions(-) diff --git a/app/helpers/buttons_helper.rb b/app/helpers/buttons_helper.rb index 206322dab..994265adc 100644 --- a/app/helpers/buttons_helper.rb +++ b/app/helpers/buttons_helper.rb @@ -1,12 +1,4 @@ module ButtonsHelper - def seed_add_photo_button(seed) - button(new_photo_path(id: seed.id, type: "seed"), 'buttons.add_a_photo', 'camera') - end - - def harvest_add_photo_button(harvest) - button(new_photo_path(id: harvest.id, type: "harvest"), 'buttons.add_a_photo', 'camera') - end - def garden_plant_something_button(garden) button(new_planting_path(garden_id: garden.id), 'buttons.plant_something_here', 'leaf') end @@ -24,14 +16,10 @@ module ButtonsHelper data: { confirm: 'All plantings associated with this garden will be marked as finished. Are you sure?' } end - def garden_add_photo_button(garden) - button(new_photo_path(id: garden.id, type: "garden"), 'buttons.add_a_photo', 'camera') - end - def seed_edit_button(seed) edit_button(edit_seed_path(seed)) end - + def harvest_edit_button(harvest) edit_button(edit_harvest_path(harvest)) end @@ -44,10 +32,6 @@ module ButtonsHelper edit_button(edit_planting_path(planting)) end - def planting_add_photo_button(planting) - button(new_photo_path(id: planting.id, type: 'planting'), 'buttons.add_photo', 'camera') - end - def planting_finish_button(planting) return unless can?(:edit, planting) @@ -68,11 +52,22 @@ module ButtonsHelper button(new_planting_seed_path(planting), 'buttons.save_seeds', 'heart') if can?(:edit, planting) end + # Generic buttons (works out which model) + def add_photo_button(model) + return unless can?(:edit, model) && can?(:create, Photo) + + button( + new_photo_path(id: model.id, type: model_type_for_photo(model)), + 'buttons.add_a_photo', 'camera') + end + + def edit_button(path) button(path, 'buttons.edit', 'pencil') end def delete_button(model, message: 'are_you_sure') + return unless can? :destroy, model link_to model, method: :delete, data: { confirm: t(message) }, class: 'btn btn-default btn-xs' do render 'shared/glyphicon', icon: 'trash', title: 'buttons.delete' end @@ -80,6 +75,10 @@ module ButtonsHelper private + def model_type_for_photo(model) + ActiveModel::Name.new(model.class).to_s.downcase + end + def button(path, title, icon, size = 'btn-xs') link_to path, class: "btn btn-default #{size}" do render 'shared/glyphicon', icon: icon, title: title diff --git a/app/views/gardens/_actions.html.haml b/app/views/gardens/_actions.html.haml index 656bc0b58..67743037d 100644 --- a/app/views/gardens/_actions.html.haml +++ b/app/views/gardens/_actions.html.haml @@ -8,9 +8,7 @@ = garden_mark_active_button(garden) = garden_edit_button(garden) - - - if can?(:edit, garden) && can?(:create, Photo) - = garden_add_photo_button(garden) + = render 'shared/buttons/add_photo', model: garden - if can?(:destroy, garden) .pull-right diff --git a/app/views/harvests/_actions.html.haml b/app/views/harvests/_actions.html.haml index a86cbdb18..feabfbf96 100644 --- a/app/views/harvests/_actions.html.haml +++ b/app/views/harvests/_actions.html.haml @@ -1,5 +1,5 @@ .harvest-actions .btn-group = harvest_edit_button(harvest) if can? :edit, harvest - = harvest_add_photo_button(harvest) - = delete_button(harvest) if can? :destroy, harvest + = render 'shared/buttons/add_photo', model: harvest + = delete_button(harvest) diff --git a/app/views/plantings/_actions.html.haml b/app/views/plantings/_actions.html.haml index ca3fceefc..a8291089b 100644 --- a/app/views/plantings/_actions.html.haml +++ b/app/views/plantings/_actions.html.haml @@ -2,7 +2,7 @@ .planting-actions .btn-group = planting_edit_button(planting) - = planting_add_photo_button(planting) + = render 'shared/buttons/add_photo', model: planting - if planting.active? = planting_finish_button(planting) diff --git a/app/views/seeds/_actions.html.haml b/app/views/seeds/_actions.html.haml index ea731c16b..c801142a4 100644 --- a/app/views/seeds/_actions.html.haml +++ b/app/views/seeds/_actions.html.haml @@ -2,7 +2,7 @@ - if can? :edit, seed .btn-group = seed_edit_button(seed) - = seed_add_photo_button(seed) + = add_photo_button(seed) - if can?(:create, Planting) && seed.active? = link_to new_planting_path(seed_id: seed), class: 'btn btn-default btn-xs' do From 06eb01b7c5630732db13b62e90f005588cc98362 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Wed, 23 Jan 2019 08:04:06 +1300 Subject: [PATCH 101/207] Tests for edit and add photo buttons --- spec/helpers/buttons_helper_spec.rb | 33 +++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 spec/helpers/buttons_helper_spec.rb diff --git a/spec/helpers/buttons_helper_spec.rb b/spec/helpers/buttons_helper_spec.rb new file mode 100644 index 000000000..d3def8e00 --- /dev/null +++ b/spec/helpers/buttons_helper_spec.rb @@ -0,0 +1,33 @@ +require 'rails_helper' + +# Specs in this file have access to a helper object that includes +# the ButtonsHelper. For example: +# +# describe ButtonsHelper do +# describe "string concat" do +# it "concats two strings with spaces" do +# expect(helper.concat_strings("this","that")).to eq("this that") +# end +# end +# end +RSpec.describe ButtonsHelper, type: :helper do + before { allow(self).to receive(:can?) { true } } + let(:garden) { FactoryBot.create :garden } + let(:planting) { FactoryBot.create :planting } + let(:harvest) { FactoryBot.create :harvest } + let(:seed) { FactoryBot.create :seed } + + describe 'add_photo_button' do + it { expect(add_photo_button(garden)).to include "/photos/new?id=#{garden.id}&type=garden" } + it { expect(add_photo_button(planting)).to include "/photos/new?id=#{planting.id}&type=planting" } + it { expect(add_photo_button(harvest)).to include "/photos/new?id=#{harvest.id}&type=harvest" } + it { expect(add_photo_button(seed)).to include "/photos/new?id=#{seed.id}&type=seed" } + end + + describe 'edit_button' do + it { expect(garden_edit_button(garden)).to include "/gardens/#{garden.slug}/edit" } + it { expect(planting_edit_button(planting)).to include "/plantings/#{planting.slug}/edit" } + it { expect(harvest_edit_button(harvest)).to include "/harvests/#{harvest.slug}/edit" } + it { expect(seed_edit_button(seed)).to include "/seeds/#{seed.slug}/edit" } + end +end From c52e735a0be0391758abf804baf17356211739c2 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Wed, 23 Jan 2019 14:03:36 +1300 Subject: [PATCH 102/207] Move home page greeting test to features spec (from views) --- spec/features/home/home_spec.rb | 5 +++++ spec/views/home/index_spec.rb | 4 ---- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/spec/features/home/home_spec.rb b/spec/features/home/home_spec.rb index 3847d532b..d02bb619f 100644 --- a/spec/features/home/home_spec.rb +++ b/spec/features/home/home_spec.rb @@ -84,5 +84,10 @@ feature "home page" do include_examples 'show plantings' include_examples 'show harvests' include_examples 'shows seeds' + + describe 'should say welcome' do + before { visit root_path } + it { expect(page).to have_content "Welcome to #{ENV['GROWSTUFF_SITE_NAME']}, #{member.login_name}" } + end end end diff --git a/spec/views/home/index_spec.rb b/spec/views/home/index_spec.rb index 5e11882fd..4bc1e9c10 100644 --- a/spec/views/home/index_spec.rb +++ b/spec/views/home/index_spec.rb @@ -36,9 +36,5 @@ describe 'home/index.html.haml', type: "view" do controller.stub(:current_user) { @member } render end - - it 'should say welcome' do - rendered.should have_content "Welcome to #{ENV['GROWSTUFF_SITE_NAME']}, #{@member.login_name}" - end end end From 887886ebae43de4192b3bf35a42b2946e8e1e547 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Wed, 23 Jan 2019 14:04:48 +1300 Subject: [PATCH 103/207] Rubocop fixup --- app/helpers/buttons_helper.rb | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/app/helpers/buttons_helper.rb b/app/helpers/buttons_helper.rb index 994265adc..ea475fa05 100644 --- a/app/helpers/buttons_helper.rb +++ b/app/helpers/buttons_helper.rb @@ -58,16 +58,17 @@ module ButtonsHelper button( new_photo_path(id: model.id, type: model_type_for_photo(model)), - 'buttons.add_a_photo', 'camera') + 'buttons.add_a_photo', 'camera' + ) end - def edit_button(path) button(path, 'buttons.edit', 'pencil') end def delete_button(model, message: 'are_you_sure') return unless can? :destroy, model + link_to model, method: :delete, data: { confirm: t(message) }, class: 'btn btn-default btn-xs' do render 'shared/glyphicon', icon: 'trash', title: 'buttons.delete' end From a926b37ad984aecc038ee8edb684c1f7a0c2b90f Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Wed, 23 Jan 2019 14:07:39 +1300 Subject: [PATCH 104/207] Always use the helper for add_photo buttons --- app/views/gardens/_actions.html.haml | 2 +- app/views/harvests/_actions.html.haml | 2 +- app/views/plantings/_actions.html.haml | 2 +- app/views/plantings/_badges.html.haml | 39 ++++++++++++------------ app/views/shared/buttons/_add_photo.haml | 4 --- 5 files changed, 23 insertions(+), 26 deletions(-) delete mode 100644 app/views/shared/buttons/_add_photo.haml diff --git a/app/views/gardens/_actions.html.haml b/app/views/gardens/_actions.html.haml index 67743037d..3834d4787 100644 --- a/app/views/gardens/_actions.html.haml +++ b/app/views/gardens/_actions.html.haml @@ -8,7 +8,7 @@ = garden_mark_active_button(garden) = garden_edit_button(garden) - = render 'shared/buttons/add_photo', model: garden + = add_photo_button(garden) - if can?(:destroy, garden) .pull-right diff --git a/app/views/harvests/_actions.html.haml b/app/views/harvests/_actions.html.haml index feabfbf96..28a9aee77 100644 --- a/app/views/harvests/_actions.html.haml +++ b/app/views/harvests/_actions.html.haml @@ -1,5 +1,5 @@ .harvest-actions .btn-group = harvest_edit_button(harvest) if can? :edit, harvest - = render 'shared/buttons/add_photo', model: harvest + = add_photo_button(harvest) = delete_button(harvest) diff --git a/app/views/plantings/_actions.html.haml b/app/views/plantings/_actions.html.haml index a8291089b..3de6ce339 100644 --- a/app/views/plantings/_actions.html.haml +++ b/app/views/plantings/_actions.html.haml @@ -2,7 +2,7 @@ .planting-actions .btn-group = planting_edit_button(planting) - = render 'shared/buttons/add_photo', model: planting + = add_photo_button(planting) - if planting.active? = planting_finish_button(planting) diff --git a/app/views/plantings/_badges.html.haml b/app/views/plantings/_badges.html.haml index 2d690b914..e7ac1f6d3 100644 --- a/app/views/plantings/_badges.html.haml +++ b/app/views/plantings/_badges.html.haml @@ -1,20 +1,21 @@ -// Finish times -- if planting.finish_is_predicatable? - - if planting.super_late? - %span.badge.badge-super-late= t('.super_late') - = render 'shared/buttons/finish_planting', planting: planting - - elsif planting.late? - %span.badge.badge-late= t('.late_finishing') - - else - %span.badge - = days_from_now_to_finished(planting) - = t('.days_until_finished') +- unless planting.finished? + // Finish times + - if planting.finish_is_predicatable? + - if planting.super_late? + %span.badge.badge-super-late= t('.super_late') + = render 'shared/buttons/finish_planting', planting: planting + - elsif planting.late? + %span.badge.badge-late= t('.late_finishing') + - else + %span.badge + = days_from_now_to_finished(planting) + = t('.days_until_finished') -// Harvest times -- unless planting.super_late? - - if planting.harvest_time? - %span.badge.badge-harvest= t('.harvesting_now') - - elsif planting.before_harvest_time? - %span.badge - = days_from_now_to_first_harvest(planting) - = t('.days_until_harvest') + // Harvest times + - unless planting.super_late? + - if planting.harvest_time? + %span.badge.badge-harvest= t('.harvesting_now') + - elsif planting.before_harvest_time? + %span.badge + = days_from_now_to_first_harvest(planting) + = t('.days_until_harvest') diff --git a/app/views/shared/buttons/_add_photo.haml b/app/views/shared/buttons/_add_photo.haml deleted file mode 100644 index 0e4a75c07..000000000 --- a/app/views/shared/buttons/_add_photo.haml +++ /dev/null @@ -1,4 +0,0 @@ -- if can?(:create, Photo) - = link_to path, class: 'btn btn-default btn-xs' do - = render 'shared/glyphicon', icon: 'camera', title: 'buttons.add_photo' - =t('buttons.add_photo') From e5bb6fa15404687f0117afab3e69d212fbcd2de5 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Wed, 23 Jan 2019 14:33:48 +1300 Subject: [PATCH 105/207] Move some action button specs to feature specs because it's in a buttonbar, not the view now --- spec/features/gardens/actions_spec.rb | 5 +++++ spec/views/gardens/show.html.haml_spec.rb | 12 ------------ 2 files changed, 5 insertions(+), 12 deletions(-) diff --git a/spec/features/gardens/actions_spec.rb b/spec/features/gardens/actions_spec.rb index 0f4545714..18a339e09 100644 --- a/spec/features/gardens/actions_spec.rb +++ b/spec/features/gardens/actions_spec.rb @@ -54,6 +54,11 @@ feature "Gardens" do end describe '#show' do + before { visit garden_path(garden) } + it { is_expected.to have_link 'Edit' } + it { is_expected.to have_link 'Delete' } + it { is_expected.to have_content "Plant something here" } + it { is_expected.to have_content "Add photo" } end end diff --git a/spec/views/gardens/show.html.haml_spec.rb b/spec/views/gardens/show.html.haml_spec.rb index 5594c6755..0a3f813e8 100644 --- a/spec/views/gardens/show.html.haml_spec.rb +++ b/spec/views/gardens/show.html.haml_spec.rb @@ -42,18 +42,6 @@ describe "gardens/show" do render end - it 'should have an edit button' do - rendered.should have_link 'Edit' - end - - it "shows a 'plant something' button" do - rendered.should have_content "Plant something" - end - - it "shows an 'add photo' button" do - rendered.should have_content "Add photo" - end - it "links to the right crop in the planting link" do assert_select("a[href='#{new_planting_path}?garden_id=#{@garden.id}']") end From d980b9af4eb330f8cb284868cc9649c6e716bb1c Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Wed, 23 Jan 2019 14:36:36 +1300 Subject: [PATCH 106/207] Action specs for someone else's garden --- spec/features/gardens/actions_spec.rb | 36 ++++++++++++++++----------- 1 file changed, 22 insertions(+), 14 deletions(-) diff --git a/spec/features/gardens/actions_spec.rb b/spec/features/gardens/actions_spec.rb index 18a339e09..8468cec18 100644 --- a/spec/features/gardens/actions_spec.rb +++ b/spec/features/gardens/actions_spec.rb @@ -9,6 +9,7 @@ feature "Gardens" do background { login_as member } let(:garden) { member.gardens.first } + let(:other_member_garden) { FactoryBot.create :garden } describe '#index' do shared_examples "has buttons bar at top" do @@ -26,13 +27,11 @@ feature "Gardens" do include_examples "has buttons bar at top" it "has actions on garden" do - within '.garden-actions' do - is_expected.to have_link 'Plant something' - is_expected.to have_link 'Mark as inactive' - is_expected.to have_link 'Edit' - is_expected.to have_link 'Add photo' - is_expected.to have_link 'Delete' - end + is_expected.to have_link 'Plant something here' + is_expected.to have_link 'Mark as inactive' + is_expected.to have_link 'Edit' + is_expected.to have_link 'Add photo' + is_expected.to have_link 'Delete' end end @@ -47,18 +46,27 @@ feature "Gardens" do include_examples "has buttons bar at top" describe 'does not show actions on other member garden' do - it { is_expected.not_to have_link 'Plant something' } - it { is_expected.not_to have_link 'Mark as inactive' } + it { is_expected.not_to have_link 'Edit' } + it { is_expected.not_to have_link 'Delete' } end end end describe '#show' do - before { visit garden_path(garden) } - it { is_expected.to have_link 'Edit' } - it { is_expected.to have_link 'Delete' } - it { is_expected.to have_content "Plant something here" } - it { is_expected.to have_content "Add photo" } + describe 'my garden' do + before { visit garden_path(garden) } + it { is_expected.to have_link 'Edit' } + it { is_expected.to have_link 'Delete' } + it { is_expected.to have_content "Plant something here" } + it { is_expected.to have_content "Add photo" } + end + describe "someone else's garden" do + before { visit garden_path(other_member_garden) } + it { is_expected.not_to have_link 'Edit' } + it { is_expected.not_to have_link 'Delete' } + it { is_expected.not_to have_content "Plant something here" } + it { is_expected.not_to have_content "Add photo" } + end end end From 14441b623850e5486279e3f0042a0c354b33061d Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Wed, 23 Jan 2019 14:36:48 +1300 Subject: [PATCH 107/207] Update from should to expect syntax --- spec/views/gardens/show.html.haml_spec.rb | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/spec/views/gardens/show.html.haml_spec.rb b/spec/views/gardens/show.html.haml_spec.rb index 0a3f813e8..5a33707b3 100644 --- a/spec/views/gardens/show.html.haml_spec.rb +++ b/spec/views/gardens/show.html.haml_spec.rb @@ -12,28 +12,28 @@ describe "gardens/show" do render end - it 'should show the location' do - rendered.should have_content @garden.location + it 'shows the location' do + expect(rendered).to have_content @garden.location end - it 'should show the area' do - rendered.should have_content pluralize(@garden.area, @garden.area_unit) + it 'shows the area' do + expect(rendered).to have_content pluralize(@garden.area, @garden.area_unit) end - it 'should show the description' do - rendered.should have_content "totally cool garden" + it 'shows the description' do + expect(rendered).to have_content "totally cool garden" end it 'renders markdown in the description' do assert_select "strong", "totally" end - it 'should show plantings on the garden page' do - rendered.should have_content @planting.crop.name + it 'shows plantings on the garden page' do + expect(rendered).to have_content @planting.crop.name end it "doesn't show the note about random plantings" do - rendered.should_not have_content "Note: these are a random selection" + expect(rendered).to have_content "Note: these are a random selection" end context 'signed in' do From 3965fa193435df120d9df26f614787915090b4e4 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Wed, 23 Jan 2019 14:37:00 +1300 Subject: [PATCH 108/207] Add "something" to global action labels --- app/views/shared/_global_actions.html.haml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/views/shared/_global_actions.html.haml b/app/views/shared/_global_actions.html.haml index 771033c8a..1fbfa2733 100644 --- a/app/views/shared/_global_actions.html.haml +++ b/app/views/shared/_global_actions.html.haml @@ -6,9 +6,9 @@ .btn-group = link_to new_planting_path, class: 'btn btn-default' do - = t('buttons.plant') + = t('plantings.plant_something') = link_to new_harvest_path, class: 'btn btn-default' do - = t('buttons.harvest') + = t('harvests.harvest_something') = link_to new_seed_path, class: 'btn btn-default' do = t('buttons.save_seeds') From 79dfe2b84ded1fb5af0a3432a256c100b86c5b66 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Wed, 23 Jan 2019 14:37:18 +1300 Subject: [PATCH 109/207] Fixed button link, using translation that exists --- app/helpers/buttons_helper.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/helpers/buttons_helper.rb b/app/helpers/buttons_helper.rb index ea475fa05..8697ffd4c 100644 --- a/app/helpers/buttons_helper.rb +++ b/app/helpers/buttons_helper.rb @@ -58,7 +58,7 @@ module ButtonsHelper button( new_photo_path(id: model.id, type: model_type_for_photo(model)), - 'buttons.add_a_photo', 'camera' + 'buttons.add_photo', 'camera' ) end From 409dc1a2762fcb870e40e7a814633d080f7e767d Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Wed, 23 Jan 2019 14:52:17 +1300 Subject: [PATCH 110/207] Removing some unused translations --- config/locales/en.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/config/locales/en.yml b/config/locales/en.yml index 850492e09..f5415f127 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -76,13 +76,11 @@ en: edit: Edit harvest: Harvest harvest_crop: Harvest %{crop_name} - harvest_something: Harvest something mark_as_active: Mark as active mark_as_finished: Mark as finished mark_as_inactive: Mark as inactive plant: Plant plant_crop: Plant %{crop_name} - plant_something: Plant something plant_something_here: Plant something here save_seeds: Save seeds write_blog_post: Write blog post From a323da6780d554dafb503f2c72d5410e4546ad4e Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Wed, 23 Jan 2019 14:52:40 +1300 Subject: [PATCH 111/207] Capitalise some translations --- config/locales/en.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/config/locales/en.yml b/config/locales/en.yml index f5415f127..023d7b5a5 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -130,7 +130,7 @@ en: crops: our_crops: Some of our crops recently_added: Recently added crops - recently_planted: Recently planted + recently_planted: Recently Planted view_all: View all crops discuss: discussion: Discussion @@ -142,7 +142,7 @@ en: harvest: Harvest plant: Plant post: Post - recently_added: Recently added + recently_added: Recently Added welcome: Welcome to %{site_name}, %{member_name} members: title: Some of our members @@ -173,7 +173,7 @@ en: why_linktext: why Growstuff is open source wiki_linktext: Growstuff Wiki plantings: - recently_planted: Recently planted + recently_planted: Recently Planted seeds: crop: Crop description: Description From 066eaab1c2d7cfd33443b1d850c7c8941721d4f3 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Wed, 23 Jan 2019 14:54:43 +1300 Subject: [PATCH 112/207] Removed outdated spec --- spec/views/gardens/show.html.haml_spec.rb | 4 ---- 1 file changed, 4 deletions(-) diff --git a/spec/views/gardens/show.html.haml_spec.rb b/spec/views/gardens/show.html.haml_spec.rb index 5a33707b3..fd78ed08a 100644 --- a/spec/views/gardens/show.html.haml_spec.rb +++ b/spec/views/gardens/show.html.haml_spec.rb @@ -32,10 +32,6 @@ describe "gardens/show" do expect(rendered).to have_content @planting.crop.name end - it "doesn't show the note about random plantings" do - expect(rendered).to have_content "Note: these are a random selection" - end - context 'signed in' do before :each do sign_in @owner From 7779f7ec05aae35aa6e286ecb2137dfc7fec09b2 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Wed, 23 Jan 2019 15:01:34 +1300 Subject: [PATCH 113/207] Remove new planting button spec because it's in the button bar now --- spec/views/gardens/show.html.haml_spec.rb | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/spec/views/gardens/show.html.haml_spec.rb b/spec/views/gardens/show.html.haml_spec.rb index fd78ed08a..7451f26c8 100644 --- a/spec/views/gardens/show.html.haml_spec.rb +++ b/spec/views/gardens/show.html.haml_spec.rb @@ -31,15 +31,4 @@ describe "gardens/show" do it 'shows plantings on the garden page' do expect(rendered).to have_content @planting.crop.name end - - context 'signed in' do - before :each do - sign_in @owner - render - end - - it "links to the right crop in the planting link" do - assert_select("a[href='#{new_planting_path}?garden_id=#{@garden.id}']") - end - end end From 4fcd892458e1338891058658802cdb09bfad0e3c Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Wed, 23 Jan 2019 15:06:56 +1300 Subject: [PATCH 114/207] Use button helper for crop wrangling --- app/helpers/buttons_helper.rb | 4 ++++ app/views/crops/_wrangle.html.haml | 11 ++--------- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/app/helpers/buttons_helper.rb b/app/helpers/buttons_helper.rb index 8697ffd4c..32df4d932 100644 --- a/app/helpers/buttons_helper.rb +++ b/app/helpers/buttons_helper.rb @@ -16,6 +16,10 @@ module ButtonsHelper data: { confirm: 'All plantings associated with this garden will be marked as finished. Are you sure?' } end + def crop_edit_button(crop) + edit_button(edit_crop_path(seed)) + end + def seed_edit_button(seed) edit_button(edit_seed_path(seed)) end diff --git a/app/views/crops/_wrangle.html.haml b/app/views/crops/_wrangle.html.haml index fafafd490..4260bbfe2 100644 --- a/app/views/crops/_wrangle.html.haml +++ b/app/views/crops/_wrangle.html.haml @@ -5,12 +5,5 @@ = succeed "." do %strong CROP WRANGLER - - if can? :edit, crop - %p - = link_to t(:edit_crop), edit_crop_path(crop), class: 'btn btn-default' - - if can? :destroy, crop - %p - = link_to 'Delete crop', crop, - method: :delete, - data: { confirm: t('are_you_sure') }, - class: 'btn btn-default' + %p= crop_edit_button(crop) if can? :edit, crop + %p= delete_button(crop) if can? :destroy, crop From 0fa5513bf8cf89ab045b2dfd0d618a093f137b3c Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Wed, 23 Jan 2019 15:49:13 +1300 Subject: [PATCH 115/207] Revert modifications to menu --- app/views/layouts/_header.html.haml | 100 ++++++++++++++-------------- 1 file changed, 49 insertions(+), 51 deletions(-) diff --git a/app/views/layouts/_header.html.haml b/app/views/layouts/_header.html.haml index 990a23c76..ff4086c2e 100644 --- a/app/views/layouts/_header.html.haml +++ b/app/views/layouts/_header.html.haml @@ -20,63 +20,61 @@ = render 'crops/search_bar' .navbar-collapse.collapse#navbar-collapse - .navbar-right - %ul.nav.navbar-nav.navbar-right - %li.dropdown< - %a.dropdown-toggle{ 'data-toggle': 'dropdown', href: crops_path } - = t('.crops') - %b.caret - %ul.dropdown-menu - %li= link_to t('.browse_crops'), crops_path - %li= link_to t('.seeds'), seeds_path - %li= link_to t('.plantings'), plantings_path - %li= link_to t('.harvests'), harvests_path - %li.dropdown< - %a.dropdown-toggle{ 'data-toggle': 'dropdown', href: members_path } - = t('.community') - %b.caret - %ul.dropdown-menu - %li= link_to t('.community_map'), places_path - %li= link_to t('.browse_members'), members_path - %li= link_to t('.posts'), posts_path - %li= link_to t('.forums'), forums_path + %ul.nav.navbar-nav.navbar-right + %li.dropdown< + %a.dropdown-toggle{ 'data-toggle': 'dropdown', href: crops_path } + = t('.crops') + %b.caret + %ul.dropdown-menu + %li= link_to t('.browse_crops'), crops_path + %li= link_to t('.seeds'), seeds_path + %li= link_to t('.plantings'), plantings_path + %li= link_to t('.harvests'), harvests_path + %li.dropdown< + %a.dropdown-toggle{ 'data-toggle': 'dropdown', href: members_path } + = t('.community') + %b.caret + %ul.dropdown-menu + %li= link_to t('.community_map'), places_path + %li= link_to t('.browse_members'), members_path + %li= link_to t('.posts'), posts_path + %li= link_to t('.forums'), forums_path - - if member_signed_in? - %li.dropdown< - %a.dropdown-toggle{ 'data-toggle': 'dropdown', href: root_path } + - if member_signed_in? + %li.dropdown< + %a.dropdown-toggle{ 'data-toggle': 'dropdown', href: root_path } + - if current_member.notifications.unread_count.positive? + = t('.your_stuff', unread_count: current_member.notifications.unread_count) + - else + = t('.current_memberlogin_name', current_memberlogin_name: current_member.login_name) + %b.caret + %ul.dropdown-menu + %li= link_to t('.profile'), member_path(current_member) + %li= link_to t('.gardens'), gardens_by_owner_path(owner: current_member.slug) + %li= link_to t('.plantings'), plantings_by_owner_path(owner: current_member.slug) + %li= link_to t('.harvest'), harvests_by_owner_path(owner: current_member.slug) + %li= link_to t('.seeds'), seeds_by_owner_path(owner: current_member.slug) + %li= link_to t('.posts'), posts_by_author_path(author: current_member.slug) + %li - if current_member.notifications.unread_count.positive? - = t('.your_stuff', unread_count: current_member.notifications.unread_count) + = link_to(t('.inbox_unread', unread_count: current_member.notifications.unread_count), + notifications_path) - else - = t('.current_memberlogin_name', current_memberlogin_name: current_member.login_name) - %b.caret - %ul.dropdown-menu - %li= link_to t('.profile'), member_path(current_member) - %li= link_to t('.gardens'), gardens_by_owner_path(owner: current_member.slug) - %li= link_to t('.plantings'), plantings_by_owner_path(owner: current_member.slug) - %li= link_to t('.harvest'), harvests_by_owner_path(owner: current_member.slug) - %li= link_to t('.seeds'), seeds_by_owner_path(owner: current_member.slug) - %li= link_to t('.posts'), posts_by_author_path(author: current_member.slug) - %li - - if current_member.notifications.unread_count.positive? - = link_to(t('.inbox_unread', unread_count: current_member.notifications.unread_count), - notifications_path) - - else - = link_to(t('.inbox'), notifications_path) - - if current_member.role?(:crop_wrangler) || current_member.role?(:admin) - %li.divider{ role: 'presentation' } - - if current_member.role?(:crop_wrangler) - %li= link_to t('.crop_wrangling'), wrangle_crops_path - - if current_member.role?(:admin) - %li= link_to t('.admin'), admin_path + = link_to(t('.inbox'), notifications_path) + - if current_member.role?(:crop_wrangler) || current_member.role?(:admin) + %li.divider{ role: 'presentation' } + - if current_member.role?(:crop_wrangler) + %li= link_to t('.crop_wrangling'), wrangle_crops_path + - if current_member.role?(:admin) + %li= link_to t('.admin'), admin_path - %li= link_to t('.sign_out'), destroy_member_session_path, method: :delete + %li= link_to t('.sign_out'), destroy_member_session_path, method: :delete + + - else + %li= link_to t('.sign_in'), new_member_session_path, id: 'navbar-signin' + %li= link_to t('.sign_up'), new_member_registration_path, id: 'navbar-signup' - - else - %li= link_to t('.sign_in'), new_member_session_path, id: 'navbar-signin' - %li= link_to t('.sign_up'), new_member_registration_path, id: 'navbar-signup' - -# anchor tag for accessibility link to skip the navigation menu %a{ name: 'skipnav' } - From af7e59e45a70af4d2c6c2e19eb84b9fddb7e7e94 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Wed, 23 Jan 2019 16:14:22 +1300 Subject: [PATCH 116/207] Find maze button in spec --- spec/features/plantings/planting_a_crop_spec.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/spec/features/plantings/planting_a_crop_spec.rb b/spec/features/plantings/planting_a_crop_spec.rb index 1d8b7f745..de966b2fe 100644 --- a/spec/features/plantings/planting_a_crop_spec.rb +++ b/spec/features/plantings/planting_a_crop_spec.rb @@ -152,7 +152,9 @@ feature "Planting a crop", :js, :elasticsearch do scenario "Planting from crop page" do visit crop_path(maize) - click_link "Plant this" + within '.crop-actions' do + click_link "Plant maize" + end within "form#new_planting" do expect(page).to have_selector "input[value='maize']" click_button "Save" From 4d2936b68d5aa6769c406058a30bc5bcf22533e9 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Wed, 23 Jan 2019 16:15:09 +1300 Subject: [PATCH 117/207] Copy finish planting from view to helper --- app/helpers/buttons_helper.rb | 13 ++++++------- app/views/shared/buttons/_finish_planting.html.haml | 5 ----- 2 files changed, 6 insertions(+), 12 deletions(-) delete mode 100644 app/views/shared/buttons/_finish_planting.html.haml diff --git a/app/helpers/buttons_helper.rb b/app/helpers/buttons_helper.rb index 32df4d932..64ec66fae 100644 --- a/app/helpers/buttons_helper.rb +++ b/app/helpers/buttons_helper.rb @@ -17,7 +17,7 @@ module ButtonsHelper end def crop_edit_button(crop) - edit_button(edit_crop_path(seed)) + edit_button(edit_crop_path(crop)) end def seed_edit_button(seed) @@ -37,13 +37,12 @@ module ButtonsHelper end def planting_finish_button(planting) - return unless can?(:edit, planting) + return unless can?(:edit, planting) || planting.finished - button( - planting_path(planting, planting: { finished: 1 }), - 'buttons.mark_as_finished', - 'ok' - ) + link_to planting_path(planting, planting: { finished: 1 }), + method: :put, class: 'btn btn-default btn-xs append-date' do + render 'shared/glyphicon', icon: 'ok', title: 'buttons.mark_as_finished' + end end def planting_harvest_button(planting) diff --git a/app/views/shared/buttons/_finish_planting.html.haml b/app/views/shared/buttons/_finish_planting.html.haml deleted file mode 100644 index d0a931b41..000000000 --- a/app/views/shared/buttons/_finish_planting.html.haml +++ /dev/null @@ -1,5 +0,0 @@ -- if can?(:edit, planting) && !planting.finished - = link_to planting_path(planting, planting: { finished: 1 }), - method: :put, class: 'btn btn-default btn-xs append-date' do - = render 'shared/glyphicon', icon: 'ok', title: 'buttons.finished' - = t('buttons.mark_as_finished') From 045deb1ae48d902f48efd3ee1a7a0edc9ff6f45f Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Wed, 23 Jan 2019 16:19:08 +1300 Subject: [PATCH 118/207] Add crop name to actions --- app/views/crops/_index_card.html.haml | 4 ++-- spec/features/harvests/harvesting_a_crop_spec.rb | 4 +++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/app/views/crops/_index_card.html.haml b/app/views/crops/_index_card.html.haml index 99b4a1a7e..1c94573cf 100644 --- a/app/views/crops/_index_card.html.haml +++ b/app/views/crops/_index_card.html.haml @@ -31,6 +31,6 @@ days after planting - if can? :create, Planting - = link_to 'Plant this', new_planting_path(params: { crop_id: crop.id }), class: 'btn btn-primary' + = link_to "Plant #{crop.name}", new_planting_path(params: { crop_id: crop.id }), class: 'btn btn-primary' - if can? :create, Seed - = link_to 'Add seeds to stash', new_seed_path(params: { crop_id: crop.id }), class: 'btn btn-primary' + = link_to "Add #{crop.name} seeds to stash", new_seed_path(params: { crop_id: crop.id }), class: 'btn btn-primary' diff --git a/spec/features/harvests/harvesting_a_crop_spec.rb b/spec/features/harvests/harvesting_a_crop_spec.rb index 5f6d85fa2..afb182120 100644 --- a/spec/features/harvests/harvesting_a_crop_spec.rb +++ b/spec/features/harvests/harvesting_a_crop_spec.rb @@ -64,7 +64,9 @@ feature "Harvesting a crop", :js, :elasticsearch do scenario "Harvesting from crop page" do visit crop_path(maize) - click_link "Harvest this" + within '.crop-actions' do + click_link "Harvest #{maize.name}" + end within "form#new_harvest" do select plant_part.name, from: 'harvest[plant_part_id]' expect(page).to have_selector "input[value='maize']" From f39af27538d5612ccdb40a7ccff8030ee343e30b Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Wed, 23 Jan 2019 16:25:01 +1300 Subject: [PATCH 119/207] Seperate some specs --- spec/features/crops/crop_wranglers_spec.rb | 10 +++++----- .../features/plantings/planting_a_crop_spec.rb | 18 +++++++++--------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/spec/features/crops/crop_wranglers_spec.rb b/spec/features/crops/crop_wranglers_spec.rb index eafc7039f..86dc8a1c0 100644 --- a/spec/features/crops/crop_wranglers_spec.rb +++ b/spec/features/crops/crop_wranglers_spec.rb @@ -32,11 +32,11 @@ feature "crop wranglers", js: true do end end - scenario "visiting a crop can see wrangler links" do - visit crop_path(crops.first) - expect(page).to have_content 'You are a CROP WRANGLER' - expect(page).to have_link 'Edit crop' - expect(page).to have_link 'Delete crop' + describe "visiting a crop can see wrangler links" do + before { visit crop_path(crops.first) } + it { expect(page).to have_content 'You are a CROP WRANGLER' } + it { expect(page).to have_link 'Edit' } + it { expect(page).to have_link 'Delete' } end scenario "can create a new crop" do diff --git a/spec/features/plantings/planting_a_crop_spec.rb b/spec/features/plantings/planting_a_crop_spec.rb index de966b2fe..376c42569 100644 --- a/spec/features/plantings/planting_a_crop_spec.rb +++ b/spec/features/plantings/planting_a_crop_spec.rb @@ -21,15 +21,15 @@ feature "Planting a crop", :js, :elasticsearch do expect(page).to have_content "* denotes a required field" end - it "displays required and optional fields properly" do - expect(page).to have_selector ".form-group.required", text: "What did you plant?" - expect(page).to have_selector ".form-group.required", text: "Where did you plant it?" - expect(page).to have_optional 'input#planting_planted_at' - expect(page).to have_optional 'input#planting_quantity' - expect(page).to have_optional 'select#planting_planted_from' - expect(page).to have_optional 'select#planting_sunniness' - expect(page).to have_optional 'textarea#planting_description' - expect(page).to have_optional 'input#planting_finished_at' + describe "displays required and optional fields properly" do + it { expect(page).to have_selector ".form-group.required", text: "What did you plant?" } + it { expect(page).to have_selector ".form-group.required", text: "Where did you plant it?" } + it { expect(page).to have_optional 'input#planting_planted_at' } + it { expect(page).to have_optional 'input#planting_quantity' } + it { expect(page).to have_optional 'select#planting_planted_from' } + it { expect(page).to have_optional 'select#planting_sunniness' } + it { expect(page).to have_optional 'textarea#planting_description' } + it { expect(page).to have_optional 'input#planting_finished_at' } end scenario "Creating a new planting" do From 6c04d26638bc644602b968fc5b4902e669a069aa Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Wed, 23 Jan 2019 16:31:44 +1300 Subject: [PATCH 120/207] Crop name is in button label - add to spec --- spec/features/seeds/adding_seeds_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/features/seeds/adding_seeds_spec.rb b/spec/features/seeds/adding_seeds_spec.rb index 67a8b7717..021a24336 100644 --- a/spec/features/seeds/adding_seeds_spec.rb +++ b/spec/features/seeds/adding_seeds_spec.rb @@ -59,7 +59,7 @@ feature "Seeds", :js, :elasticsearch do describe "Adding a seed from crop page" do before do visit crop_path(maize) - click_link "Add seeds to stash" + click_link "Add maize seeds to stash" within "form#new_seed" do expect(page).to have_selector "input[value='maize']" click_button "Save" From e116229b7b883584c2a69bf1962ab4b3e5e00bbf Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Wed, 23 Jan 2019 16:35:12 +1300 Subject: [PATCH 121/207] Use new finish button on planting badges --- app/views/plantings/_badges.html.haml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/plantings/_badges.html.haml b/app/views/plantings/_badges.html.haml index e7ac1f6d3..acd244da4 100644 --- a/app/views/plantings/_badges.html.haml +++ b/app/views/plantings/_badges.html.haml @@ -3,7 +3,7 @@ - if planting.finish_is_predicatable? - if planting.super_late? %span.badge.badge-super-late= t('.super_late') - = render 'shared/buttons/finish_planting', planting: planting + = planting_finish_button(planting) - elsif planting.late? %span.badge.badge-late= t('.late_finishing') - else From 45aa0f1c701a94b5620453678881f333174f7332 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Wed, 23 Jan 2019 16:49:06 +1300 Subject: [PATCH 122/207] Fixed photo specs to find the button on the actions view --- spec/features/photos/new_photo_spec.rb | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/spec/features/photos/new_photo_spec.rb b/spec/features/photos/new_photo_spec.rb index 0bf696f06..3c486fa5b 100644 --- a/spec/features/photos/new_photo_spec.rb +++ b/spec/features/photos/new_photo_spec.rb @@ -13,7 +13,9 @@ feature "new photo page" do scenario "add photo" do visit planting_path(planting) - click_link('Add photo', match: :first) + within '.planting-actions' do + click_link('Add photo') + end expect(page).to have_text planting.crop.name end end @@ -23,7 +25,9 @@ feature "new photo page" do scenario "add photo" do visit harvest_path(harvest) - click_link "Add photo" + within '.harvest-actions' do + click_link "Add photo" + end expect(page).to have_text harvest.crop.name end end From a1b576aab492cdf3e3e3cb136f342728d296afa6 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Wed, 23 Jan 2019 16:54:07 +1300 Subject: [PATCH 123/207] Fixed label on link in spec --- spec/features/gardens_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/features/gardens_spec.rb b/spec/features/gardens_spec.rb index 368389719..0c58f8fdf 100644 --- a/spec/features/gardens_spec.rb +++ b/spec/features/gardens_spec.rb @@ -82,7 +82,7 @@ feature "Planting a crop", js: true do fill_in "Name", with: "New garden" click_button "Save" visit garden_path(Garden.last) - click_link 'delete_garden_link' + click_link 'Delete' expect(page).to have_content "Garden was successfully deleted" expect(page).to have_content "#{garden.owner}'s gardens" end From 001c0251b2237a74ba0a580cca6983a1e2cf4049 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Wed, 23 Jan 2019 17:34:32 +1300 Subject: [PATCH 124/207] DRY the icons --- app/helpers/icons_helper.rb | 17 +++++++++++++++++ app/views/crops/_actions.html.haml | 5 ++++- app/views/shared/_global_actions.html.haml | 15 +++++++++------ 3 files changed, 30 insertions(+), 7 deletions(-) create mode 100644 app/helpers/icons_helper.rb diff --git a/app/helpers/icons_helper.rb b/app/helpers/icons_helper.rb new file mode 100644 index 000000000..636884133 --- /dev/null +++ b/app/helpers/icons_helper.rb @@ -0,0 +1,17 @@ +module IconsHelper + def garden_icon + icon('far', 'square') + end + + def planting_icon + icon('fas', 'seedling') + end + + def harvest_icon + icon('fas', 'carrot') + end + + def seed_icon + icon('fas', 'heart') + end +end diff --git a/app/views/crops/_actions.html.haml b/app/views/crops/_actions.html.haml index 5cc80036b..92ae2b00f 100644 --- a/app/views/crops/_actions.html.haml +++ b/app/views/crops/_actions.html.haml @@ -2,12 +2,15 @@ .btn-group - if can? :create, Planting = link_to new_planting_path(crop_id: crop.id), class: 'btn btn-default' do + = planting_icon = t('buttons.plant_crop', crop_name: crop.name) - if can? :create, Harvest = link_to new_harvest_path(crop_id: crop.id), class: 'btn btn-default' do + = harvest_icon = t('buttons.harvest_crop', crop_name: crop.name) - + - if can? :create, Seed = link_to new_seed_path(crop_id: crop.id), class: 'btn btn-default' do + = seed_icon = t('buttons.add_seed_to_stash', crop_name: crop.name) diff --git a/app/views/shared/_global_actions.html.haml b/app/views/shared/_global_actions.html.haml index 1fbfa2733..638ce87d0 100644 --- a/app/views/shared/_global_actions.html.haml +++ b/app/views/shared/_global_actions.html.haml @@ -1,19 +1,22 @@ - if signed_in? - .global-actions + .global-actions.pull-right .btn-group = link_to gardens_by_owner_path(owner: current_member.slug), class: 'btn btn-default' do - = t('links.my_gardens') - + = garden_icon + = t('links.my_gardens') + .btn-group = link_to new_planting_path, class: 'btn btn-default' do + = planting_icon = t('plantings.plant_something') + = link_to new_harvest_path, class: 'btn btn-default' do + = harvest_icon = t('harvests.harvest_something') + = link_to new_seed_path, class: 'btn btn-default' do + = seed_icon = t('buttons.save_seeds') .btn-group = link_to t('posts.write_blog_post'), new_post_path, class: 'btn btn-default' - -- content_for(:attributions) do - seed by Template from the Noun Project \ No newline at end of file From e78180dc3a138abb765a4299165b4ccfecad04c5 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Wed, 23 Jan 2019 21:49:11 +1300 Subject: [PATCH 125/207] Move consistent icons --- app/helpers/buttons_helper.rb | 35 +++++++++++++++++----------- app/helpers/icons_helper.rb | 16 +++++++++++++ app/views/gardens/_actions.html.haml | 5 ++-- 3 files changed, 40 insertions(+), 16 deletions(-) diff --git a/app/helpers/buttons_helper.rb b/app/helpers/buttons_helper.rb index 64ec66fae..30c992946 100644 --- a/app/helpers/buttons_helper.rb +++ b/app/helpers/buttons_helper.rb @@ -1,6 +1,8 @@ module ButtonsHelper def garden_plant_something_button(garden) - button(new_planting_path(garden_id: garden.id), 'buttons.plant_something_here', 'leaf') + link_to new_planting_path(garden_id: garden.id), class: "btn btn-default btn-xs btn-primary" do + planting_icon + ' ' + t('buttons.plant_something_here') + end end def garden_mark_active_button(garden) @@ -41,39 +43,46 @@ module ButtonsHelper link_to planting_path(planting, planting: { finished: 1 }), method: :put, class: 'btn btn-default btn-xs append-date' do - render 'shared/glyphicon', icon: 'ok', title: 'buttons.mark_as_finished' + finished_icon + ' ' + t('buttons.mark_as_finished') end end def planting_harvest_button(planting) return unless planting.active? && can?(:create, Harvest) && can?(:edit, planting) - button(new_planting_harvest_path(planting), 'buttons.harvest', 'apple') + link_to new_planting_harvest_path(planting), class: "btn btn-default btn-xs" do + harvest_icon + ' ' + t('buttons.harvest') + end end def planting_save_seeds_button(planting) - button(new_planting_seed_path(planting), 'buttons.save_seeds', 'heart') if can?(:edit, planting) + return unless can?(:edit, planting) + + link_to new_planting_seed_path(planting), class: "btn btn-default btn-xs" do + seed_icon + ' ' + t('buttons.save_seeds') + end end - # Generic buttons (works out which model) def add_photo_button(model) return unless can?(:edit, model) && can?(:create, Photo) - button( - new_photo_path(id: model.id, type: model_type_for_photo(model)), - 'buttons.add_photo', 'camera' - ) + link_to new_photo_path(id: model.id, type: model_type_for_photo(model)), + class: "btn btn-default btn-xs" do + photo_icon + ' ' + t('buttons.add_photo') + end end def edit_button(path) - button(path, 'buttons.edit', 'pencil') + link_to path, class: "btn btn-default btn-xs" do + edit_icon + ' ' + t('buttons.edit') + end end def delete_button(model, message: 'are_you_sure') return unless can? :destroy, model link_to model, method: :delete, data: { confirm: t(message) }, class: 'btn btn-default btn-xs' do - render 'shared/glyphicon', icon: 'trash', title: 'buttons.delete' + delete_icon + ' ' + t('buttons.delete') end end @@ -83,9 +92,9 @@ module ButtonsHelper ActiveModel::Name.new(model.class).to_s.downcase end - def button(path, title, icon, size = 'btn-xs') + def button(path, button_title, icon, size = 'btn-xs') link_to path, class: "btn btn-default #{size}" do - render 'shared/glyphicon', icon: icon, title: title + icon + ' ' + button_title end end end diff --git a/app/helpers/icons_helper.rb b/app/helpers/icons_helper.rb index 636884133..ab3a042b5 100644 --- a/app/helpers/icons_helper.rb +++ b/app/helpers/icons_helper.rb @@ -14,4 +14,20 @@ module IconsHelper def seed_icon icon('fas', 'heart') end + + def finished_icon + icon('fas', 'calendar') + end + + def edit_icon + icon('far', 'edit') + end + + def delete_icon + icon('fas', 'trash-alt') + end + + def photo_icon + icon('fas', 'camera-retro') + end end diff --git a/app/views/gardens/_actions.html.haml b/app/views/gardens/_actions.html.haml index 3834d4787..ea97a3931 100644 --- a/app/views/gardens/_actions.html.haml +++ b/app/views/gardens/_actions.html.haml @@ -1,8 +1,8 @@ .garden-actions - if can?(:edit, garden) + = garden_plant_something_button(garden) if garden.active .btn-group - if garden.active - = garden_plant_something_button(garden) = garden_mark_inactive_button(garden) - else = garden_mark_active_button(garden) @@ -11,5 +11,4 @@ = add_photo_button(garden) - if can?(:destroy, garden) - .pull-right - = delete_button(garden, message: 'All plantings associated with this garden will also be deleted. Are you sure?') + = delete_button(garden, message: 'All plantings associated with this garden will also be deleted. Are you sure?') From 2d68aa20825d23704eb69fa04de97e2748b924ff Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Wed, 23 Jan 2019 21:49:17 +1300 Subject: [PATCH 126/207] Wider action bar --- app/views/layouts/application.html.haml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/app/views/layouts/application.html.haml b/app/views/layouts/application.html.haml index 3ac9f7cf6..f7fc3f5de 100644 --- a/app/views/layouts/application.html.haml +++ b/app/views/layouts/application.html.haml @@ -8,7 +8,7 @@ #maincontainer = render partial: "shared/flash_messages", flash: flash .row - .col-md-8 + .col-md-6 - if content_for?(:title) %h1#title = yield(:title) @@ -19,8 +19,7 @@ .btn-group.layout-actions = yield(:buttonbar) - .col-md-4 - + .col-md-6 = render 'shared/global_actions' = yield From de01cc9c00acda7e18f4fc943636d45eb89e77bb Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Wed, 23 Jan 2019 21:57:21 +1300 Subject: [PATCH 127/207] Tidy up member edit buttons --- app/views/members/show.html.haml | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/app/views/members/show.html.haml b/app/views/members/show.html.haml index 621f35c51..a786b8077 100644 --- a/app/views/members/show.html.haml +++ b/app/views/members/show.html.haml @@ -7,11 +7,17 @@ = tag("meta", property: "og:type", content: "profile") = tag("meta", property: "og:url", content: request.original_url) = tag("meta", property: "og:site_name", content: ENV['GROWSTUFF_SITE_NAME']) + + - content_for :buttonbar do - - if can? :update, @member - = link_to 'Edit profile', edit_member_registration_path, class: 'btn btn-default pull-right' - - if can?(:create, Notification) && current_member != @member - = link_to 'Send message', new_notification_path(recipient_id: @member.id), class: 'btn btn-default pull-right' + %p.btn-group + - if can? :update, @member + = link_to edit_member_registration_path, class: 'btn btn-default pull-right' do + = edit_icon + = t('members.edit_profile') + + - if can?(:create, Notification) && current_member != @member + = link_to 'Send message', new_notification_path(recipient_id: @member.id), class: 'btn btn-default' - if current_member && current_member != @member # must be logged in, can't follow yourself - follow = current_member.get_follow(@member) From 09230fe4e744f8606a9c5d14986bc05726897e46 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Wed, 23 Jan 2019 21:59:06 +1300 Subject: [PATCH 128/207] indentation clean up --- app/helpers/buttons_helper.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/helpers/buttons_helper.rb b/app/helpers/buttons_helper.rb index 30c992946..df4a48f6c 100644 --- a/app/helpers/buttons_helper.rb +++ b/app/helpers/buttons_helper.rb @@ -43,7 +43,7 @@ module ButtonsHelper link_to planting_path(planting, planting: { finished: 1 }), method: :put, class: 'btn btn-default btn-xs append-date' do - finished_icon + ' ' + t('buttons.mark_as_finished') + finished_icon + ' ' + t('buttons.mark_as_finished') end end From d270be83d0cc41938f5191576cdfbfb2b49f41f4 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Wed, 23 Jan 2019 22:30:44 +1300 Subject: [PATCH 129/207] Tidied up the planting actions on gardens#index --- app/assets/stylesheets/overrides.sass | 6 ++++-- app/views/plantings/_thumbnail.html.haml | 27 +++++++++++++++--------- 2 files changed, 21 insertions(+), 12 deletions(-) diff --git a/app/assets/stylesheets/overrides.sass b/app/assets/stylesheets/overrides.sass index b255536ea..1e9374184 100644 --- a/app/assets/stylesheets/overrides.sass +++ b/app/assets/stylesheets/overrides.sass @@ -132,11 +132,13 @@ p.stats padding: 0 border: 1px solid darken($beige, 10%) border-radius: 4px - .planting-actions - top: -8em .planting-name position: relative top: -1em + .planting-quick-actions + position: absolute + top: 0 + right: 2em dl.planting-attributes dt diff --git a/app/views/plantings/_thumbnail.html.haml b/app/views/plantings/_thumbnail.html.haml index a6b8349b8..bfe4892a8 100644 --- a/app/views/plantings/_thumbnail.html.haml +++ b/app/views/plantings/_thumbnail.html.haml @@ -1,13 +1,20 @@ .planting .planting-badges = render 'plantings/badges', planting: planting - .hover-wrapper - .thumbnail - .planting-thumbnail{ class: planting_classes(planting) } - = link_to image_tag(planting_image_path(planting), - alt: planting.crop.name, class: 'img'), planting_path(planting) - = render 'plantings/progress', planting: planting, show_explanation: false - .planting-name - = link_to planting.crop.name, planting - .text - .planting-actions= render 'plantings/actions', planting: planting + + .planting-quick-actions.pull-right + %a.btn.btn-default.btn-xs#actionsMenu.nav-link.dropdown-toggle{"aria-expanded" => "false", "aria-haspopup" => "true", "data-toggle" => "dropdown", href: "#"} + =icon('fas', 'bars') + .dropdown-menu{"aria-labelledby" => "actionsMenu"} + %p= render 'plantings/actions', planting: planting + + .thumbnail + + .planting-thumbnail{ class: planting_classes(planting) } + = link_to image_tag(planting_image_path(planting), + alt: planting.crop.name, class: 'img'), planting_path(planting) + = render 'plantings/progress', planting: planting, show_explanation: false + + .planting-name + = link_to planting.crop.name, planting + From a8b9d0d5ffb6e669d9da5cb7db5d985448965728 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Thu, 24 Jan 2019 09:17:13 +1300 Subject: [PATCH 130/207] Include icon helper from button helper --- app/helpers/buttons_helper.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/app/helpers/buttons_helper.rb b/app/helpers/buttons_helper.rb index df4a48f6c..ad31f45c4 100644 --- a/app/helpers/buttons_helper.rb +++ b/app/helpers/buttons_helper.rb @@ -1,4 +1,5 @@ module ButtonsHelper + include IconHelper def garden_plant_something_button(garden) link_to new_planting_path(garden_id: garden.id), class: "btn btn-default btn-xs btn-primary" do planting_icon + ' ' + t('buttons.plant_something_here') From 8586d7c73dccb53af665f6b12e734d1bf4019fd6 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Thu, 24 Jan 2019 09:18:46 +1300 Subject: [PATCH 131/207] Update buttons_helper.rb --- app/helpers/buttons_helper.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/helpers/buttons_helper.rb b/app/helpers/buttons_helper.rb index ad31f45c4..7ae28247e 100644 --- a/app/helpers/buttons_helper.rb +++ b/app/helpers/buttons_helper.rb @@ -1,5 +1,5 @@ module ButtonsHelper - include IconHelper + include IconsHelper def garden_plant_something_button(garden) link_to new_planting_path(garden_id: garden.id), class: "btn btn-default btn-xs btn-primary" do planting_icon + ' ' + t('buttons.plant_something_here') From 251365654f11109c47c4e833cfe46f87155fa333 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Thu, 24 Jan 2019 11:51:48 +1300 Subject: [PATCH 132/207] Include font awesome (so specs pass) --- app/helpers/icons_helper.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/app/helpers/icons_helper.rb b/app/helpers/icons_helper.rb index ab3a042b5..a42aaf5d8 100644 --- a/app/helpers/icons_helper.rb +++ b/app/helpers/icons_helper.rb @@ -1,4 +1,5 @@ module IconsHelper + include FontAwesome::Sass::Rails::ViewHelpers def garden_icon icon('far', 'square') end From 87c7596ab744131831a7631ee6fc628be3003a2b Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Thu, 24 Jan 2019 11:54:55 +1300 Subject: [PATCH 133/207] Added missing translation for Edit profile button --- config/locales/en.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/config/locales/en.yml b/config/locales/en.yml index 023d7b5a5..12942554f 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -221,6 +221,7 @@ en: links: my_gardens: My gardens members: + edit_profile: Edit profile index: title: "%{site_name} members" signup: From 79c22308df89786eccd74f6db3f066de2efaff47 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Thu, 24 Jan 2019 11:58:58 +1300 Subject: [PATCH 134/207] Fixed nested row on layout, that was breaking photo add page --- app/views/layouts/application.html.haml | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/app/views/layouts/application.html.haml b/app/views/layouts/application.html.haml index f7fc3f5de..d36f217b8 100644 --- a/app/views/layouts/application.html.haml +++ b/app/views/layouts/application.html.haml @@ -6,7 +6,8 @@ = render partial: "layouts/header" #maincontainer - = render partial: "shared/flash_messages", flash: flash + .row + .col-md-12= render partial: "shared/flash_messages", flash: flash .row .col-md-6 - if content_for?(:title) @@ -21,10 +22,13 @@ .col-md-6 = render 'shared/global_actions' - = yield + + .row + .col-md-12 + = yield %footer - = render partial: "layouts/footer" + = render "layouts/footer" / Javascripts \================================================== From a3f32aba9bb9b34233b7e6699d5d6c4f486894a2 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Mon, 21 Jan 2019 11:46:50 +1300 Subject: [PATCH 135/207] Call t() on button labels --- app/views/shared/buttons/_add_photo.haml | 2 +- app/views/shared/buttons/_delete.haml | 6 +++--- app/views/shared/buttons/_edit.haml | 4 ++-- app/views/shared/buttons/_finish_planting.html.haml | 4 ++-- app/views/shared/buttons/_finish_seeds.haml | 4 ++-- app/views/shared/buttons/_harvest_planting.haml | 4 ++-- app/views/shared/buttons/_save_seeds.haml | 4 ++-- 7 files changed, 14 insertions(+), 14 deletions(-) diff --git a/app/views/shared/buttons/_add_photo.haml b/app/views/shared/buttons/_add_photo.haml index 71e97c0e9..09199c208 100644 --- a/app/views/shared/buttons/_add_photo.haml +++ b/app/views/shared/buttons/_add_photo.haml @@ -1,4 +1,4 @@ - if can?(:create, Photo) = link_to path, class: 'btn btn-default btn-xs' do %span.glyphicon.glyphicon-camera{ title: "Add photo" } - Add photo + =t(:add_photo) diff --git a/app/views/shared/buttons/_delete.haml b/app/views/shared/buttons/_delete.haml index b7490837b..635b652c0 100644 --- a/app/views/shared/buttons/_delete.haml +++ b/app/views/shared/buttons/_delete.haml @@ -1,4 +1,4 @@ = link_to path, method: :delete, - data: { confirm: 'Are you sure?' }, class: 'btn btn-default btn-xs' do - %span.glyphicon.glyphicon-trash{ title: "Delete" } - Delete + data: { confirm: t(:are_you_sure?) }, class: 'btn btn-default btn-xs' do + %span.glyphicon.glyphicon-trash{ title: t(:delete) } + =t :delete diff --git a/app/views/shared/buttons/_edit.haml b/app/views/shared/buttons/_edit.haml index 87d464023..f45fc529e 100644 --- a/app/views/shared/buttons/_edit.haml +++ b/app/views/shared/buttons/_edit.haml @@ -1,3 +1,3 @@ = link_to path, class: 'btn btn-default btn-xs' do - %span.glyphicon.glyphicon-pencil{ title: "Edit" } - Edit + %span.glyphicon.glyphicon-pencil{ title: t(:edit) } + =t :edit diff --git a/app/views/shared/buttons/_finish_planting.html.haml b/app/views/shared/buttons/_finish_planting.html.haml index 7b1ba8319..166bb6817 100644 --- a/app/views/shared/buttons/_finish_planting.html.haml +++ b/app/views/shared/buttons/_finish_planting.html.haml @@ -1,5 +1,5 @@ - if can?(:edit, planting) && !planting.finished = link_to planting_path(planting, planting: { finished: 1 }), method: :put, class: 'btn btn-default btn-xs append-date' do - %span.glyphicon.glyphicon-ok{ title: "Finished" } - Mark as finished + %span.glyphicon.glyphicon-ok{ title: t(:finished) } + =t :mark_as_finished diff --git a/app/views/shared/buttons/_finish_seeds.haml b/app/views/shared/buttons/_finish_seeds.haml index 211e3ec8b..54a4d68b5 100644 --- a/app/views/shared/buttons/_finish_seeds.haml +++ b/app/views/shared/buttons/_finish_seeds.haml @@ -1,5 +1,5 @@ - unless seed.finished = link_to seed_path(seed, seed: { finished: 1 }), method: :put, class: 'btn btn-default btn-xs append-date' do - %span.glyphicon.glyphicon-ok{ title: "Finished" } - Mark as finished + %span.glyphicon.glyphicon-ok{ title: t(:finished) } + =t(:mark_as_finished) diff --git a/app/views/shared/buttons/_harvest_planting.haml b/app/views/shared/buttons/_harvest_planting.haml index c90e163ad..f18d948bd 100644 --- a/app/views/shared/buttons/_harvest_planting.haml +++ b/app/views/shared/buttons/_harvest_planting.haml @@ -1,4 +1,4 @@ - planting.active? && if can?(:create, Harvest) && can?(:edit, planting) = link_to new_planting_harvest_path(planting), class: 'btn btn-default btn-xs' do - %span.glyphicon.glyphicon-leaf{ title: "Harvest" } - Harvest + %span.glyphicon.glyphicon-leaf{ title: :harvest } + =t(:harvest) diff --git a/app/views/shared/buttons/_save_seeds.haml b/app/views/shared/buttons/_save_seeds.haml index 00d5febb0..c1664de35 100644 --- a/app/views/shared/buttons/_save_seeds.haml +++ b/app/views/shared/buttons/_save_seeds.haml @@ -1,4 +1,4 @@ - if planting.active? = link_to new_planting_seed_path(planting), class: 'btn btn-default btn-xs' do - %span.glyphicon.glyphicon-heart{ title: "Save seeds" } - Save seeds + %span.glyphicon.glyphicon-heart{ title: t(:save_seeds) } + =t(:save_seeds) From 7169b624b0edac057c36853e396b4d0d4f85a6cf Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Mon, 21 Jan 2019 11:47:25 +1300 Subject: [PATCH 136/207] Move the action buttons to EVERY page --- app/views/home/index.html.haml | 7 ------- app/views/layouts/application.html.haml | 1 + app/views/shared/_global_actions.html.haml | 6 ++++++ 3 files changed, 7 insertions(+), 7 deletions(-) create mode 100644 app/views/shared/_global_actions.html.haml diff --git a/app/views/home/index.html.haml b/app/views/home/index.html.haml index d05d6a37a..0259ce590 100644 --- a/app/views/home/index.html.haml +++ b/app/views/home/index.html.haml @@ -4,13 +4,6 @@ %h1= t('.welcome', site_name: ENV['GROWSTUFF_SITE_NAME'], member_name: current_member) = render 'stats' - %p - .btn-group - = link_to t('.plant'), new_planting_path, class: 'btn btn-default' - = link_to t('.harvest'), new_harvest_path, class: 'btn btn-default' - = link_to t('.add_seeds'), new_seed_path, class: 'btn btn-default' - = link_to t('.post'), new_post_path, class: 'btn btn-default' - - else .hidden-xs .jumbotron diff --git a/app/views/layouts/application.html.haml b/app/views/layouts/application.html.haml index 070ed73db..34dbbdfe5 100644 --- a/app/views/layouts/application.html.haml +++ b/app/views/layouts/application.html.haml @@ -8,6 +8,7 @@ #maincontainer .row .col-md-12 + = render 'shared/global_actions' - if content_for?(:title) %h1#title = yield(:title) diff --git a/app/views/shared/_global_actions.html.haml b/app/views/shared/_global_actions.html.haml new file mode 100644 index 000000000..d4b4a5e97 --- /dev/null +++ b/app/views/shared/_global_actions.html.haml @@ -0,0 +1,6 @@ +%p + .btn-group + = link_to t(:plant_something), new_planting_path, class: 'btn btn-default' + = link_to t(:harvest_something), new_harvest_path, class: 'btn btn-default' + = link_to t(:save_seeds), new_seed_path, class: 'btn btn-default' + = link_to t(:write_blog_post), new_post_path, class: 'btn btn-default' From e886929af519ff579dda13ab11e03d6cb487954c Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Mon, 21 Jan 2019 13:37:58 +1300 Subject: [PATCH 137/207] Put buttons translations under buttons namespace --- app/views/shared/buttons/_add_photo.haml | 2 +- app/views/shared/buttons/_delete.haml | 2 +- app/views/shared/buttons/_edit.haml | 2 +- app/views/shared/buttons/_finish_planting.html.haml | 2 +- app/views/shared/buttons/_finish_seeds.haml | 2 +- app/views/shared/buttons/_harvest_planting.haml | 2 +- app/views/shared/buttons/_save_seeds.haml | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) diff --git a/app/views/shared/buttons/_add_photo.haml b/app/views/shared/buttons/_add_photo.haml index 09199c208..c2c87f315 100644 --- a/app/views/shared/buttons/_add_photo.haml +++ b/app/views/shared/buttons/_add_photo.haml @@ -1,4 +1,4 @@ - if can?(:create, Photo) = link_to path, class: 'btn btn-default btn-xs' do %span.glyphicon.glyphicon-camera{ title: "Add photo" } - =t(:add_photo) + =t('buttons.add_photo') diff --git a/app/views/shared/buttons/_delete.haml b/app/views/shared/buttons/_delete.haml index 635b652c0..d89a51d2d 100644 --- a/app/views/shared/buttons/_delete.haml +++ b/app/views/shared/buttons/_delete.haml @@ -1,4 +1,4 @@ = link_to path, method: :delete, data: { confirm: t(:are_you_sure?) }, class: 'btn btn-default btn-xs' do %span.glyphicon.glyphicon-trash{ title: t(:delete) } - =t :delete + =t('buttons.delete') diff --git a/app/views/shared/buttons/_edit.haml b/app/views/shared/buttons/_edit.haml index f45fc529e..3e00821c5 100644 --- a/app/views/shared/buttons/_edit.haml +++ b/app/views/shared/buttons/_edit.haml @@ -1,3 +1,3 @@ = link_to path, class: 'btn btn-default btn-xs' do %span.glyphicon.glyphicon-pencil{ title: t(:edit) } - =t :edit + =t('buttons.edit') diff --git a/app/views/shared/buttons/_finish_planting.html.haml b/app/views/shared/buttons/_finish_planting.html.haml index 166bb6817..c38ba3185 100644 --- a/app/views/shared/buttons/_finish_planting.html.haml +++ b/app/views/shared/buttons/_finish_planting.html.haml @@ -2,4 +2,4 @@ = link_to planting_path(planting, planting: { finished: 1 }), method: :put, class: 'btn btn-default btn-xs append-date' do %span.glyphicon.glyphicon-ok{ title: t(:finished) } - =t :mark_as_finished + =t('buttons.mark_as_finished') diff --git a/app/views/shared/buttons/_finish_seeds.haml b/app/views/shared/buttons/_finish_seeds.haml index 54a4d68b5..49c34ac17 100644 --- a/app/views/shared/buttons/_finish_seeds.haml +++ b/app/views/shared/buttons/_finish_seeds.haml @@ -2,4 +2,4 @@ = link_to seed_path(seed, seed: { finished: 1 }), method: :put, class: 'btn btn-default btn-xs append-date' do %span.glyphicon.glyphicon-ok{ title: t(:finished) } - =t(:mark_as_finished) + =t('buttons.mark_as_finished') diff --git a/app/views/shared/buttons/_harvest_planting.haml b/app/views/shared/buttons/_harvest_planting.haml index f18d948bd..8845e4c01 100644 --- a/app/views/shared/buttons/_harvest_planting.haml +++ b/app/views/shared/buttons/_harvest_planting.haml @@ -1,4 +1,4 @@ - planting.active? && if can?(:create, Harvest) && can?(:edit, planting) = link_to new_planting_harvest_path(planting), class: 'btn btn-default btn-xs' do %span.glyphicon.glyphicon-leaf{ title: :harvest } - =t(:harvest) + =t('buttons.harvest') diff --git a/app/views/shared/buttons/_save_seeds.haml b/app/views/shared/buttons/_save_seeds.haml index c1664de35..312f54cf4 100644 --- a/app/views/shared/buttons/_save_seeds.haml +++ b/app/views/shared/buttons/_save_seeds.haml @@ -1,4 +1,4 @@ - if planting.active? = link_to new_planting_seed_path(planting), class: 'btn btn-default btn-xs' do %span.glyphicon.glyphicon-heart{ title: t(:save_seeds) } - =t(:save_seeds) + =t('buttons.save_seeds') From 30255a24d26183f8ec7b07fb75b033ec2d794c3c Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Mon, 21 Jan 2019 13:40:56 +1300 Subject: [PATCH 138/207] Use buttons.* translations for glyphicons titles --- app/views/shared/_global_actions.html.haml | 8 ++++---- app/views/shared/buttons/_add_photo.haml | 2 +- app/views/shared/buttons/_delete.haml | 2 +- app/views/shared/buttons/_edit.haml | 2 +- app/views/shared/buttons/_finish_planting.html.haml | 2 +- app/views/shared/buttons/_finish_seeds.haml | 2 +- app/views/shared/buttons/_harvest_planting.haml | 4 ++-- app/views/shared/buttons/_save_seeds.haml | 4 ++-- config/locales/en.yml | 10 ++++++++++ 9 files changed, 23 insertions(+), 13 deletions(-) diff --git a/app/views/shared/_global_actions.html.haml b/app/views/shared/_global_actions.html.haml index d4b4a5e97..59481c858 100644 --- a/app/views/shared/_global_actions.html.haml +++ b/app/views/shared/_global_actions.html.haml @@ -1,6 +1,6 @@ %p .btn-group - = link_to t(:plant_something), new_planting_path, class: 'btn btn-default' - = link_to t(:harvest_something), new_harvest_path, class: 'btn btn-default' - = link_to t(:save_seeds), new_seed_path, class: 'btn btn-default' - = link_to t(:write_blog_post), new_post_path, class: 'btn btn-default' + = link_to t('buttons.plant_something'), new_planting_path, class: 'btn btn-default' + = link_to t('buttons.harvest_something'), new_harvest_path, class: 'btn btn-default' + = link_to t('buttons.save_seeds'), new_seed_path, class: 'btn btn-default' + = link_to t('buttons.write_blog_post'), new_post_path, class: 'btn btn-default' diff --git a/app/views/shared/buttons/_add_photo.haml b/app/views/shared/buttons/_add_photo.haml index c2c87f315..425ca52fc 100644 --- a/app/views/shared/buttons/_add_photo.haml +++ b/app/views/shared/buttons/_add_photo.haml @@ -1,4 +1,4 @@ - if can?(:create, Photo) = link_to path, class: 'btn btn-default btn-xs' do - %span.glyphicon.glyphicon-camera{ title: "Add photo" } + %span.glyphicon.glyphicon-camera{ title: t('buttons.add_photo') } =t('buttons.add_photo') diff --git a/app/views/shared/buttons/_delete.haml b/app/views/shared/buttons/_delete.haml index d89a51d2d..f4ae4f5cd 100644 --- a/app/views/shared/buttons/_delete.haml +++ b/app/views/shared/buttons/_delete.haml @@ -1,4 +1,4 @@ = link_to path, method: :delete, data: { confirm: t(:are_you_sure?) }, class: 'btn btn-default btn-xs' do - %span.glyphicon.glyphicon-trash{ title: t(:delete) } + %span.glyphicon.glyphicon-trash{ title: t('buttons.delete') } =t('buttons.delete') diff --git a/app/views/shared/buttons/_edit.haml b/app/views/shared/buttons/_edit.haml index 3e00821c5..1ad2fc77e 100644 --- a/app/views/shared/buttons/_edit.haml +++ b/app/views/shared/buttons/_edit.haml @@ -1,3 +1,3 @@ = link_to path, class: 'btn btn-default btn-xs' do - %span.glyphicon.glyphicon-pencil{ title: t(:edit) } + %span.glyphicon.glyphicon-pencil{ title: t('buttons.edit') } =t('buttons.edit') diff --git a/app/views/shared/buttons/_finish_planting.html.haml b/app/views/shared/buttons/_finish_planting.html.haml index c38ba3185..5d49418a1 100644 --- a/app/views/shared/buttons/_finish_planting.html.haml +++ b/app/views/shared/buttons/_finish_planting.html.haml @@ -1,5 +1,5 @@ - if can?(:edit, planting) && !planting.finished = link_to planting_path(planting, planting: { finished: 1 }), method: :put, class: 'btn btn-default btn-xs append-date' do - %span.glyphicon.glyphicon-ok{ title: t(:finished) } + %span.glyphicon.glyphicon-ok{ title: t('buttons.finished') } =t('buttons.mark_as_finished') diff --git a/app/views/shared/buttons/_finish_seeds.haml b/app/views/shared/buttons/_finish_seeds.haml index 49c34ac17..4589e50f2 100644 --- a/app/views/shared/buttons/_finish_seeds.haml +++ b/app/views/shared/buttons/_finish_seeds.haml @@ -1,5 +1,5 @@ - unless seed.finished = link_to seed_path(seed, seed: { finished: 1 }), method: :put, class: 'btn btn-default btn-xs append-date' do - %span.glyphicon.glyphicon-ok{ title: t(:finished) } + %span.glyphicon.glyphicon-ok{ title: t('buttons.finished') } =t('buttons.mark_as_finished') diff --git a/app/views/shared/buttons/_harvest_planting.haml b/app/views/shared/buttons/_harvest_planting.haml index 8845e4c01..d81b18fa2 100644 --- a/app/views/shared/buttons/_harvest_planting.haml +++ b/app/views/shared/buttons/_harvest_planting.haml @@ -1,4 +1,4 @@ - planting.active? && if can?(:create, Harvest) && can?(:edit, planting) = link_to new_planting_harvest_path(planting), class: 'btn btn-default btn-xs' do - %span.glyphicon.glyphicon-leaf{ title: :harvest } - =t('buttons.harvest') + %span.glyphicon.glyphicon-leaf{ title: = t('buttons.harvest') } + = t('buttons.harvest') diff --git a/app/views/shared/buttons/_save_seeds.haml b/app/views/shared/buttons/_save_seeds.haml index 312f54cf4..d18807b2b 100644 --- a/app/views/shared/buttons/_save_seeds.haml +++ b/app/views/shared/buttons/_save_seeds.haml @@ -1,4 +1,4 @@ - if planting.active? = link_to new_planting_seed_path(planting), class: 'btn btn-default btn-xs' do - %span.glyphicon.glyphicon-heart{ title: t(:save_seeds) } - =t('buttons.save_seeds') + %span.glyphicon.glyphicon-heart{ title: t('buttons.save_seeds') } + = t('buttons.save_seeds') diff --git a/config/locales/en.yml b/config/locales/en.yml index 879d7c51c..7f2778983 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -63,6 +63,16 @@ en: seed: one: seed other: seeds + buttons: + add_photo: Add photo + delete: Delete + edit: Edit + harvest: Harvest + harvest_something: Harvest something + mark_as_finished: Mark as finished + plant_something: Plant something + save_seeds: Save seeds + write_blog_post: Write blog post crops: index: subtitle: "%{crops_size} total" From 6c16dca9b4a85a2ca1b10a6fe565b7dd441c1fdb Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Mon, 21 Jan 2019 14:13:12 +1300 Subject: [PATCH 139/207] Dry the gglypicons --- app/views/shared/_glyphicon.html.haml | 1 + app/views/shared/buttons/_add_photo.haml | 2 +- app/views/shared/buttons/_delete.haml | 2 +- app/views/shared/buttons/_edit.haml | 2 +- app/views/shared/buttons/_finish_planting.html.haml | 4 ++-- app/views/shared/buttons/_finish_seeds.haml | 2 +- app/views/shared/buttons/_harvest_planting.haml | 2 +- app/views/shared/buttons/_save_seeds.haml | 2 +- 8 files changed, 9 insertions(+), 8 deletions(-) create mode 100644 app/views/shared/_glyphicon.html.haml diff --git a/app/views/shared/_glyphicon.html.haml b/app/views/shared/_glyphicon.html.haml new file mode 100644 index 000000000..39f2546cf --- /dev/null +++ b/app/views/shared/_glyphicon.html.haml @@ -0,0 +1 @@ +%span{class: "glyphicon.glyphicon-#{icon}", title: t(title) } \ No newline at end of file diff --git a/app/views/shared/buttons/_add_photo.haml b/app/views/shared/buttons/_add_photo.haml index 425ca52fc..0e4a75c07 100644 --- a/app/views/shared/buttons/_add_photo.haml +++ b/app/views/shared/buttons/_add_photo.haml @@ -1,4 +1,4 @@ - if can?(:create, Photo) = link_to path, class: 'btn btn-default btn-xs' do - %span.glyphicon.glyphicon-camera{ title: t('buttons.add_photo') } + = render 'shared/glyphicon', icon: 'camera', title: 'buttons.add_photo' =t('buttons.add_photo') diff --git a/app/views/shared/buttons/_delete.haml b/app/views/shared/buttons/_delete.haml index f4ae4f5cd..8be23926a 100644 --- a/app/views/shared/buttons/_delete.haml +++ b/app/views/shared/buttons/_delete.haml @@ -1,4 +1,4 @@ = link_to path, method: :delete, data: { confirm: t(:are_you_sure?) }, class: 'btn btn-default btn-xs' do - %span.glyphicon.glyphicon-trash{ title: t('buttons.delete') } + = render 'shared/glyphicon', icon: 'trash', title: 'buttons.delete' =t('buttons.delete') diff --git a/app/views/shared/buttons/_edit.haml b/app/views/shared/buttons/_edit.haml index 1ad2fc77e..f7f75ea36 100644 --- a/app/views/shared/buttons/_edit.haml +++ b/app/views/shared/buttons/_edit.haml @@ -1,3 +1,3 @@ = link_to path, class: 'btn btn-default btn-xs' do - %span.glyphicon.glyphicon-pencil{ title: t('buttons.edit') } + = render 'shared/glyphicon', icon: 'pencil', title: 'buttons.edit' =t('buttons.edit') diff --git a/app/views/shared/buttons/_finish_planting.html.haml b/app/views/shared/buttons/_finish_planting.html.haml index 5d49418a1..d0a931b41 100644 --- a/app/views/shared/buttons/_finish_planting.html.haml +++ b/app/views/shared/buttons/_finish_planting.html.haml @@ -1,5 +1,5 @@ - if can?(:edit, planting) && !planting.finished = link_to planting_path(planting, planting: { finished: 1 }), method: :put, class: 'btn btn-default btn-xs append-date' do - %span.glyphicon.glyphicon-ok{ title: t('buttons.finished') } - =t('buttons.mark_as_finished') + = render 'shared/glyphicon', icon: 'ok', title: 'buttons.finished' + = t('buttons.mark_as_finished') diff --git a/app/views/shared/buttons/_finish_seeds.haml b/app/views/shared/buttons/_finish_seeds.haml index 4589e50f2..23316d861 100644 --- a/app/views/shared/buttons/_finish_seeds.haml +++ b/app/views/shared/buttons/_finish_seeds.haml @@ -1,5 +1,5 @@ - unless seed.finished = link_to seed_path(seed, seed: { finished: 1 }), method: :put, class: 'btn btn-default btn-xs append-date' do - %span.glyphicon.glyphicon-ok{ title: t('buttons.finished') } + = render 'shared/glyphicon', icon: 'ok', title: 'buttons.finished' =t('buttons.mark_as_finished') diff --git a/app/views/shared/buttons/_harvest_planting.haml b/app/views/shared/buttons/_harvest_planting.haml index d81b18fa2..296ee30a0 100644 --- a/app/views/shared/buttons/_harvest_planting.haml +++ b/app/views/shared/buttons/_harvest_planting.haml @@ -1,4 +1,4 @@ - planting.active? && if can?(:create, Harvest) && can?(:edit, planting) = link_to new_planting_harvest_path(planting), class: 'btn btn-default btn-xs' do - %span.glyphicon.glyphicon-leaf{ title: = t('buttons.harvest') } + = render 'shared/glyphicon', icon: 'leaf', title: 'buttons.harvest' = t('buttons.harvest') diff --git a/app/views/shared/buttons/_save_seeds.haml b/app/views/shared/buttons/_save_seeds.haml index d18807b2b..d4cf794f5 100644 --- a/app/views/shared/buttons/_save_seeds.haml +++ b/app/views/shared/buttons/_save_seeds.haml @@ -1,4 +1,4 @@ - if planting.active? = link_to new_planting_seed_path(planting), class: 'btn btn-default btn-xs' do - %span.glyphicon.glyphicon-heart{ title: t('buttons.save_seeds') } + = render 'shared/glyphicon', icon: 'heart', title: 'buttons.save_seeds' = t('buttons.save_seeds') From 2f271da9099399c0b75f6c2db832088882cf55bd Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Mon, 21 Jan 2019 14:13:36 +1300 Subject: [PATCH 140/207] Move global buttons and search --- app/views/crops/_search_bar.haml | 9 ++ app/views/layouts/_header.html.haml | 107 +++++++++++------------- app/views/layouts/application.html.haml | 21 ++--- 3 files changed, 69 insertions(+), 68 deletions(-) create mode 100644 app/views/crops/_search_bar.haml diff --git a/app/views/crops/_search_bar.haml b/app/views/crops/_search_bar.haml new file mode 100644 index 000000000..390c32390 --- /dev/null +++ b/app/views/crops/_search_bar.haml @@ -0,0 +1,9 @@ += form_tag crops_search_path, method: :get, id: 'navbar-search' do + = label_tag :term, "Search crop database:", class: 'sr-only' + .input + .input-group + = text_field_tag 'term', nil, class: 'search-query input-medium form-control', placeholder: 'Search crops' + .input-group-btn + %button.btn.btn-default{ style: "height: 34px;" } + = submit_tag "Search", class: 'btn sr-only' + %span.glyphicon.glyphicon-search diff --git a/app/views/layouts/_header.html.haml b/app/views/layouts/_header.html.haml index d2b8fd01c..ca6bf15bc 100644 --- a/app/views/layouts/_header.html.haml +++ b/app/views/layouts/_header.html.haml @@ -17,72 +17,67 @@ alt: ENV['GROWSTUFF_SITE_NAME']) .form.navbar-form.pull-left - = form_tag crops_search_path, method: :get, id: 'navbar-search' do - = label_tag :term, "Search crop database:", class: 'sr-only' - .input - .input-group - = text_field_tag 'term', nil, class: 'search-query input-medium form-control', placeholder: 'Search crops' - .input-group-btn - %button.btn.btn-default{ style: "height: 34px;" } - = submit_tag "Search", class: 'btn sr-only' - %span.glyphicon.glyphicon-search + = render 'crops/search_bar' .navbar-collapse.collapse#navbar-collapse - %ul.nav.navbar-nav.navbar-right - %li.dropdown< - %a.dropdown-toggle{ 'data-toggle': 'dropdown', href: crops_path } - = t('.crops') - %b.caret - %ul.dropdown-menu - %li= link_to t('.browse_crops'), crops_path - %li= link_to t('.seeds'), seeds_path - %li= link_to t('.plantings'), plantings_path - %li= link_to t('.harvests'), harvests_path - %li.dropdown< - %a.dropdown-toggle{ 'data-toggle': 'dropdown', href: members_path } - = t('.community') - %b.caret - %ul.dropdown-menu - %li= link_to t('.community_map'), places_path - %li= link_to t('.browse_members'), members_path - %li= link_to t('.posts'), posts_path - %li= link_to t('.forums'), forums_path - - - if member_signed_in? + .navbar-right + = render 'shared/global_actions' + %ul.nav.navbar-nav.navbar-right %li.dropdown< - %a.dropdown-toggle{ 'data-toggle': 'dropdown', href: root_path } - - if current_member.notifications.unread_count.positive? - = t('.your_stuff', unread_count: current_member.notifications.unread_count) - - else - = t('.current_memberlogin_name', current_memberlogin_name: current_member.login_name) + %a.dropdown-toggle{ 'data-toggle': 'dropdown', href: crops_path } + = t('.crops') %b.caret %ul.dropdown-menu - %li= link_to t('.profile'), member_path(current_member) - %li= link_to t('.gardens'), gardens_by_owner_path(owner: current_member.slug) - %li= link_to t('.plantings'), plantings_by_owner_path(owner: current_member.slug) - %li= link_to t('.harvest'), harvests_by_owner_path(owner: current_member.slug) - %li= link_to t('.seeds'), seeds_by_owner_path(owner: current_member.slug) - %li= link_to t('.posts'), posts_by_author_path(author: current_member.slug) - %li + %li= link_to t('.browse_crops'), crops_path + %li= link_to t('.seeds'), seeds_path + %li= link_to t('.plantings'), plantings_path + %li= link_to t('.harvests'), harvests_path + %li.dropdown< + %a.dropdown-toggle{ 'data-toggle': 'dropdown', href: members_path } + = t('.community') + %b.caret + %ul.dropdown-menu + %li= link_to t('.community_map'), places_path + %li= link_to t('.browse_members'), members_path + %li= link_to t('.posts'), posts_path + %li= link_to t('.forums'), forums_path + + - if member_signed_in? + %li.dropdown< + %a.dropdown-toggle{ 'data-toggle': 'dropdown', href: root_path } - if current_member.notifications.unread_count.positive? - = link_to(t('.inbox_unread', unread_count: current_member.notifications.unread_count), - notifications_path) + = t('.your_stuff', unread_count: current_member.notifications.unread_count) - else - = link_to(t('.inbox'), notifications_path) - - if current_member.role?(:crop_wrangler) || current_member.role?(:admin) - %li.divider{ role: 'presentation' } - - if current_member.role?(:crop_wrangler) - %li= link_to t('.crop_wrangling'), wrangle_crops_path - - if current_member.role?(:admin) - %li= link_to t('.admin'), admin_path + = t('.current_memberlogin_name', current_memberlogin_name: current_member.login_name) + %b.caret + %ul.dropdown-menu + %li= link_to t('.profile'), member_path(current_member) + %li= link_to t('.gardens'), gardens_by_owner_path(owner: current_member.slug) + %li= link_to t('.plantings'), plantings_by_owner_path(owner: current_member.slug) + %li= link_to t('.harvest'), harvests_by_owner_path(owner: current_member.slug) + %li= link_to t('.seeds'), seeds_by_owner_path(owner: current_member.slug) + %li= link_to t('.posts'), posts_by_author_path(author: current_member.slug) + %li + - if current_member.notifications.unread_count.positive? + = link_to(t('.inbox_unread', unread_count: current_member.notifications.unread_count), + notifications_path) + - else + = link_to(t('.inbox'), notifications_path) + - if current_member.role?(:crop_wrangler) || current_member.role?(:admin) + %li.divider{ role: 'presentation' } + - if current_member.role?(:crop_wrangler) + %li= link_to t('.crop_wrangling'), wrangle_crops_path + - if current_member.role?(:admin) + %li= link_to t('.admin'), admin_path - %li= link_to t('.sign_out'), destroy_member_session_path, method: :delete - - - else - %li= link_to t('.sign_in'), new_member_session_path, id: 'navbar-signin' - %li= link_to t('.sign_up'), new_member_registration_path, id: 'navbar-signup' + %li= link_to t('.sign_out'), destroy_member_session_path, method: :delete + - else + %li= link_to t('.sign_in'), new_member_session_path, id: 'navbar-signin' + %li= link_to t('.sign_up'), new_member_registration_path, id: 'navbar-signup' + -# anchor tag for accessibility link to skip the navigation menu %a{ name: 'skipnav' } + diff --git a/app/views/layouts/application.html.haml b/app/views/layouts/application.html.haml index 34dbbdfe5..8fc527ff1 100644 --- a/app/views/layouts/application.html.haml +++ b/app/views/layouts/application.html.haml @@ -6,19 +6,16 @@ = render partial: "layouts/header" #maincontainer - .row - .col-md-12 - = render 'shared/global_actions' - - if content_for?(:title) - %h1#title - = yield(:title) - - if content_for?(:subtitle) - %small= yield(:subtitle) + - if content_for?(:title) + %h1#title + = yield(:title) + - if content_for?(:subtitle) + %small= yield(:subtitle) - - if content_for?(:buttonbar) - .btn-group.layout-actions= yield(:buttonbar) - = render partial: "shared/flash_messages", flash: flash - = yield + - if content_for?(:buttonbar) + .btn-group.layout-actions= yield(:buttonbar) + = render partial: "shared/flash_messages", flash: flash + = yield %footer = render partial: "layouts/footer" From acc100f744d88d61bd2cf9e786e0adea33c74924 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Mon, 21 Jan 2019 14:19:40 +1300 Subject: [PATCH 141/207] Adding missing translations for plantings --- config/locales/en.yml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/config/locales/en.yml b/config/locales/en.yml index 7f2778983..4b104ab81 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -225,6 +225,13 @@ en: index: title: "%{site_name} Community Map" plantings: + badges: + days_until_finished: days until finished + days_until_harvest: days until harvest + harvesting_now: harvesting now + late_finishing: late finishing + sharedbuttonsfinish_planting: shared/buttons/finish_planting + super_late: super late form: finish_helper: > A planting is finished when you've harvested all of the crop, or it dies, or it's otherwise From 6eebc7480c9e4fd8a722fb8b8c9a4c06b679dbbb Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Mon, 21 Jan 2019 18:41:51 +1300 Subject: [PATCH 142/207] Moved global actions - only show if no buttonbar --- app/views/layouts/_header.html.haml | 1 - app/views/layouts/application.html.haml | 24 ++++++++++++++++-------- 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/app/views/layouts/_header.html.haml b/app/views/layouts/_header.html.haml index ca6bf15bc..990a23c76 100644 --- a/app/views/layouts/_header.html.haml +++ b/app/views/layouts/_header.html.haml @@ -21,7 +21,6 @@ .navbar-collapse.collapse#navbar-collapse .navbar-right - = render 'shared/global_actions' %ul.nav.navbar-nav.navbar-right %li.dropdown< %a.dropdown-toggle{ 'data-toggle': 'dropdown', href: crops_path } diff --git a/app/views/layouts/application.html.haml b/app/views/layouts/application.html.haml index 8fc527ff1..2b1c2e982 100644 --- a/app/views/layouts/application.html.haml +++ b/app/views/layouts/application.html.haml @@ -6,15 +6,23 @@ = render partial: "layouts/header" #maincontainer - - if content_for?(:title) - %h1#title - = yield(:title) - - if content_for?(:subtitle) - %small= yield(:subtitle) - - - if content_for?(:buttonbar) - .btn-group.layout-actions= yield(:buttonbar) = render partial: "shared/flash_messages", flash: flash + .row + .col-md-8 + - if content_for?(:title) + %h1#title + = yield(:title) + - if content_for?(:subtitle) + %small= yield(:subtitle) + + + + .col-md-4 + - if content_for?(:buttonbar) + .btn-group.layout-actions= yield(:buttonbar) + - else + = render 'shared/global_actions' + = yield %footer From 279ce38c86cf19048fb0ec897668deb3d2c2bdd6 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Mon, 21 Jan 2019 18:42:02 +1300 Subject: [PATCH 143/207] Moving actions to the button bar --- app/views/crops/_wrangle.html.haml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/app/views/crops/_wrangle.html.haml b/app/views/crops/_wrangle.html.haml index 8e8f87558..16b7ed23b 100644 --- a/app/views/crops/_wrangle.html.haml +++ b/app/views/crops/_wrangle.html.haml @@ -4,11 +4,11 @@ You are a = succeed "." do %strong CROP WRANGLER - %p + - content_for(:buttonbar) do - if can? :edit, crop - = link_to 'Edit crop', edit_crop_path(crop), class: 'btn btn-default btn-xs' + = link_to t(:edit_crop), edit_crop_path(crop), class: 'btn btn-default' - if can? :destroy, crop = link_to 'Delete crop', crop, method: :delete, - data: { confirm: 'Are you sure?' }, - class: 'btn btn-default btn-xs' + data: { confirm: t('are_you_sure') }, + class: 'btn btn-default' From f5a63d770c57b22543fd97d52f72d3a3116ae39d Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Mon, 21 Jan 2019 18:42:13 +1300 Subject: [PATCH 144/207] Moving garden actions to button bar --- app/views/gardens/show.html.haml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/app/views/gardens/show.html.haml b/app/views/gardens/show.html.haml index 8b45b0b16..b71f09c78 100644 --- a/app/views/gardens/show.html.haml +++ b/app/views/gardens/show.html.haml @@ -16,7 +16,8 @@ .row .col-md-9 - = render 'gardens/actions', garden: @garden + -content_for(:buttonbar) do + = render 'gardens/actions', garden: @garden - unless @garden.active @@ -57,7 +58,7 @@ - if @finished_plantings.size.positive? - @finished_plantings.each do |planting| .col-xs-6.col-md-2 - = render partial: "plantings/thumbnail", locals: { planting: planting } + = render "plantings/thumbnail", planting: planting - else %p Nothing has been planted here. .col-md-3 From a4f20bff7783f1a71d31309e6885995882d2b603 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Mon, 21 Jan 2019 18:42:21 +1300 Subject: [PATCH 145/207] More button label translations --- config/locales/en.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/config/locales/en.yml b/config/locales/en.yml index 4b104ab81..17a7acc36 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -63,14 +63,17 @@ en: seed: one: seed other: seeds + are_you_sure: 'Are you sure?' buttons: add_photo: Add photo delete: Delete edit: Edit harvest: Harvest + harvest_crop: Harvest %{crop_name} harvest_something: Harvest something mark_as_finished: Mark as finished plant_something: Plant something + plant_crop: Plant %{crop_name} save_seeds: Save seeds write_blog_post: Write blog post crops: From 614eff06b98a206f42d407b80047fdf68f5657d2 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Mon, 21 Jan 2019 18:42:34 +1300 Subject: [PATCH 146/207] Bigger buttons --- app/views/shared/_global_actions.html.haml | 13 +++++++------ app/views/shared/buttons/_edit.haml | 2 +- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/app/views/shared/_global_actions.html.haml b/app/views/shared/_global_actions.html.haml index 59481c858..2b5ca1168 100644 --- a/app/views/shared/_global_actions.html.haml +++ b/app/views/shared/_global_actions.html.haml @@ -1,6 +1,7 @@ -%p - .btn-group - = link_to t('buttons.plant_something'), new_planting_path, class: 'btn btn-default' - = link_to t('buttons.harvest_something'), new_harvest_path, class: 'btn btn-default' - = link_to t('buttons.save_seeds'), new_seed_path, class: 'btn btn-default' - = link_to t('buttons.write_blog_post'), new_post_path, class: 'btn btn-default' +.btn-group + = link_to t('buttons.plant_something'), new_planting_path, class: 'btn btn-default' + = link_to t('buttons.harvest_something'), new_harvest_path, class: 'btn btn-default' + = link_to t('buttons.save_seeds'), new_seed_path, class: 'btn btn-default' + +.btn-group + = link_to t('buttons.write_blog_post'), new_post_path, class: 'btn btn-default' diff --git a/app/views/shared/buttons/_edit.haml b/app/views/shared/buttons/_edit.haml index f7f75ea36..f80cdf917 100644 --- a/app/views/shared/buttons/_edit.haml +++ b/app/views/shared/buttons/_edit.haml @@ -1,3 +1,3 @@ -= link_to path, class: 'btn btn-default btn-xs' do += link_to path, class: 'btn btn-default' do = render 'shared/glyphicon', icon: 'pencil', title: 'buttons.edit' =t('buttons.edit') From fcfe7f196e746b3f58649a57174c28948583ba2b Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Mon, 21 Jan 2019 18:42:44 +1300 Subject: [PATCH 147/207] Button for planting stuff --- app/views/shared/buttons/_plant.html.haml | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 app/views/shared/buttons/_plant.html.haml diff --git a/app/views/shared/buttons/_plant.html.haml b/app/views/shared/buttons/_plant.html.haml new file mode 100644 index 000000000..8044dddef --- /dev/null +++ b/app/views/shared/buttons/_plant.html.haml @@ -0,0 +1,3 @@ += link_to new_planting_path(garden_id: garden.id), class: 'btn btn-default' do + = render 'shared/glyphicon', icon: 'grain', title: 'buttons.plant' + = t('buttons.plant_something_here') \ No newline at end of file From d1c367e3d909cc0cd55e7a5afedc25f6399115aa Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Mon, 21 Jan 2019 18:42:52 +1300 Subject: [PATCH 148/207] Fixed glyphicons --- app/views/shared/_glyphicon.html.haml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/shared/_glyphicon.html.haml b/app/views/shared/_glyphicon.html.haml index 39f2546cf..dd34405cc 100644 --- a/app/views/shared/_glyphicon.html.haml +++ b/app/views/shared/_glyphicon.html.haml @@ -1 +1 @@ -%span{class: "glyphicon.glyphicon-#{icon}", title: t(title) } \ No newline at end of file +%span.glyphicon{class: "glyphicon-#{icon}", title: t(title) } \ No newline at end of file From ba3863739254432fecae9d18fe99085c3bf51da8 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Mon, 21 Jan 2019 18:43:07 +1300 Subject: [PATCH 149/207] Wrapping crop actions in btn-group --- app/views/crops/_actions.html.haml | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/app/views/crops/_actions.html.haml b/app/views/crops/_actions.html.haml index e15979f61..b27f4b89a 100644 --- a/app/views/crops/_actions.html.haml +++ b/app/views/crops/_actions.html.haml @@ -1,9 +1,10 @@ .crop-actions - - if can? :create, Planting - = link_to "Plant this", new_planting_path(crop_id: crop.id), class: 'btn btn-default' + .btn-group + - if can? :create, Planting + = link_to t('buttons.plant_crop', crop_name: crop.name), new_planting_path(crop_id: crop.id), class: 'btn btn-default' - - if can? :create, Harvest - = link_to "Harvest this", new_harvest_path(crop_id: crop.id), class: 'btn btn-default' + - if can? :create, Harvest + = link_to t('buttons.harvest_crop', crop_name: crop.name), new_harvest_path(crop_id: crop.id), class: 'btn btn-default' - - if can? :create, Seed - = link_to 'Add seeds to stash', new_seed_path(params: { crop_id: crop.id }), class: 'btn btn-default' + - if can? :create, Seed + = link_to t('buttons.add_seed_to_stash'), new_seed_path(params: { crop_id: crop.id }), class: 'btn btn-default' From de3c7fb1c51cf0539ebf6cffce021da82dc10494 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Mon, 21 Jan 2019 18:43:25 +1300 Subject: [PATCH 150/207] Move homepage title to the :title content --- app/views/home/index.html.haml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/home/index.html.haml b/app/views/home/index.html.haml index 0259ce590..be274c930 100644 --- a/app/views/home/index.html.haml +++ b/app/views/home/index.html.haml @@ -1,7 +1,7 @@ .homepage.row .col-md-12 - if member_signed_in? - %h1= t('.welcome', site_name: ENV['GROWSTUFF_SITE_NAME'], member_name: current_member) + - content_for :title, t('.welcome', site_name: ENV['GROWSTUFF_SITE_NAME'], member_name: current_member) = render 'stats' - else From b86e6e6dab7773ed762f218609a6a878cc7cfb43 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Mon, 21 Jan 2019 18:43:37 +1300 Subject: [PATCH 151/207] More translations in garden actions --- app/views/gardens/_actions.html.haml | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/app/views/gardens/_actions.html.haml b/app/views/gardens/_actions.html.haml index a5187991e..5ff23e09a 100644 --- a/app/views/gardens/_actions.html.haml +++ b/app/views/gardens/_actions.html.haml @@ -2,28 +2,29 @@ - if can?(:edit, garden) .btn-group - if garden.active - = link_to new_planting_path(garden_id: garden.id), class: 'btn btn-default btn-xs' do - %span.glyphicon.glyphicon-grain{ title: "Plant" } - Plant something - = link_to "Mark as inactive", garden_path(garden, garden: { active: 0 }), - method: :put, class: 'btn btn-default btn-xs', + = render 'shared/buttons/plant', garden: garden + = render 'shared/glyphicon', icon: 'ban', title: 'buttons.mark_as_inactive' + = link_to t('buttons.mark_as_inactive'), garden_path(garden, garden: { active: 0 }), + method: :put, class: 'btn btn-default', data: { confirm: 'All plantings associated with this garden will be marked as finished. Are you sure?' } - else + = render 'shared/glyphicon', icon: 'check', title: 'buttons.mark_active' = link_to "Mark as active", garden_path(garden, garden: { active: 1 }), method: :put + = render 'shared/buttons/edit', path: edit_garden_path(garden) - if can?(:edit, garden) && can?(:create, Photo) = link_to new_photo_path(type: "garden", id: garden.id), - class: 'btn btn-default btn-xs' do + class: 'btn btn-default' do %span.glyphicon.glyphicon-camera{ title: "Add photo" } - Add photo + = t('buttons.add_a_photo') - if can?(:destroy, garden) .pull-right = link_to garden_path(garden), method: :delete, data: { confirm: 'All plantings associated with this garden will also be deleted. Are you sure?' }, - class: 'btn btn-default btn-xs', id: 'delete_garden_link' do + class: 'btn btn-default', id: 'delete_garden_link' do %span.glyphicon.glyphicon-trash{ title: "Delete" } - Delete + = t('buttons.delete_this_garden') From 67e58fe9018a2c03f65cf8b88b24a202ac9d4863 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Tue, 22 Jan 2019 15:19:24 +1300 Subject: [PATCH 152/207] Moving buttons to the right of page (with translations) --- app/helpers/buttons_helper.rb | 66 ++++++++++++++++++++++ app/views/crops/_actions.html.haml | 9 ++- app/views/crops/_wrangle.html.haml | 14 +++-- app/views/gardens/_actions.html.haml | 25 ++------ app/views/layouts/application.html.haml | 11 ++-- app/views/plantings/_actions.html.haml | 17 +++--- app/views/shared/_global_actions.html.haml | 24 ++++++-- app/views/shared/_glyphicon.html.haml | 3 +- config/locales/en.yml | 36 ++++++++---- 9 files changed, 144 insertions(+), 61 deletions(-) create mode 100644 app/helpers/buttons_helper.rb diff --git a/app/helpers/buttons_helper.rb b/app/helpers/buttons_helper.rb new file mode 100644 index 000000000..4dbf7015a --- /dev/null +++ b/app/helpers/buttons_helper.rb @@ -0,0 +1,66 @@ +module ButtonsHelper + def garden_plant_something_button(garden) + button(new_planting_path(garden_id: garden.id), 'buttons.plant_something_here', 'leaf') + end + + def garden_mark_active(garden) + link_to t('buttons.mark_as_active'), garden_path(garden, garden: { active: 1 }), method: :put, class: 'btn btn-default btn-xs' + end + + def garden_mark_inactive(garden) + link_to t('buttons.mark_as_inactive'), + garden_path(garden, garden: { active: 0 }), + method: :put, class: 'btn btn-default btn-xs', + data: { confirm: 'All plantings associated with this garden will be marked as finished. Are you sure?' } + end + + def garden_add_photo_button(garden) + button(new_photo_path(id: garden.id, type: "garden"), 'buttons.add_a_photo', 'camera') + end + + def garden_edit_button(garden) + button(edit_garden_path(garden), 'buttons.edit', 'pencil') + end + + def planting_edit_button(planting) + button(edit_planting_path(planting), 'buttons.edit', 'pencil') + end + + def planting_add_photo_button(planting) + button(new_photo_path(id: planting.id, type: 'planting'), 'buttons.add_photo', 'camera') + end + + def planting_finish_button(planting) + if can?(:edit, planting) + button( + planting_path(planting, planting: { finished: 1 }), + 'buttons.mark_as_finished', + 'ok' + ) + end + end + + def planting_harvest_button(planting) + if planting.active? && can?(:create, Harvest) && can?(:edit, planting) + button(new_planting_harvest_path(planting), 'buttons.harvest', 'apple') + end + end + + def planting_save_seeds_button(planting) + button(new_planting_seed_path(planting), 'buttons.save_seeds', 'heart') if can?(:edit, planting) + end + + def delete_button(model, message: 'are_you_sure') + link_to model, method: :delete, data: { confirm: t(message) }, class: 'btn btn-default btn-xs' do + render 'shared/glyphicon', icon: 'trash', title: 'buttons.delete' + end + end + + private + + def button(path, title, icon, size = 'btn-xs') + link_to path, class: "btn btn-default #{size}" do + render 'shared/glyphicon', icon: icon, title: title + end + end +end diff --git a/app/views/crops/_actions.html.haml b/app/views/crops/_actions.html.haml index b27f4b89a..5cc80036b 100644 --- a/app/views/crops/_actions.html.haml +++ b/app/views/crops/_actions.html.haml @@ -1,10 +1,13 @@ .crop-actions .btn-group - if can? :create, Planting - = link_to t('buttons.plant_crop', crop_name: crop.name), new_planting_path(crop_id: crop.id), class: 'btn btn-default' + = link_to new_planting_path(crop_id: crop.id), class: 'btn btn-default' do + = t('buttons.plant_crop', crop_name: crop.name) - if can? :create, Harvest - = link_to t('buttons.harvest_crop', crop_name: crop.name), new_harvest_path(crop_id: crop.id), class: 'btn btn-default' + = link_to new_harvest_path(crop_id: crop.id), class: 'btn btn-default' do + = t('buttons.harvest_crop', crop_name: crop.name) - if can? :create, Seed - = link_to t('buttons.add_seed_to_stash'), new_seed_path(params: { crop_id: crop.id }), class: 'btn btn-default' + = link_to new_seed_path(crop_id: crop.id), class: 'btn btn-default' do + = t('buttons.add_seed_to_stash', crop_name: crop.name) diff --git a/app/views/crops/_wrangle.html.haml b/app/views/crops/_wrangle.html.haml index 16b7ed23b..fafafd490 100644 --- a/app/views/crops/_wrangle.html.haml +++ b/app/views/crops/_wrangle.html.haml @@ -4,11 +4,13 @@ You are a = succeed "." do %strong CROP WRANGLER - - content_for(:buttonbar) do - - if can? :edit, crop + + - if can? :edit, crop + %p = link_to t(:edit_crop), edit_crop_path(crop), class: 'btn btn-default' - - if can? :destroy, crop + - if can? :destroy, crop + %p = link_to 'Delete crop', crop, - method: :delete, - data: { confirm: t('are_you_sure') }, - class: 'btn btn-default' + method: :delete, + data: { confirm: t('are_you_sure') }, + class: 'btn btn-default' diff --git a/app/views/gardens/_actions.html.haml b/app/views/gardens/_actions.html.haml index 5ff23e09a..54842b577 100644 --- a/app/views/gardens/_actions.html.haml +++ b/app/views/gardens/_actions.html.haml @@ -2,29 +2,16 @@ - if can?(:edit, garden) .btn-group - if garden.active - = render 'shared/buttons/plant', garden: garden - = render 'shared/glyphicon', icon: 'ban', title: 'buttons.mark_as_inactive' - = link_to t('buttons.mark_as_inactive'), garden_path(garden, garden: { active: 0 }), - method: :put, class: 'btn btn-default', - data: { confirm: 'All plantings associated with this garden will be marked as finished. Are you sure?' } + = garden_plant_something_button(garden) + = garden_mark_inactive(garden) - else - = render 'shared/glyphicon', icon: 'check', title: 'buttons.mark_active' - = link_to "Mark as active", garden_path(garden, garden: { active: 1 }), - method: :put + = garden_mark_active(garden) - = render 'shared/buttons/edit', path: edit_garden_path(garden) + = garden_edit_button(garden) - if can?(:edit, garden) && can?(:create, Photo) - = link_to new_photo_path(type: "garden", id: garden.id), - class: 'btn btn-default' do - %span.glyphicon.glyphicon-camera{ title: "Add photo" } - = t('buttons.add_a_photo') + = garden_add_photo_button(garden) - if can?(:destroy, garden) .pull-right - = link_to garden_path(garden), - method: :delete, - data: { confirm: 'All plantings associated with this garden will also be deleted. Are you sure?' }, - class: 'btn btn-default', id: 'delete_garden_link' do - %span.glyphicon.glyphicon-trash{ title: "Delete" } - = t('buttons.delete_this_garden') + = delete_button(garden, message: 'All plantings associated with this garden will also be deleted. Are you sure?') diff --git a/app/views/layouts/application.html.haml b/app/views/layouts/application.html.haml index 2b1c2e982..3ac9f7cf6 100644 --- a/app/views/layouts/application.html.haml +++ b/app/views/layouts/application.html.haml @@ -14,15 +14,14 @@ = yield(:title) - if content_for?(:subtitle) %small= yield(:subtitle) - - + + - if content_for?(:buttonbar) + .btn-group.layout-actions + = yield(:buttonbar) .col-md-4 - - if content_for?(:buttonbar) - .btn-group.layout-actions= yield(:buttonbar) - - else - = render 'shared/global_actions' + = render 'shared/global_actions' = yield %footer diff --git a/app/views/plantings/_actions.html.haml b/app/views/plantings/_actions.html.haml index 6f5b1b93d..ca3fceefc 100644 --- a/app/views/plantings/_actions.html.haml +++ b/app/views/plantings/_actions.html.haml @@ -1,12 +1,13 @@ - if can?(:edit, planting) - .btn-group.planting-actions - = render 'shared/buttons/edit', path: edit_planting_path(planting) - = render 'shared/buttons/add_photo', path: new_photo_path(id: planting.id, type: 'planting') + .planting-actions + .btn-group + = planting_edit_button(planting) + = planting_add_photo_button(planting) - - if planting.active? - = render 'shared/buttons/finish_planting', planting: planting - = render 'shared/buttons/harvest_planting', planting: planting - = render 'shared/buttons/save_seeds', planting: planting + - if planting.active? + = planting_finish_button(planting) + = planting_harvest_button(planting) + = planting_save_seeds_button(planting) - if can? :destroy, planting - = render 'shared/buttons/delete', path: planting + = delete_button(planting) diff --git a/app/views/shared/_global_actions.html.haml b/app/views/shared/_global_actions.html.haml index 2b5ca1168..29b2f1ef3 100644 --- a/app/views/shared/_global_actions.html.haml +++ b/app/views/shared/_global_actions.html.haml @@ -1,7 +1,19 @@ -.btn-group - = link_to t('buttons.plant_something'), new_planting_path, class: 'btn btn-default' - = link_to t('buttons.harvest_something'), new_harvest_path, class: 'btn btn-default' - = link_to t('buttons.save_seeds'), new_seed_path, class: 'btn btn-default' +- if signed_in? + .global-actions + .btn-group + = link_to gardens_by_owner_path(owner: current_member.slug), class: 'btn btn-default' do + = t('links.my_gardens') -.btn-group - = link_to t('buttons.write_blog_post'), new_post_path, class: 'btn btn-default' + .btn-group + = link_to new_planting_path, class: 'btn btn-default' do + = t('buttons.plant') + = link_to new_harvest_path, class: 'btn btn-default' do + = t('buttons.harvest') + = link_to new_seed_path, class: 'btn btn-default' do + = t('buttons.save_seeds') + + .btn-group + = link_to t('buttons.write_blog_post'), new_post_path, class: 'btn btn-default' + +- content_for(:attributions) do + seed by Template from the Noun Project \ No newline at end of file diff --git a/app/views/shared/_glyphicon.html.haml b/app/views/shared/_glyphicon.html.haml index dd34405cc..65cba2bdd 100644 --- a/app/views/shared/_glyphicon.html.haml +++ b/app/views/shared/_glyphicon.html.haml @@ -1 +1,2 @@ -%span.glyphicon{class: "glyphicon-#{icon}", title: t(title) } \ No newline at end of file +%span.glyphicon{class: "glyphicon-#{icon}", title: t(title) } +=t(title) \ No newline at end of file diff --git a/config/locales/en.yml b/config/locales/en.yml index 17a7acc36..d850060b2 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -63,17 +63,27 @@ en: seed: one: seed other: seeds - are_you_sure: 'Are you sure?' + application_helper: + title: + title: + default: Default + are_you_sure: Are you sure? buttons: + add: Add add_photo: Add photo + add_seed_to_stash: Add %{crop_name} seeds to stash delete: Delete edit: Edit harvest: Harvest harvest_crop: Harvest %{crop_name} harvest_something: Harvest something + mark_as_active: Mark as active mark_as_finished: Mark as finished - plant_something: Plant something + mark_as_inactive: Mark as inactive + plant: Plant plant_crop: Plant %{crop_name} + plant_something: Plant something + plant_something_here: Plant something here save_seeds: Save seeds write_blog_post: Write blog post crops: @@ -84,6 +94,7 @@ en: link: You have %{number_crops} crops awaiting approval subtitle: Pending approval title: Requested crops + edit_crop: Edit crop forms: optional: "(Optional)" forums: @@ -95,28 +106,25 @@ en: form: location_helper: If you have a location set in your profile, it will be used when you create a new garden. location: "%{owner}'s %{garden}" - updated: Garden was successfully updated. overview: - gardensphoto: gardens/photo - plantingsthumbnail: plantings/thumbnail - no_plantings: no plantings gardensactions: gardens/actions + gardensphoto: gardens/photo + no_plantings: no plantings + plantingsthumbnail: plantings/thumbnail + updated: Garden was successfully updated. harvests: created: Harvest was successfully created. index: title: crop_harvests: Everyone's %{crop} harvests - planting_harvests: Harvests from %{planting} default: Everyone's harvests owner_harvests: "%{owner} harvests" + planting_harvests: Harvests from %{planting} updated: Harvest was successfully updated. home: blurb: already_html: Or %{sign_in} if you already have an account - intro: > - %{site_name} is a community of food gardeners. We're building an open source - platform to help you learn about growing food, track what you plant and harvest, - and swap seeds and produce with other gardeners near you. + intro: "%{site_name} is a community of food gardeners. We're building an open source platform to help you learn about growing food, track what you plant and harvest, and swap seeds and produce with other gardeners near you.\n" perks: Join now for your free garden journal, seed sharing, forums, and more. sign_in_linktext: sign in sign_up: Sign up @@ -135,6 +143,7 @@ en: harvest: Harvest plant: Plant post: Post + recently_added: Recently added welcome: Welcome to %{site_name}, %{member_name} members: title: Some of our members @@ -164,6 +173,8 @@ en: talk_linktext: Growstuff Talk why_linktext: why Growstuff is open source wiki_linktext: Growstuff Wiki + plantings: + recently_planted: Recently planted seeds: crop: Crop description: Description @@ -208,6 +219,8 @@ en: support_growstuff: Support Growstuff toggle_navigation: Toggle Navigation your_stuff: Your Stuff (%{unread_count}) + links: + my_gardens: My gardens members: index: title: "%{site_name} members" @@ -250,7 +263,6 @@ en: badges: late_finishing: late finishing super_late: super late - sharedbuttonsfinish_planting: shared/buttons/finish_planting days_until_finished: days until finished harvesting_now: harvesting now days_until_harvest: days until harvest From 313a18db080736d6f4656863f15ce4017058a305 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Tue, 22 Jan 2019 15:55:41 +1300 Subject: [PATCH 153/207] Titles of pages consistent with buttons to pages --- app/views/harvests/new.html.haml | 2 +- app/views/plantings/new.html.haml | 2 +- app/views/posts/new.html.haml | 2 +- app/views/seeds/new.html.haml | 2 +- config/locales/en.yml | 4 ++++ 5 files changed, 8 insertions(+), 4 deletions(-) diff --git a/app/views/harvests/new.html.haml b/app/views/harvests/new.html.haml index 5b5004622..f3a9dbe75 100644 --- a/app/views/harvests/new.html.haml +++ b/app/views/harvests/new.html.haml @@ -1,3 +1,3 @@ -- content_for :title, "New Harvest" +- content_for :title, t('harvests.harvest_something') = render 'form' diff --git a/app/views/plantings/new.html.haml b/app/views/plantings/new.html.haml index f28af6b19..c509e5646 100644 --- a/app/views/plantings/new.html.haml +++ b/app/views/plantings/new.html.haml @@ -1,3 +1,3 @@ -= content_for :title, "Plant something" += content_for :title, t('plantings.plant_something') = render 'form' diff --git a/app/views/posts/new.html.haml b/app/views/posts/new.html.haml index 75b111f6e..748c290b8 100644 --- a/app/views/posts/new.html.haml +++ b/app/views/posts/new.html.haml @@ -1,3 +1,3 @@ -= content_for :title, @forum ? "Post in #{@forum.name}" : "Post something" += content_for :title, @forum ? "Post in #{@forum.name}" : t('posts.write_blog_post') = render 'form' diff --git a/app/views/seeds/new.html.haml b/app/views/seeds/new.html.haml index 834c958d8..6a59b7050 100644 --- a/app/views/seeds/new.html.haml +++ b/app/views/seeds/new.html.haml @@ -1,3 +1,3 @@ -- content_for :title, "Add seeds" +- content_for :title, t('seeds.save_seeds') = render 'form' diff --git a/config/locales/en.yml b/config/locales/en.yml index d850060b2..850492e09 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -114,6 +114,7 @@ en: updated: Garden was successfully updated. harvests: created: Harvest was successfully created. + harvest_something: Harvest something index: title: crop_harvests: Everyone's %{crop} harvests @@ -248,6 +249,7 @@ en: late_finishing: late finishing sharedbuttonsfinish_planting: shared/buttons/finish_planting super_late: super late + plant_something: Plant something form: finish_helper: > A planting is finished when you've harvested all of the crop, or it dies, or it's otherwise @@ -269,6 +271,7 @@ en: progress: progress_0_not_planted_yet: 'Progress: 0% - not planted yet' posts: + write_blog_post: Write blog post index: title: author_posts: "%{author} posts" @@ -284,6 +287,7 @@ en: crop_seeds: Everyone's %{crop} seeds default: Everyone's seeds owner_seeds: "%{owner} seeds" + save_seeds: Save seeds string: "%{crop} seeds belonging to %{owner}" unauthorized: create: From e2a0278e40204d50e4e0bdab12db89ed25fca45b Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Tue, 22 Jan 2019 16:46:44 +1300 Subject: [PATCH 154/207] Use same t() for the button for writing blog posts --- app/views/shared/_global_actions.html.haml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/shared/_global_actions.html.haml b/app/views/shared/_global_actions.html.haml index 29b2f1ef3..771033c8a 100644 --- a/app/views/shared/_global_actions.html.haml +++ b/app/views/shared/_global_actions.html.haml @@ -13,7 +13,7 @@ = t('buttons.save_seeds') .btn-group - = link_to t('buttons.write_blog_post'), new_post_path, class: 'btn btn-default' + = link_to t('posts.write_blog_post'), new_post_path, class: 'btn btn-default' - content_for(:attributions) do seed by Template from the Noun Project \ No newline at end of file From dfd7765c474d3c478079bd104a1221c213bbfedc Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Tue, 22 Jan 2019 16:48:57 +1300 Subject: [PATCH 155/207] Rubocop fix ups --- app/helpers/buttons_helper.rb | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/app/helpers/buttons_helper.rb b/app/helpers/buttons_helper.rb index 4dbf7015a..f6fe45346 100644 --- a/app/helpers/buttons_helper.rb +++ b/app/helpers/buttons_helper.rb @@ -4,7 +4,9 @@ module ButtonsHelper end def garden_mark_active(garden) - link_to t('buttons.mark_as_active'), garden_path(garden, garden: { active: 1 }), method: :put, class: 'btn btn-default btn-xs' + link_to t('buttons.mark_as_active'), + garden_path(garden, garden: { active: 1 }), + method: :put, class: 'btn btn-default btn-xs' end def garden_mark_inactive(garden) @@ -31,19 +33,19 @@ module ButtonsHelper end def planting_finish_button(planting) - if can?(:edit, planting) - button( - planting_path(planting, planting: { finished: 1 }), - 'buttons.mark_as_finished', - 'ok' - ) - end + return unless can?(:edit, planting) + + button( + planting_path(planting, planting: { finished: 1 }), + 'buttons.mark_as_finished', + 'ok' + ) end def planting_harvest_button(planting) - if planting.active? && can?(:create, Harvest) && can?(:edit, planting) - button(new_planting_harvest_path(planting), 'buttons.harvest', 'apple') - end + return unless planting.active? && can?(:create, Harvest) && can?(:edit, planting) + + button(new_planting_harvest_path(planting), 'buttons.harvest', 'apple') end def planting_save_seeds_button(planting) From 6ced6c5c4e29268834e34b5569bcc0d6b0134c09 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Tue, 22 Jan 2019 16:54:25 +1300 Subject: [PATCH 156/207] Update link label in spec --- spec/features/seeds/misc_seeds_spec.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spec/features/seeds/misc_seeds_spec.rb b/spec/features/seeds/misc_seeds_spec.rb index e095ed390..941d25f00 100644 --- a/spec/features/seeds/misc_seeds_spec.rb +++ b/spec/features/seeds/misc_seeds_spec.rb @@ -21,10 +21,10 @@ feature "seeds", js: true do describe "button on front page to add seeds" do before do visit root_path - click_link "Add seeds" + click_link "Save seeds" end it { expect(current_path).to eq new_seed_path } - it { expect(page).to have_content 'Add seeds' } + it { expect(page).to have_content 'Save seeds' } end describe "Clicking link to owner's profile" do From 8df90dacfcf34ed325061960f9f2788c5ee9a9d9 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Tue, 22 Jan 2019 16:54:54 +1300 Subject: [PATCH 157/207] Seperate specs --- spec/features/gardens/actions_spec.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/spec/features/gardens/actions_spec.rb b/spec/features/gardens/actions_spec.rb index a22ab6886..0f4545714 100644 --- a/spec/features/gardens/actions_spec.rb +++ b/spec/features/gardens/actions_spec.rb @@ -46,9 +46,9 @@ feature "Gardens" do before { visit gardens_path(owner: FactoryBot.create(:member)) } include_examples "has buttons bar at top" - it 'does not show actions on other member garden' do - is_expected.not_to have_link 'Plant something' - is_expected.not_to have_link 'Mark as inactive' + describe 'does not show actions on other member garden' do + it { is_expected.not_to have_link 'Plant something' } + it { is_expected.not_to have_link 'Mark as inactive' } end end end From 02d4d12582fcbecea6fefc95b78859ba2c0a8abe Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Tue, 22 Jan 2019 16:58:13 +1300 Subject: [PATCH 158/207] suffix _button to button helpers --- app/helpers/buttons_helper.rb | 4 ++-- app/views/gardens/_actions.html.haml | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/helpers/buttons_helper.rb b/app/helpers/buttons_helper.rb index f6fe45346..b3ed95a25 100644 --- a/app/helpers/buttons_helper.rb +++ b/app/helpers/buttons_helper.rb @@ -3,13 +3,13 @@ module ButtonsHelper button(new_planting_path(garden_id: garden.id), 'buttons.plant_something_here', 'leaf') end - def garden_mark_active(garden) + def garden_mark_active_button(garden) link_to t('buttons.mark_as_active'), garden_path(garden, garden: { active: 1 }), method: :put, class: 'btn btn-default btn-xs' end - def garden_mark_inactive(garden) + def garden_mark_inactive_button(garden) link_to t('buttons.mark_as_inactive'), garden_path(garden, garden: { active: 0 }), method: :put, class: 'btn btn-default btn-xs', diff --git a/app/views/gardens/_actions.html.haml b/app/views/gardens/_actions.html.haml index 54842b577..656bc0b58 100644 --- a/app/views/gardens/_actions.html.haml +++ b/app/views/gardens/_actions.html.haml @@ -3,9 +3,9 @@ .btn-group - if garden.active = garden_plant_something_button(garden) - = garden_mark_inactive(garden) + = garden_mark_inactive_button(garden) - else - = garden_mark_active(garden) + = garden_mark_active_button(garden) = garden_edit_button(garden) From 8270611f0c1655a223a3b99f1ccd8f00602fb9ca Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Tue, 22 Jan 2019 17:03:34 +1300 Subject: [PATCH 159/207] Removed un-used viewss --- app/views/shared/buttons/_harvest_planting.haml | 4 ---- app/views/shared/buttons/_plant.html.haml | 3 --- app/views/shared/buttons/_save_seeds.haml | 4 ---- 3 files changed, 11 deletions(-) delete mode 100644 app/views/shared/buttons/_harvest_planting.haml delete mode 100644 app/views/shared/buttons/_plant.html.haml delete mode 100644 app/views/shared/buttons/_save_seeds.haml diff --git a/app/views/shared/buttons/_harvest_planting.haml b/app/views/shared/buttons/_harvest_planting.haml deleted file mode 100644 index 296ee30a0..000000000 --- a/app/views/shared/buttons/_harvest_planting.haml +++ /dev/null @@ -1,4 +0,0 @@ -- planting.active? && if can?(:create, Harvest) && can?(:edit, planting) - = link_to new_planting_harvest_path(planting), class: 'btn btn-default btn-xs' do - = render 'shared/glyphicon', icon: 'leaf', title: 'buttons.harvest' - = t('buttons.harvest') diff --git a/app/views/shared/buttons/_plant.html.haml b/app/views/shared/buttons/_plant.html.haml deleted file mode 100644 index 8044dddef..000000000 --- a/app/views/shared/buttons/_plant.html.haml +++ /dev/null @@ -1,3 +0,0 @@ -= link_to new_planting_path(garden_id: garden.id), class: 'btn btn-default' do - = render 'shared/glyphicon', icon: 'grain', title: 'buttons.plant' - = t('buttons.plant_something_here') \ No newline at end of file diff --git a/app/views/shared/buttons/_save_seeds.haml b/app/views/shared/buttons/_save_seeds.haml deleted file mode 100644 index d4cf794f5..000000000 --- a/app/views/shared/buttons/_save_seeds.haml +++ /dev/null @@ -1,4 +0,0 @@ -- if planting.active? - = link_to new_planting_seed_path(planting), class: 'btn btn-default btn-xs' do - = render 'shared/glyphicon', icon: 'heart', title: 'buttons.save_seeds' - = t('buttons.save_seeds') From c811ab1f5151a356d66fb24d7c9ca90dc5f37584 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Tue, 22 Jan 2019 17:11:22 +1300 Subject: [PATCH 160/207] Moved harvest buttons to match other #show pages --- app/views/harvests/show.html.haml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/views/harvests/show.html.haml b/app/views/harvests/show.html.haml index a584389fe..c2c773819 100644 --- a/app/views/harvests/show.html.haml +++ b/app/views/harvests/show.html.haml @@ -8,6 +8,9 @@ = tag("meta", property: "og:url", content: request.original_url) = tag("meta", property: "og:site_name", content: ENV['GROWSTUFF_SITE_NAME']) +-content_for(:buttonbar) do + = render 'harvests/actions', harvest: @harvest + .row .col-md-6 %p @@ -32,7 +35,6 @@ %b Quantity: = display_quantity(@harvest) - = render 'harvests/actions', harvest: @harvest .col-md-6 = render partial: "crops/index_card", locals: { crop: @harvest.crop } From 8ae062fe9beec641b4133f4606a8753ab18cab2b Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Tue, 22 Jan 2019 17:11:30 +1300 Subject: [PATCH 161/207] Added missing harvest actions --- app/helpers/buttons_helper.rb | 8 ++++++++ app/views/harvests/_actions.html.haml | 10 ++++------ 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/app/helpers/buttons_helper.rb b/app/helpers/buttons_helper.rb index b3ed95a25..89b3c95e6 100644 --- a/app/helpers/buttons_helper.rb +++ b/app/helpers/buttons_helper.rb @@ -1,4 +1,12 @@ module ButtonsHelper + def harvest_add_photo_button(harvest) + button(new_photo_path(id: harvest.id, type: "harvest"), 'buttons.add_a_photo', 'camera') + end + + def harvest_edit_button(harvest) + button(edit_harvest_path(harvest), 'buttons.edit', 'pencil') + end + def garden_plant_something_button(garden) button(new_planting_path(garden_id: garden.id), 'buttons.plant_something_here', 'leaf') end diff --git a/app/views/harvests/_actions.html.haml b/app/views/harvests/_actions.html.haml index 2ebfbc8f9..a86cbdb18 100644 --- a/app/views/harvests/_actions.html.haml +++ b/app/views/harvests/_actions.html.haml @@ -1,7 +1,5 @@ .harvest-actions - - if can?(:edit, harvest) || can?(:destroy, harvest) - .btn-group - - if can? :edit, harvest - = render 'shared/buttons/edit', path: edit_harvest_path(harvest) - - if can? :destroy, harvest - .pull-right= render 'shared/buttons/delete', path: harvest_path(harvest) + .btn-group + = harvest_edit_button(harvest) if can? :edit, harvest + = harvest_add_photo_button(harvest) + = delete_button(harvest) if can? :destroy, harvest From b58e0cf3ce091e39657e241acb7aa7bd4130fb8d Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Tue, 22 Jan 2019 17:11:50 +1300 Subject: [PATCH 162/207] Moved garden actions code to top of view --- app/views/gardens/show.html.haml | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/app/views/gardens/show.html.haml b/app/views/gardens/show.html.haml index b71f09c78..2c8ec76d6 100644 --- a/app/views/gardens/show.html.haml +++ b/app/views/gardens/show.html.haml @@ -14,12 +14,11 @@ = javascript_include_tag "charts" = javascript_include_tag "https://www.gstatic.com/charts/loader.js" +-content_for(:buttonbar) do + = render 'gardens/actions', garden: @garden + .row .col-md-9 - -content_for(:buttonbar) do - = render 'gardens/actions', garden: @garden - - - unless @garden.active .alert.alert-warning This garden is inactive. From ad001767e26e517814fe85b99a46128d5b0ddce9 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Tue, 22 Jan 2019 17:15:25 +1300 Subject: [PATCH 163/207] Move seed buttongs to buttons helper --- app/helpers/buttons_helper.rb | 8 ++++++++ app/views/seeds/_actions.html.haml | 7 +++---- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/app/helpers/buttons_helper.rb b/app/helpers/buttons_helper.rb index 89b3c95e6..c1121a04f 100644 --- a/app/helpers/buttons_helper.rb +++ b/app/helpers/buttons_helper.rb @@ -1,4 +1,12 @@ module ButtonsHelper + def seed_add_photo_button(seed) + button(new_photo_path(id: seed.id, type: "seed"), 'buttons.add_a_photo', 'camera') + end + + def seed_edit_button(seed) + button(edit_seed_path(seed), 'buttons.edit', 'pencil') + end + def harvest_add_photo_button(harvest) button(new_photo_path(id: harvest.id, type: "harvest"), 'buttons.add_a_photo', 'camera') end diff --git a/app/views/seeds/_actions.html.haml b/app/views/seeds/_actions.html.haml index 6e1cef334..ea731c16b 100644 --- a/app/views/seeds/_actions.html.haml +++ b/app/views/seeds/_actions.html.haml @@ -1,8 +1,8 @@ .seed-actions - if can? :edit, seed .btn-group - = render 'shared/buttons/edit', path: edit_seed_path(seed) - = render 'shared/buttons/add_photo', path: new_photo_path(id: seed.id, type: 'seed') + = seed_edit_button(seed) + = seed_add_photo_button(seed) - if can?(:create, Planting) && seed.active? = link_to new_planting_path(seed_id: seed), class: 'btn btn-default btn-xs' do @@ -11,5 +11,4 @@ = render 'shared/buttons/finish_seeds', seed: seed - - if can? :destroy, seed - = render 'shared/buttons/delete', path: seed + = delete_button(seed) if can? :destroy, seed From 22e50aa61823cb2d68e12747e6aee37ac9ac98c3 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Tue, 22 Jan 2019 17:20:34 +1300 Subject: [PATCH 164/207] DRY the edit buttons --- app/helpers/buttons_helper.rb | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/app/helpers/buttons_helper.rb b/app/helpers/buttons_helper.rb index c1121a04f..206322dab 100644 --- a/app/helpers/buttons_helper.rb +++ b/app/helpers/buttons_helper.rb @@ -2,18 +2,10 @@ module ButtonsHelper def seed_add_photo_button(seed) button(new_photo_path(id: seed.id, type: "seed"), 'buttons.add_a_photo', 'camera') end - - def seed_edit_button(seed) - button(edit_seed_path(seed), 'buttons.edit', 'pencil') - end def harvest_add_photo_button(harvest) button(new_photo_path(id: harvest.id, type: "harvest"), 'buttons.add_a_photo', 'camera') end - - def harvest_edit_button(harvest) - button(edit_harvest_path(harvest), 'buttons.edit', 'pencil') - end def garden_plant_something_button(garden) button(new_planting_path(garden_id: garden.id), 'buttons.plant_something_here', 'leaf') @@ -35,13 +27,21 @@ module ButtonsHelper def garden_add_photo_button(garden) button(new_photo_path(id: garden.id, type: "garden"), 'buttons.add_a_photo', 'camera') end + + def seed_edit_button(seed) + edit_button(edit_seed_path(seed)) + end + + def harvest_edit_button(harvest) + edit_button(edit_harvest_path(harvest)) + end def garden_edit_button(garden) - button(edit_garden_path(garden), 'buttons.edit', 'pencil') + edit_button(edit_garden_path(garden)) end def planting_edit_button(planting) - button(edit_planting_path(planting), 'buttons.edit', 'pencil') + edit_button(edit_planting_path(planting)) end def planting_add_photo_button(planting) @@ -68,6 +68,10 @@ module ButtonsHelper button(new_planting_seed_path(planting), 'buttons.save_seeds', 'heart') if can?(:edit, planting) end + def edit_button(path) + button(path, 'buttons.edit', 'pencil') + end + def delete_button(model, message: 'are_you_sure') link_to model, method: :delete, data: { confirm: t(message) }, class: 'btn btn-default btn-xs' do render 'shared/glyphicon', icon: 'trash', title: 'buttons.delete' From a8547d60337873d97187ae04a29cb262d66d5fb4 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Tue, 22 Jan 2019 17:20:52 +1300 Subject: [PATCH 165/207] Update labels on button in crop detail spec --- spec/features/crops/crop_detail_page_spec.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/spec/features/crops/crop_detail_page_spec.rb b/spec/features/crops/crop_detail_page_spec.rb index cbc73cf9c..523770bcb 100644 --- a/spec/features/crops/crop_detail_page_spec.rb +++ b/spec/features/crops/crop_detail_page_spec.rb @@ -105,13 +105,13 @@ feature "crop detail page", js: true do background { subject } scenario "has a link to plant the crop" do - expect(page).to have_link "Plant this", href: new_planting_path(crop_id: crop.id) + expect(page).to have_link "Plant #{crop.name}", href: new_planting_path(crop_id: crop.id) end scenario "has a link to harvest the crop" do - expect(page).to have_link "Harvest this", href: new_harvest_path(crop_id: crop.id) + expect(page).to have_link "Harvest #{crop.name}", href: new_harvest_path(crop_id: crop.id) end scenario "has a link to add seeds" do - expect(page).to have_link "Add seeds to stash", href: new_seed_path(crop_id: crop.id) + expect(page).to have_link "Add #{crop.name} seeds to stash", href: new_seed_path(crop_id: crop.id) end end From a95c3a988cf0469845d095b904ada23d2a798322 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Wed, 23 Jan 2019 08:03:57 +1300 Subject: [PATCH 166/207] DRY the add photo buttons --- app/helpers/buttons_helper.rb | 33 +++++++++++++------------- app/views/gardens/_actions.html.haml | 4 +--- app/views/harvests/_actions.html.haml | 4 ++-- app/views/plantings/_actions.html.haml | 2 +- app/views/seeds/_actions.html.haml | 2 +- 5 files changed, 21 insertions(+), 24 deletions(-) diff --git a/app/helpers/buttons_helper.rb b/app/helpers/buttons_helper.rb index 206322dab..994265adc 100644 --- a/app/helpers/buttons_helper.rb +++ b/app/helpers/buttons_helper.rb @@ -1,12 +1,4 @@ module ButtonsHelper - def seed_add_photo_button(seed) - button(new_photo_path(id: seed.id, type: "seed"), 'buttons.add_a_photo', 'camera') - end - - def harvest_add_photo_button(harvest) - button(new_photo_path(id: harvest.id, type: "harvest"), 'buttons.add_a_photo', 'camera') - end - def garden_plant_something_button(garden) button(new_planting_path(garden_id: garden.id), 'buttons.plant_something_here', 'leaf') end @@ -24,14 +16,10 @@ module ButtonsHelper data: { confirm: 'All plantings associated with this garden will be marked as finished. Are you sure?' } end - def garden_add_photo_button(garden) - button(new_photo_path(id: garden.id, type: "garden"), 'buttons.add_a_photo', 'camera') - end - def seed_edit_button(seed) edit_button(edit_seed_path(seed)) end - + def harvest_edit_button(harvest) edit_button(edit_harvest_path(harvest)) end @@ -44,10 +32,6 @@ module ButtonsHelper edit_button(edit_planting_path(planting)) end - def planting_add_photo_button(planting) - button(new_photo_path(id: planting.id, type: 'planting'), 'buttons.add_photo', 'camera') - end - def planting_finish_button(planting) return unless can?(:edit, planting) @@ -68,11 +52,22 @@ module ButtonsHelper button(new_planting_seed_path(planting), 'buttons.save_seeds', 'heart') if can?(:edit, planting) end + # Generic buttons (works out which model) + def add_photo_button(model) + return unless can?(:edit, model) && can?(:create, Photo) + + button( + new_photo_path(id: model.id, type: model_type_for_photo(model)), + 'buttons.add_a_photo', 'camera') + end + + def edit_button(path) button(path, 'buttons.edit', 'pencil') end def delete_button(model, message: 'are_you_sure') + return unless can? :destroy, model link_to model, method: :delete, data: { confirm: t(message) }, class: 'btn btn-default btn-xs' do render 'shared/glyphicon', icon: 'trash', title: 'buttons.delete' end @@ -80,6 +75,10 @@ module ButtonsHelper private + def model_type_for_photo(model) + ActiveModel::Name.new(model.class).to_s.downcase + end + def button(path, title, icon, size = 'btn-xs') link_to path, class: "btn btn-default #{size}" do render 'shared/glyphicon', icon: icon, title: title diff --git a/app/views/gardens/_actions.html.haml b/app/views/gardens/_actions.html.haml index 656bc0b58..67743037d 100644 --- a/app/views/gardens/_actions.html.haml +++ b/app/views/gardens/_actions.html.haml @@ -8,9 +8,7 @@ = garden_mark_active_button(garden) = garden_edit_button(garden) - - - if can?(:edit, garden) && can?(:create, Photo) - = garden_add_photo_button(garden) + = render 'shared/buttons/add_photo', model: garden - if can?(:destroy, garden) .pull-right diff --git a/app/views/harvests/_actions.html.haml b/app/views/harvests/_actions.html.haml index a86cbdb18..feabfbf96 100644 --- a/app/views/harvests/_actions.html.haml +++ b/app/views/harvests/_actions.html.haml @@ -1,5 +1,5 @@ .harvest-actions .btn-group = harvest_edit_button(harvest) if can? :edit, harvest - = harvest_add_photo_button(harvest) - = delete_button(harvest) if can? :destroy, harvest + = render 'shared/buttons/add_photo', model: harvest + = delete_button(harvest) diff --git a/app/views/plantings/_actions.html.haml b/app/views/plantings/_actions.html.haml index ca3fceefc..a8291089b 100644 --- a/app/views/plantings/_actions.html.haml +++ b/app/views/plantings/_actions.html.haml @@ -2,7 +2,7 @@ .planting-actions .btn-group = planting_edit_button(planting) - = planting_add_photo_button(planting) + = render 'shared/buttons/add_photo', model: planting - if planting.active? = planting_finish_button(planting) diff --git a/app/views/seeds/_actions.html.haml b/app/views/seeds/_actions.html.haml index ea731c16b..c801142a4 100644 --- a/app/views/seeds/_actions.html.haml +++ b/app/views/seeds/_actions.html.haml @@ -2,7 +2,7 @@ - if can? :edit, seed .btn-group = seed_edit_button(seed) - = seed_add_photo_button(seed) + = add_photo_button(seed) - if can?(:create, Planting) && seed.active? = link_to new_planting_path(seed_id: seed), class: 'btn btn-default btn-xs' do From a6ac57f045ce45209636e99adad64f158a83f7cb Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Wed, 23 Jan 2019 08:04:06 +1300 Subject: [PATCH 167/207] Tests for edit and add photo buttons --- spec/helpers/buttons_helper_spec.rb | 33 +++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 spec/helpers/buttons_helper_spec.rb diff --git a/spec/helpers/buttons_helper_spec.rb b/spec/helpers/buttons_helper_spec.rb new file mode 100644 index 000000000..d3def8e00 --- /dev/null +++ b/spec/helpers/buttons_helper_spec.rb @@ -0,0 +1,33 @@ +require 'rails_helper' + +# Specs in this file have access to a helper object that includes +# the ButtonsHelper. For example: +# +# describe ButtonsHelper do +# describe "string concat" do +# it "concats two strings with spaces" do +# expect(helper.concat_strings("this","that")).to eq("this that") +# end +# end +# end +RSpec.describe ButtonsHelper, type: :helper do + before { allow(self).to receive(:can?) { true } } + let(:garden) { FactoryBot.create :garden } + let(:planting) { FactoryBot.create :planting } + let(:harvest) { FactoryBot.create :harvest } + let(:seed) { FactoryBot.create :seed } + + describe 'add_photo_button' do + it { expect(add_photo_button(garden)).to include "/photos/new?id=#{garden.id}&type=garden" } + it { expect(add_photo_button(planting)).to include "/photos/new?id=#{planting.id}&type=planting" } + it { expect(add_photo_button(harvest)).to include "/photos/new?id=#{harvest.id}&type=harvest" } + it { expect(add_photo_button(seed)).to include "/photos/new?id=#{seed.id}&type=seed" } + end + + describe 'edit_button' do + it { expect(garden_edit_button(garden)).to include "/gardens/#{garden.slug}/edit" } + it { expect(planting_edit_button(planting)).to include "/plantings/#{planting.slug}/edit" } + it { expect(harvest_edit_button(harvest)).to include "/harvests/#{harvest.slug}/edit" } + it { expect(seed_edit_button(seed)).to include "/seeds/#{seed.slug}/edit" } + end +end From 8eb948796795abed5e50a6f78736890c672c495f Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Wed, 23 Jan 2019 14:03:36 +1300 Subject: [PATCH 168/207] Move home page greeting test to features spec (from views) --- spec/features/home/home_spec.rb | 5 +++++ spec/views/home/index_spec.rb | 4 ---- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/spec/features/home/home_spec.rb b/spec/features/home/home_spec.rb index 3847d532b..d02bb619f 100644 --- a/spec/features/home/home_spec.rb +++ b/spec/features/home/home_spec.rb @@ -84,5 +84,10 @@ feature "home page" do include_examples 'show plantings' include_examples 'show harvests' include_examples 'shows seeds' + + describe 'should say welcome' do + before { visit root_path } + it { expect(page).to have_content "Welcome to #{ENV['GROWSTUFF_SITE_NAME']}, #{member.login_name}" } + end end end diff --git a/spec/views/home/index_spec.rb b/spec/views/home/index_spec.rb index 5e11882fd..4bc1e9c10 100644 --- a/spec/views/home/index_spec.rb +++ b/spec/views/home/index_spec.rb @@ -36,9 +36,5 @@ describe 'home/index.html.haml', type: "view" do controller.stub(:current_user) { @member } render end - - it 'should say welcome' do - rendered.should have_content "Welcome to #{ENV['GROWSTUFF_SITE_NAME']}, #{@member.login_name}" - end end end From 9130b44fb9a4fd132da5c2f2dd2a7668fc41dc86 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Wed, 23 Jan 2019 14:04:48 +1300 Subject: [PATCH 169/207] Rubocop fixup --- app/helpers/buttons_helper.rb | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/app/helpers/buttons_helper.rb b/app/helpers/buttons_helper.rb index 994265adc..ea475fa05 100644 --- a/app/helpers/buttons_helper.rb +++ b/app/helpers/buttons_helper.rb @@ -58,16 +58,17 @@ module ButtonsHelper button( new_photo_path(id: model.id, type: model_type_for_photo(model)), - 'buttons.add_a_photo', 'camera') + 'buttons.add_a_photo', 'camera' + ) end - def edit_button(path) button(path, 'buttons.edit', 'pencil') end def delete_button(model, message: 'are_you_sure') return unless can? :destroy, model + link_to model, method: :delete, data: { confirm: t(message) }, class: 'btn btn-default btn-xs' do render 'shared/glyphicon', icon: 'trash', title: 'buttons.delete' end From 761a0b41422ac5205a4d7493babaf41b99d92aef Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Wed, 23 Jan 2019 14:07:39 +1300 Subject: [PATCH 170/207] Always use the helper for add_photo buttons --- app/views/gardens/_actions.html.haml | 2 +- app/views/harvests/_actions.html.haml | 2 +- app/views/plantings/_actions.html.haml | 2 +- app/views/plantings/_badges.html.haml | 39 ++++++++++++------------ app/views/shared/buttons/_add_photo.haml | 4 --- 5 files changed, 23 insertions(+), 26 deletions(-) delete mode 100644 app/views/shared/buttons/_add_photo.haml diff --git a/app/views/gardens/_actions.html.haml b/app/views/gardens/_actions.html.haml index 67743037d..3834d4787 100644 --- a/app/views/gardens/_actions.html.haml +++ b/app/views/gardens/_actions.html.haml @@ -8,7 +8,7 @@ = garden_mark_active_button(garden) = garden_edit_button(garden) - = render 'shared/buttons/add_photo', model: garden + = add_photo_button(garden) - if can?(:destroy, garden) .pull-right diff --git a/app/views/harvests/_actions.html.haml b/app/views/harvests/_actions.html.haml index feabfbf96..28a9aee77 100644 --- a/app/views/harvests/_actions.html.haml +++ b/app/views/harvests/_actions.html.haml @@ -1,5 +1,5 @@ .harvest-actions .btn-group = harvest_edit_button(harvest) if can? :edit, harvest - = render 'shared/buttons/add_photo', model: harvest + = add_photo_button(harvest) = delete_button(harvest) diff --git a/app/views/plantings/_actions.html.haml b/app/views/plantings/_actions.html.haml index a8291089b..3de6ce339 100644 --- a/app/views/plantings/_actions.html.haml +++ b/app/views/plantings/_actions.html.haml @@ -2,7 +2,7 @@ .planting-actions .btn-group = planting_edit_button(planting) - = render 'shared/buttons/add_photo', model: planting + = add_photo_button(planting) - if planting.active? = planting_finish_button(planting) diff --git a/app/views/plantings/_badges.html.haml b/app/views/plantings/_badges.html.haml index 2d690b914..e7ac1f6d3 100644 --- a/app/views/plantings/_badges.html.haml +++ b/app/views/plantings/_badges.html.haml @@ -1,20 +1,21 @@ -// Finish times -- if planting.finish_is_predicatable? - - if planting.super_late? - %span.badge.badge-super-late= t('.super_late') - = render 'shared/buttons/finish_planting', planting: planting - - elsif planting.late? - %span.badge.badge-late= t('.late_finishing') - - else - %span.badge - = days_from_now_to_finished(planting) - = t('.days_until_finished') +- unless planting.finished? + // Finish times + - if planting.finish_is_predicatable? + - if planting.super_late? + %span.badge.badge-super-late= t('.super_late') + = render 'shared/buttons/finish_planting', planting: planting + - elsif planting.late? + %span.badge.badge-late= t('.late_finishing') + - else + %span.badge + = days_from_now_to_finished(planting) + = t('.days_until_finished') -// Harvest times -- unless planting.super_late? - - if planting.harvest_time? - %span.badge.badge-harvest= t('.harvesting_now') - - elsif planting.before_harvest_time? - %span.badge - = days_from_now_to_first_harvest(planting) - = t('.days_until_harvest') + // Harvest times + - unless planting.super_late? + - if planting.harvest_time? + %span.badge.badge-harvest= t('.harvesting_now') + - elsif planting.before_harvest_time? + %span.badge + = days_from_now_to_first_harvest(planting) + = t('.days_until_harvest') diff --git a/app/views/shared/buttons/_add_photo.haml b/app/views/shared/buttons/_add_photo.haml deleted file mode 100644 index 0e4a75c07..000000000 --- a/app/views/shared/buttons/_add_photo.haml +++ /dev/null @@ -1,4 +0,0 @@ -- if can?(:create, Photo) - = link_to path, class: 'btn btn-default btn-xs' do - = render 'shared/glyphicon', icon: 'camera', title: 'buttons.add_photo' - =t('buttons.add_photo') From e6e582cb4ae9c0f89c1fbbc4c7da6ff5fd21e166 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Wed, 23 Jan 2019 14:33:48 +1300 Subject: [PATCH 171/207] Move some action button specs to feature specs because it's in a buttonbar, not the view now --- spec/features/gardens/actions_spec.rb | 5 +++++ spec/views/gardens/show.html.haml_spec.rb | 12 ------------ 2 files changed, 5 insertions(+), 12 deletions(-) diff --git a/spec/features/gardens/actions_spec.rb b/spec/features/gardens/actions_spec.rb index 0f4545714..18a339e09 100644 --- a/spec/features/gardens/actions_spec.rb +++ b/spec/features/gardens/actions_spec.rb @@ -54,6 +54,11 @@ feature "Gardens" do end describe '#show' do + before { visit garden_path(garden) } + it { is_expected.to have_link 'Edit' } + it { is_expected.to have_link 'Delete' } + it { is_expected.to have_content "Plant something here" } + it { is_expected.to have_content "Add photo" } end end diff --git a/spec/views/gardens/show.html.haml_spec.rb b/spec/views/gardens/show.html.haml_spec.rb index 5594c6755..0a3f813e8 100644 --- a/spec/views/gardens/show.html.haml_spec.rb +++ b/spec/views/gardens/show.html.haml_spec.rb @@ -42,18 +42,6 @@ describe "gardens/show" do render end - it 'should have an edit button' do - rendered.should have_link 'Edit' - end - - it "shows a 'plant something' button" do - rendered.should have_content "Plant something" - end - - it "shows an 'add photo' button" do - rendered.should have_content "Add photo" - end - it "links to the right crop in the planting link" do assert_select("a[href='#{new_planting_path}?garden_id=#{@garden.id}']") end From 8ec35cc65c411359d9e7b71779f11f7579da29eb Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Wed, 23 Jan 2019 14:36:36 +1300 Subject: [PATCH 172/207] Action specs for someone else's garden --- spec/features/gardens/actions_spec.rb | 36 ++++++++++++++++----------- 1 file changed, 22 insertions(+), 14 deletions(-) diff --git a/spec/features/gardens/actions_spec.rb b/spec/features/gardens/actions_spec.rb index 18a339e09..8468cec18 100644 --- a/spec/features/gardens/actions_spec.rb +++ b/spec/features/gardens/actions_spec.rb @@ -9,6 +9,7 @@ feature "Gardens" do background { login_as member } let(:garden) { member.gardens.first } + let(:other_member_garden) { FactoryBot.create :garden } describe '#index' do shared_examples "has buttons bar at top" do @@ -26,13 +27,11 @@ feature "Gardens" do include_examples "has buttons bar at top" it "has actions on garden" do - within '.garden-actions' do - is_expected.to have_link 'Plant something' - is_expected.to have_link 'Mark as inactive' - is_expected.to have_link 'Edit' - is_expected.to have_link 'Add photo' - is_expected.to have_link 'Delete' - end + is_expected.to have_link 'Plant something here' + is_expected.to have_link 'Mark as inactive' + is_expected.to have_link 'Edit' + is_expected.to have_link 'Add photo' + is_expected.to have_link 'Delete' end end @@ -47,18 +46,27 @@ feature "Gardens" do include_examples "has buttons bar at top" describe 'does not show actions on other member garden' do - it { is_expected.not_to have_link 'Plant something' } - it { is_expected.not_to have_link 'Mark as inactive' } + it { is_expected.not_to have_link 'Edit' } + it { is_expected.not_to have_link 'Delete' } end end end describe '#show' do - before { visit garden_path(garden) } - it { is_expected.to have_link 'Edit' } - it { is_expected.to have_link 'Delete' } - it { is_expected.to have_content "Plant something here" } - it { is_expected.to have_content "Add photo" } + describe 'my garden' do + before { visit garden_path(garden) } + it { is_expected.to have_link 'Edit' } + it { is_expected.to have_link 'Delete' } + it { is_expected.to have_content "Plant something here" } + it { is_expected.to have_content "Add photo" } + end + describe "someone else's garden" do + before { visit garden_path(other_member_garden) } + it { is_expected.not_to have_link 'Edit' } + it { is_expected.not_to have_link 'Delete' } + it { is_expected.not_to have_content "Plant something here" } + it { is_expected.not_to have_content "Add photo" } + end end end From c78b96b9d6cbf42a961252dc3bd0a4936a11ce09 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Wed, 23 Jan 2019 14:36:48 +1300 Subject: [PATCH 173/207] Update from should to expect syntax --- spec/views/gardens/show.html.haml_spec.rb | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/spec/views/gardens/show.html.haml_spec.rb b/spec/views/gardens/show.html.haml_spec.rb index 0a3f813e8..5a33707b3 100644 --- a/spec/views/gardens/show.html.haml_spec.rb +++ b/spec/views/gardens/show.html.haml_spec.rb @@ -12,28 +12,28 @@ describe "gardens/show" do render end - it 'should show the location' do - rendered.should have_content @garden.location + it 'shows the location' do + expect(rendered).to have_content @garden.location end - it 'should show the area' do - rendered.should have_content pluralize(@garden.area, @garden.area_unit) + it 'shows the area' do + expect(rendered).to have_content pluralize(@garden.area, @garden.area_unit) end - it 'should show the description' do - rendered.should have_content "totally cool garden" + it 'shows the description' do + expect(rendered).to have_content "totally cool garden" end it 'renders markdown in the description' do assert_select "strong", "totally" end - it 'should show plantings on the garden page' do - rendered.should have_content @planting.crop.name + it 'shows plantings on the garden page' do + expect(rendered).to have_content @planting.crop.name end it "doesn't show the note about random plantings" do - rendered.should_not have_content "Note: these are a random selection" + expect(rendered).to have_content "Note: these are a random selection" end context 'signed in' do From 424866b733666bacce6b05955cc6e3b4d60ddb7f Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Wed, 23 Jan 2019 14:37:00 +1300 Subject: [PATCH 174/207] Add "something" to global action labels --- app/views/shared/_global_actions.html.haml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/views/shared/_global_actions.html.haml b/app/views/shared/_global_actions.html.haml index 771033c8a..1fbfa2733 100644 --- a/app/views/shared/_global_actions.html.haml +++ b/app/views/shared/_global_actions.html.haml @@ -6,9 +6,9 @@ .btn-group = link_to new_planting_path, class: 'btn btn-default' do - = t('buttons.plant') + = t('plantings.plant_something') = link_to new_harvest_path, class: 'btn btn-default' do - = t('buttons.harvest') + = t('harvests.harvest_something') = link_to new_seed_path, class: 'btn btn-default' do = t('buttons.save_seeds') From 97675868bda1906192914a539a6d2dd815afd832 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Wed, 23 Jan 2019 14:37:18 +1300 Subject: [PATCH 175/207] Fixed button link, using translation that exists --- app/helpers/buttons_helper.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/helpers/buttons_helper.rb b/app/helpers/buttons_helper.rb index ea475fa05..8697ffd4c 100644 --- a/app/helpers/buttons_helper.rb +++ b/app/helpers/buttons_helper.rb @@ -58,7 +58,7 @@ module ButtonsHelper button( new_photo_path(id: model.id, type: model_type_for_photo(model)), - 'buttons.add_a_photo', 'camera' + 'buttons.add_photo', 'camera' ) end From 655efb26eb4a661bcc4e4ac8e05be1d380cf07b4 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Wed, 23 Jan 2019 14:52:17 +1300 Subject: [PATCH 176/207] Removing some unused translations --- config/locales/en.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/config/locales/en.yml b/config/locales/en.yml index 850492e09..f5415f127 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -76,13 +76,11 @@ en: edit: Edit harvest: Harvest harvest_crop: Harvest %{crop_name} - harvest_something: Harvest something mark_as_active: Mark as active mark_as_finished: Mark as finished mark_as_inactive: Mark as inactive plant: Plant plant_crop: Plant %{crop_name} - plant_something: Plant something plant_something_here: Plant something here save_seeds: Save seeds write_blog_post: Write blog post From 6e433306f483964abe4c714d5101aaa8575203ba Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Wed, 23 Jan 2019 14:52:40 +1300 Subject: [PATCH 177/207] Capitalise some translations --- config/locales/en.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/config/locales/en.yml b/config/locales/en.yml index f5415f127..023d7b5a5 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -130,7 +130,7 @@ en: crops: our_crops: Some of our crops recently_added: Recently added crops - recently_planted: Recently planted + recently_planted: Recently Planted view_all: View all crops discuss: discussion: Discussion @@ -142,7 +142,7 @@ en: harvest: Harvest plant: Plant post: Post - recently_added: Recently added + recently_added: Recently Added welcome: Welcome to %{site_name}, %{member_name} members: title: Some of our members @@ -173,7 +173,7 @@ en: why_linktext: why Growstuff is open source wiki_linktext: Growstuff Wiki plantings: - recently_planted: Recently planted + recently_planted: Recently Planted seeds: crop: Crop description: Description From 8023d71a21e85b9d5b8232ab09db3e6b313d085c Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Wed, 23 Jan 2019 14:54:43 +1300 Subject: [PATCH 178/207] Removed outdated spec --- spec/views/gardens/show.html.haml_spec.rb | 4 ---- 1 file changed, 4 deletions(-) diff --git a/spec/views/gardens/show.html.haml_spec.rb b/spec/views/gardens/show.html.haml_spec.rb index 5a33707b3..fd78ed08a 100644 --- a/spec/views/gardens/show.html.haml_spec.rb +++ b/spec/views/gardens/show.html.haml_spec.rb @@ -32,10 +32,6 @@ describe "gardens/show" do expect(rendered).to have_content @planting.crop.name end - it "doesn't show the note about random plantings" do - expect(rendered).to have_content "Note: these are a random selection" - end - context 'signed in' do before :each do sign_in @owner From c9be8be9e59b7d18e58af3e0c7df505e0130f9e4 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Wed, 23 Jan 2019 15:01:34 +1300 Subject: [PATCH 179/207] Remove new planting button spec because it's in the button bar now --- spec/views/gardens/show.html.haml_spec.rb | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/spec/views/gardens/show.html.haml_spec.rb b/spec/views/gardens/show.html.haml_spec.rb index fd78ed08a..7451f26c8 100644 --- a/spec/views/gardens/show.html.haml_spec.rb +++ b/spec/views/gardens/show.html.haml_spec.rb @@ -31,15 +31,4 @@ describe "gardens/show" do it 'shows plantings on the garden page' do expect(rendered).to have_content @planting.crop.name end - - context 'signed in' do - before :each do - sign_in @owner - render - end - - it "links to the right crop in the planting link" do - assert_select("a[href='#{new_planting_path}?garden_id=#{@garden.id}']") - end - end end From ca75b1c8528e803cf398f82fea2e99b33cf232bc Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Wed, 23 Jan 2019 15:06:56 +1300 Subject: [PATCH 180/207] Use button helper for crop wrangling --- app/helpers/buttons_helper.rb | 4 ++++ app/views/crops/_wrangle.html.haml | 11 ++--------- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/app/helpers/buttons_helper.rb b/app/helpers/buttons_helper.rb index 8697ffd4c..32df4d932 100644 --- a/app/helpers/buttons_helper.rb +++ b/app/helpers/buttons_helper.rb @@ -16,6 +16,10 @@ module ButtonsHelper data: { confirm: 'All plantings associated with this garden will be marked as finished. Are you sure?' } end + def crop_edit_button(crop) + edit_button(edit_crop_path(seed)) + end + def seed_edit_button(seed) edit_button(edit_seed_path(seed)) end diff --git a/app/views/crops/_wrangle.html.haml b/app/views/crops/_wrangle.html.haml index fafafd490..4260bbfe2 100644 --- a/app/views/crops/_wrangle.html.haml +++ b/app/views/crops/_wrangle.html.haml @@ -5,12 +5,5 @@ = succeed "." do %strong CROP WRANGLER - - if can? :edit, crop - %p - = link_to t(:edit_crop), edit_crop_path(crop), class: 'btn btn-default' - - if can? :destroy, crop - %p - = link_to 'Delete crop', crop, - method: :delete, - data: { confirm: t('are_you_sure') }, - class: 'btn btn-default' + %p= crop_edit_button(crop) if can? :edit, crop + %p= delete_button(crop) if can? :destroy, crop From 33ad13366511ccf66b3a0f73ab9cc00a64df26e2 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Wed, 23 Jan 2019 15:49:13 +1300 Subject: [PATCH 181/207] Revert modifications to menu --- app/views/layouts/_header.html.haml | 100 ++++++++++++++-------------- 1 file changed, 49 insertions(+), 51 deletions(-) diff --git a/app/views/layouts/_header.html.haml b/app/views/layouts/_header.html.haml index 990a23c76..ff4086c2e 100644 --- a/app/views/layouts/_header.html.haml +++ b/app/views/layouts/_header.html.haml @@ -20,63 +20,61 @@ = render 'crops/search_bar' .navbar-collapse.collapse#navbar-collapse - .navbar-right - %ul.nav.navbar-nav.navbar-right - %li.dropdown< - %a.dropdown-toggle{ 'data-toggle': 'dropdown', href: crops_path } - = t('.crops') - %b.caret - %ul.dropdown-menu - %li= link_to t('.browse_crops'), crops_path - %li= link_to t('.seeds'), seeds_path - %li= link_to t('.plantings'), plantings_path - %li= link_to t('.harvests'), harvests_path - %li.dropdown< - %a.dropdown-toggle{ 'data-toggle': 'dropdown', href: members_path } - = t('.community') - %b.caret - %ul.dropdown-menu - %li= link_to t('.community_map'), places_path - %li= link_to t('.browse_members'), members_path - %li= link_to t('.posts'), posts_path - %li= link_to t('.forums'), forums_path + %ul.nav.navbar-nav.navbar-right + %li.dropdown< + %a.dropdown-toggle{ 'data-toggle': 'dropdown', href: crops_path } + = t('.crops') + %b.caret + %ul.dropdown-menu + %li= link_to t('.browse_crops'), crops_path + %li= link_to t('.seeds'), seeds_path + %li= link_to t('.plantings'), plantings_path + %li= link_to t('.harvests'), harvests_path + %li.dropdown< + %a.dropdown-toggle{ 'data-toggle': 'dropdown', href: members_path } + = t('.community') + %b.caret + %ul.dropdown-menu + %li= link_to t('.community_map'), places_path + %li= link_to t('.browse_members'), members_path + %li= link_to t('.posts'), posts_path + %li= link_to t('.forums'), forums_path - - if member_signed_in? - %li.dropdown< - %a.dropdown-toggle{ 'data-toggle': 'dropdown', href: root_path } + - if member_signed_in? + %li.dropdown< + %a.dropdown-toggle{ 'data-toggle': 'dropdown', href: root_path } + - if current_member.notifications.unread_count.positive? + = t('.your_stuff', unread_count: current_member.notifications.unread_count) + - else + = t('.current_memberlogin_name', current_memberlogin_name: current_member.login_name) + %b.caret + %ul.dropdown-menu + %li= link_to t('.profile'), member_path(current_member) + %li= link_to t('.gardens'), gardens_by_owner_path(owner: current_member.slug) + %li= link_to t('.plantings'), plantings_by_owner_path(owner: current_member.slug) + %li= link_to t('.harvest'), harvests_by_owner_path(owner: current_member.slug) + %li= link_to t('.seeds'), seeds_by_owner_path(owner: current_member.slug) + %li= link_to t('.posts'), posts_by_author_path(author: current_member.slug) + %li - if current_member.notifications.unread_count.positive? - = t('.your_stuff', unread_count: current_member.notifications.unread_count) + = link_to(t('.inbox_unread', unread_count: current_member.notifications.unread_count), + notifications_path) - else - = t('.current_memberlogin_name', current_memberlogin_name: current_member.login_name) - %b.caret - %ul.dropdown-menu - %li= link_to t('.profile'), member_path(current_member) - %li= link_to t('.gardens'), gardens_by_owner_path(owner: current_member.slug) - %li= link_to t('.plantings'), plantings_by_owner_path(owner: current_member.slug) - %li= link_to t('.harvest'), harvests_by_owner_path(owner: current_member.slug) - %li= link_to t('.seeds'), seeds_by_owner_path(owner: current_member.slug) - %li= link_to t('.posts'), posts_by_author_path(author: current_member.slug) - %li - - if current_member.notifications.unread_count.positive? - = link_to(t('.inbox_unread', unread_count: current_member.notifications.unread_count), - notifications_path) - - else - = link_to(t('.inbox'), notifications_path) - - if current_member.role?(:crop_wrangler) || current_member.role?(:admin) - %li.divider{ role: 'presentation' } - - if current_member.role?(:crop_wrangler) - %li= link_to t('.crop_wrangling'), wrangle_crops_path - - if current_member.role?(:admin) - %li= link_to t('.admin'), admin_path + = link_to(t('.inbox'), notifications_path) + - if current_member.role?(:crop_wrangler) || current_member.role?(:admin) + %li.divider{ role: 'presentation' } + - if current_member.role?(:crop_wrangler) + %li= link_to t('.crop_wrangling'), wrangle_crops_path + - if current_member.role?(:admin) + %li= link_to t('.admin'), admin_path - %li= link_to t('.sign_out'), destroy_member_session_path, method: :delete + %li= link_to t('.sign_out'), destroy_member_session_path, method: :delete + + - else + %li= link_to t('.sign_in'), new_member_session_path, id: 'navbar-signin' + %li= link_to t('.sign_up'), new_member_registration_path, id: 'navbar-signup' - - else - %li= link_to t('.sign_in'), new_member_session_path, id: 'navbar-signin' - %li= link_to t('.sign_up'), new_member_registration_path, id: 'navbar-signup' - -# anchor tag for accessibility link to skip the navigation menu %a{ name: 'skipnav' } - From 99fb21eebe793e10e4c8a3107aaaf3dffec2d3dd Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Wed, 23 Jan 2019 16:14:22 +1300 Subject: [PATCH 182/207] Find maze button in spec --- spec/features/plantings/planting_a_crop_spec.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/spec/features/plantings/planting_a_crop_spec.rb b/spec/features/plantings/planting_a_crop_spec.rb index 1d8b7f745..de966b2fe 100644 --- a/spec/features/plantings/planting_a_crop_spec.rb +++ b/spec/features/plantings/planting_a_crop_spec.rb @@ -152,7 +152,9 @@ feature "Planting a crop", :js, :elasticsearch do scenario "Planting from crop page" do visit crop_path(maize) - click_link "Plant this" + within '.crop-actions' do + click_link "Plant maize" + end within "form#new_planting" do expect(page).to have_selector "input[value='maize']" click_button "Save" From 2a98cefedbd541d2dc511c8bb09af771edf57f80 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Wed, 23 Jan 2019 16:15:09 +1300 Subject: [PATCH 183/207] Copy finish planting from view to helper --- app/helpers/buttons_helper.rb | 13 ++++++------- app/views/shared/buttons/_finish_planting.html.haml | 5 ----- 2 files changed, 6 insertions(+), 12 deletions(-) delete mode 100644 app/views/shared/buttons/_finish_planting.html.haml diff --git a/app/helpers/buttons_helper.rb b/app/helpers/buttons_helper.rb index 32df4d932..64ec66fae 100644 --- a/app/helpers/buttons_helper.rb +++ b/app/helpers/buttons_helper.rb @@ -17,7 +17,7 @@ module ButtonsHelper end def crop_edit_button(crop) - edit_button(edit_crop_path(seed)) + edit_button(edit_crop_path(crop)) end def seed_edit_button(seed) @@ -37,13 +37,12 @@ module ButtonsHelper end def planting_finish_button(planting) - return unless can?(:edit, planting) + return unless can?(:edit, planting) || planting.finished - button( - planting_path(planting, planting: { finished: 1 }), - 'buttons.mark_as_finished', - 'ok' - ) + link_to planting_path(planting, planting: { finished: 1 }), + method: :put, class: 'btn btn-default btn-xs append-date' do + render 'shared/glyphicon', icon: 'ok', title: 'buttons.mark_as_finished' + end end def planting_harvest_button(planting) diff --git a/app/views/shared/buttons/_finish_planting.html.haml b/app/views/shared/buttons/_finish_planting.html.haml deleted file mode 100644 index d0a931b41..000000000 --- a/app/views/shared/buttons/_finish_planting.html.haml +++ /dev/null @@ -1,5 +0,0 @@ -- if can?(:edit, planting) && !planting.finished - = link_to planting_path(planting, planting: { finished: 1 }), - method: :put, class: 'btn btn-default btn-xs append-date' do - = render 'shared/glyphicon', icon: 'ok', title: 'buttons.finished' - = t('buttons.mark_as_finished') From 81ee8ec56ec8958c302acdf21d73f7645b74dc34 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Wed, 23 Jan 2019 16:19:08 +1300 Subject: [PATCH 184/207] Add crop name to actions --- app/views/crops/_index_card.html.haml | 4 ++-- spec/features/harvests/harvesting_a_crop_spec.rb | 4 +++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/app/views/crops/_index_card.html.haml b/app/views/crops/_index_card.html.haml index 99b4a1a7e..1c94573cf 100644 --- a/app/views/crops/_index_card.html.haml +++ b/app/views/crops/_index_card.html.haml @@ -31,6 +31,6 @@ days after planting - if can? :create, Planting - = link_to 'Plant this', new_planting_path(params: { crop_id: crop.id }), class: 'btn btn-primary' + = link_to "Plant #{crop.name}", new_planting_path(params: { crop_id: crop.id }), class: 'btn btn-primary' - if can? :create, Seed - = link_to 'Add seeds to stash', new_seed_path(params: { crop_id: crop.id }), class: 'btn btn-primary' + = link_to "Add #{crop.name} seeds to stash", new_seed_path(params: { crop_id: crop.id }), class: 'btn btn-primary' diff --git a/spec/features/harvests/harvesting_a_crop_spec.rb b/spec/features/harvests/harvesting_a_crop_spec.rb index 5f6d85fa2..afb182120 100644 --- a/spec/features/harvests/harvesting_a_crop_spec.rb +++ b/spec/features/harvests/harvesting_a_crop_spec.rb @@ -64,7 +64,9 @@ feature "Harvesting a crop", :js, :elasticsearch do scenario "Harvesting from crop page" do visit crop_path(maize) - click_link "Harvest this" + within '.crop-actions' do + click_link "Harvest #{maize.name}" + end within "form#new_harvest" do select plant_part.name, from: 'harvest[plant_part_id]' expect(page).to have_selector "input[value='maize']" From 28422bfd1d081f6949774d2d71bf8668edf25c53 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Wed, 23 Jan 2019 16:25:01 +1300 Subject: [PATCH 185/207] Seperate some specs --- spec/features/crops/crop_wranglers_spec.rb | 10 +++++----- .../features/plantings/planting_a_crop_spec.rb | 18 +++++++++--------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/spec/features/crops/crop_wranglers_spec.rb b/spec/features/crops/crop_wranglers_spec.rb index eafc7039f..86dc8a1c0 100644 --- a/spec/features/crops/crop_wranglers_spec.rb +++ b/spec/features/crops/crop_wranglers_spec.rb @@ -32,11 +32,11 @@ feature "crop wranglers", js: true do end end - scenario "visiting a crop can see wrangler links" do - visit crop_path(crops.first) - expect(page).to have_content 'You are a CROP WRANGLER' - expect(page).to have_link 'Edit crop' - expect(page).to have_link 'Delete crop' + describe "visiting a crop can see wrangler links" do + before { visit crop_path(crops.first) } + it { expect(page).to have_content 'You are a CROP WRANGLER' } + it { expect(page).to have_link 'Edit' } + it { expect(page).to have_link 'Delete' } end scenario "can create a new crop" do diff --git a/spec/features/plantings/planting_a_crop_spec.rb b/spec/features/plantings/planting_a_crop_spec.rb index de966b2fe..376c42569 100644 --- a/spec/features/plantings/planting_a_crop_spec.rb +++ b/spec/features/plantings/planting_a_crop_spec.rb @@ -21,15 +21,15 @@ feature "Planting a crop", :js, :elasticsearch do expect(page).to have_content "* denotes a required field" end - it "displays required and optional fields properly" do - expect(page).to have_selector ".form-group.required", text: "What did you plant?" - expect(page).to have_selector ".form-group.required", text: "Where did you plant it?" - expect(page).to have_optional 'input#planting_planted_at' - expect(page).to have_optional 'input#planting_quantity' - expect(page).to have_optional 'select#planting_planted_from' - expect(page).to have_optional 'select#planting_sunniness' - expect(page).to have_optional 'textarea#planting_description' - expect(page).to have_optional 'input#planting_finished_at' + describe "displays required and optional fields properly" do + it { expect(page).to have_selector ".form-group.required", text: "What did you plant?" } + it { expect(page).to have_selector ".form-group.required", text: "Where did you plant it?" } + it { expect(page).to have_optional 'input#planting_planted_at' } + it { expect(page).to have_optional 'input#planting_quantity' } + it { expect(page).to have_optional 'select#planting_planted_from' } + it { expect(page).to have_optional 'select#planting_sunniness' } + it { expect(page).to have_optional 'textarea#planting_description' } + it { expect(page).to have_optional 'input#planting_finished_at' } end scenario "Creating a new planting" do From 1460d4822a9d42678a902911ef70dd2456ff7767 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Wed, 23 Jan 2019 16:31:44 +1300 Subject: [PATCH 186/207] Crop name is in button label - add to spec --- spec/features/seeds/adding_seeds_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/features/seeds/adding_seeds_spec.rb b/spec/features/seeds/adding_seeds_spec.rb index 67a8b7717..021a24336 100644 --- a/spec/features/seeds/adding_seeds_spec.rb +++ b/spec/features/seeds/adding_seeds_spec.rb @@ -59,7 +59,7 @@ feature "Seeds", :js, :elasticsearch do describe "Adding a seed from crop page" do before do visit crop_path(maize) - click_link "Add seeds to stash" + click_link "Add maize seeds to stash" within "form#new_seed" do expect(page).to have_selector "input[value='maize']" click_button "Save" From 2380d622581d6819e0d1086837bbf3e86cc8d606 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Wed, 23 Jan 2019 16:35:12 +1300 Subject: [PATCH 187/207] Use new finish button on planting badges --- app/views/plantings/_badges.html.haml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/plantings/_badges.html.haml b/app/views/plantings/_badges.html.haml index e7ac1f6d3..acd244da4 100644 --- a/app/views/plantings/_badges.html.haml +++ b/app/views/plantings/_badges.html.haml @@ -3,7 +3,7 @@ - if planting.finish_is_predicatable? - if planting.super_late? %span.badge.badge-super-late= t('.super_late') - = render 'shared/buttons/finish_planting', planting: planting + = planting_finish_button(planting) - elsif planting.late? %span.badge.badge-late= t('.late_finishing') - else From a09c6603e23ee4495e72fe242b3d7b877a0ea81c Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Wed, 23 Jan 2019 16:49:06 +1300 Subject: [PATCH 188/207] Fixed photo specs to find the button on the actions view --- spec/features/photos/new_photo_spec.rb | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/spec/features/photos/new_photo_spec.rb b/spec/features/photos/new_photo_spec.rb index 0bf696f06..3c486fa5b 100644 --- a/spec/features/photos/new_photo_spec.rb +++ b/spec/features/photos/new_photo_spec.rb @@ -13,7 +13,9 @@ feature "new photo page" do scenario "add photo" do visit planting_path(planting) - click_link('Add photo', match: :first) + within '.planting-actions' do + click_link('Add photo') + end expect(page).to have_text planting.crop.name end end @@ -23,7 +25,9 @@ feature "new photo page" do scenario "add photo" do visit harvest_path(harvest) - click_link "Add photo" + within '.harvest-actions' do + click_link "Add photo" + end expect(page).to have_text harvest.crop.name end end From 4e82584a0a1f769fafbba143e67ecbfe5726a308 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Wed, 23 Jan 2019 16:54:07 +1300 Subject: [PATCH 189/207] Fixed label on link in spec --- spec/features/gardens_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/features/gardens_spec.rb b/spec/features/gardens_spec.rb index 368389719..0c58f8fdf 100644 --- a/spec/features/gardens_spec.rb +++ b/spec/features/gardens_spec.rb @@ -82,7 +82,7 @@ feature "Planting a crop", js: true do fill_in "Name", with: "New garden" click_button "Save" visit garden_path(Garden.last) - click_link 'delete_garden_link' + click_link 'Delete' expect(page).to have_content "Garden was successfully deleted" expect(page).to have_content "#{garden.owner}'s gardens" end From e912211ceea603640348ca8bfb3afbd326d7ebeb Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Wed, 23 Jan 2019 17:34:32 +1300 Subject: [PATCH 190/207] DRY the icons --- app/helpers/icons_helper.rb | 17 +++++++++++++++++ app/views/crops/_actions.html.haml | 5 ++++- app/views/shared/_global_actions.html.haml | 15 +++++++++------ 3 files changed, 30 insertions(+), 7 deletions(-) create mode 100644 app/helpers/icons_helper.rb diff --git a/app/helpers/icons_helper.rb b/app/helpers/icons_helper.rb new file mode 100644 index 000000000..636884133 --- /dev/null +++ b/app/helpers/icons_helper.rb @@ -0,0 +1,17 @@ +module IconsHelper + def garden_icon + icon('far', 'square') + end + + def planting_icon + icon('fas', 'seedling') + end + + def harvest_icon + icon('fas', 'carrot') + end + + def seed_icon + icon('fas', 'heart') + end +end diff --git a/app/views/crops/_actions.html.haml b/app/views/crops/_actions.html.haml index 5cc80036b..92ae2b00f 100644 --- a/app/views/crops/_actions.html.haml +++ b/app/views/crops/_actions.html.haml @@ -2,12 +2,15 @@ .btn-group - if can? :create, Planting = link_to new_planting_path(crop_id: crop.id), class: 'btn btn-default' do + = planting_icon = t('buttons.plant_crop', crop_name: crop.name) - if can? :create, Harvest = link_to new_harvest_path(crop_id: crop.id), class: 'btn btn-default' do + = harvest_icon = t('buttons.harvest_crop', crop_name: crop.name) - + - if can? :create, Seed = link_to new_seed_path(crop_id: crop.id), class: 'btn btn-default' do + = seed_icon = t('buttons.add_seed_to_stash', crop_name: crop.name) diff --git a/app/views/shared/_global_actions.html.haml b/app/views/shared/_global_actions.html.haml index 1fbfa2733..638ce87d0 100644 --- a/app/views/shared/_global_actions.html.haml +++ b/app/views/shared/_global_actions.html.haml @@ -1,19 +1,22 @@ - if signed_in? - .global-actions + .global-actions.pull-right .btn-group = link_to gardens_by_owner_path(owner: current_member.slug), class: 'btn btn-default' do - = t('links.my_gardens') - + = garden_icon + = t('links.my_gardens') + .btn-group = link_to new_planting_path, class: 'btn btn-default' do + = planting_icon = t('plantings.plant_something') + = link_to new_harvest_path, class: 'btn btn-default' do + = harvest_icon = t('harvests.harvest_something') + = link_to new_seed_path, class: 'btn btn-default' do + = seed_icon = t('buttons.save_seeds') .btn-group = link_to t('posts.write_blog_post'), new_post_path, class: 'btn btn-default' - -- content_for(:attributions) do - seed by Template from the Noun Project \ No newline at end of file From 88a277c6ed2aeb7ac5200f00a289e816e513a4fd Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Wed, 23 Jan 2019 21:49:11 +1300 Subject: [PATCH 191/207] Move consistent icons --- app/helpers/buttons_helper.rb | 35 +++++++++++++++++----------- app/helpers/icons_helper.rb | 16 +++++++++++++ app/views/gardens/_actions.html.haml | 5 ++-- 3 files changed, 40 insertions(+), 16 deletions(-) diff --git a/app/helpers/buttons_helper.rb b/app/helpers/buttons_helper.rb index 64ec66fae..30c992946 100644 --- a/app/helpers/buttons_helper.rb +++ b/app/helpers/buttons_helper.rb @@ -1,6 +1,8 @@ module ButtonsHelper def garden_plant_something_button(garden) - button(new_planting_path(garden_id: garden.id), 'buttons.plant_something_here', 'leaf') + link_to new_planting_path(garden_id: garden.id), class: "btn btn-default btn-xs btn-primary" do + planting_icon + ' ' + t('buttons.plant_something_here') + end end def garden_mark_active_button(garden) @@ -41,39 +43,46 @@ module ButtonsHelper link_to planting_path(planting, planting: { finished: 1 }), method: :put, class: 'btn btn-default btn-xs append-date' do - render 'shared/glyphicon', icon: 'ok', title: 'buttons.mark_as_finished' + finished_icon + ' ' + t('buttons.mark_as_finished') end end def planting_harvest_button(planting) return unless planting.active? && can?(:create, Harvest) && can?(:edit, planting) - button(new_planting_harvest_path(planting), 'buttons.harvest', 'apple') + link_to new_planting_harvest_path(planting), class: "btn btn-default btn-xs" do + harvest_icon + ' ' + t('buttons.harvest') + end end def planting_save_seeds_button(planting) - button(new_planting_seed_path(planting), 'buttons.save_seeds', 'heart') if can?(:edit, planting) + return unless can?(:edit, planting) + + link_to new_planting_seed_path(planting), class: "btn btn-default btn-xs" do + seed_icon + ' ' + t('buttons.save_seeds') + end end - # Generic buttons (works out which model) def add_photo_button(model) return unless can?(:edit, model) && can?(:create, Photo) - button( - new_photo_path(id: model.id, type: model_type_for_photo(model)), - 'buttons.add_photo', 'camera' - ) + link_to new_photo_path(id: model.id, type: model_type_for_photo(model)), + class: "btn btn-default btn-xs" do + photo_icon + ' ' + t('buttons.add_photo') + end end def edit_button(path) - button(path, 'buttons.edit', 'pencil') + link_to path, class: "btn btn-default btn-xs" do + edit_icon + ' ' + t('buttons.edit') + end end def delete_button(model, message: 'are_you_sure') return unless can? :destroy, model link_to model, method: :delete, data: { confirm: t(message) }, class: 'btn btn-default btn-xs' do - render 'shared/glyphicon', icon: 'trash', title: 'buttons.delete' + delete_icon + ' ' + t('buttons.delete') end end @@ -83,9 +92,9 @@ module ButtonsHelper ActiveModel::Name.new(model.class).to_s.downcase end - def button(path, title, icon, size = 'btn-xs') + def button(path, button_title, icon, size = 'btn-xs') link_to path, class: "btn btn-default #{size}" do - render 'shared/glyphicon', icon: icon, title: title + icon + ' ' + button_title end end end diff --git a/app/helpers/icons_helper.rb b/app/helpers/icons_helper.rb index 636884133..ab3a042b5 100644 --- a/app/helpers/icons_helper.rb +++ b/app/helpers/icons_helper.rb @@ -14,4 +14,20 @@ module IconsHelper def seed_icon icon('fas', 'heart') end + + def finished_icon + icon('fas', 'calendar') + end + + def edit_icon + icon('far', 'edit') + end + + def delete_icon + icon('fas', 'trash-alt') + end + + def photo_icon + icon('fas', 'camera-retro') + end end diff --git a/app/views/gardens/_actions.html.haml b/app/views/gardens/_actions.html.haml index 3834d4787..ea97a3931 100644 --- a/app/views/gardens/_actions.html.haml +++ b/app/views/gardens/_actions.html.haml @@ -1,8 +1,8 @@ .garden-actions - if can?(:edit, garden) + = garden_plant_something_button(garden) if garden.active .btn-group - if garden.active - = garden_plant_something_button(garden) = garden_mark_inactive_button(garden) - else = garden_mark_active_button(garden) @@ -11,5 +11,4 @@ = add_photo_button(garden) - if can?(:destroy, garden) - .pull-right - = delete_button(garden, message: 'All plantings associated with this garden will also be deleted. Are you sure?') + = delete_button(garden, message: 'All plantings associated with this garden will also be deleted. Are you sure?') From 94a5411a79733deada412934a2626bff170d4906 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Wed, 23 Jan 2019 21:49:17 +1300 Subject: [PATCH 192/207] Wider action bar --- app/views/layouts/application.html.haml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/app/views/layouts/application.html.haml b/app/views/layouts/application.html.haml index 3ac9f7cf6..f7fc3f5de 100644 --- a/app/views/layouts/application.html.haml +++ b/app/views/layouts/application.html.haml @@ -8,7 +8,7 @@ #maincontainer = render partial: "shared/flash_messages", flash: flash .row - .col-md-8 + .col-md-6 - if content_for?(:title) %h1#title = yield(:title) @@ -19,8 +19,7 @@ .btn-group.layout-actions = yield(:buttonbar) - .col-md-4 - + .col-md-6 = render 'shared/global_actions' = yield From 5218685bd93269aa0ac953a9d2869d8f800b5109 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Wed, 23 Jan 2019 21:57:21 +1300 Subject: [PATCH 193/207] Tidy up member edit buttons --- app/views/members/show.html.haml | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/app/views/members/show.html.haml b/app/views/members/show.html.haml index 621f35c51..a786b8077 100644 --- a/app/views/members/show.html.haml +++ b/app/views/members/show.html.haml @@ -7,11 +7,17 @@ = tag("meta", property: "og:type", content: "profile") = tag("meta", property: "og:url", content: request.original_url) = tag("meta", property: "og:site_name", content: ENV['GROWSTUFF_SITE_NAME']) + + - content_for :buttonbar do - - if can? :update, @member - = link_to 'Edit profile', edit_member_registration_path, class: 'btn btn-default pull-right' - - if can?(:create, Notification) && current_member != @member - = link_to 'Send message', new_notification_path(recipient_id: @member.id), class: 'btn btn-default pull-right' + %p.btn-group + - if can? :update, @member + = link_to edit_member_registration_path, class: 'btn btn-default pull-right' do + = edit_icon + = t('members.edit_profile') + + - if can?(:create, Notification) && current_member != @member + = link_to 'Send message', new_notification_path(recipient_id: @member.id), class: 'btn btn-default' - if current_member && current_member != @member # must be logged in, can't follow yourself - follow = current_member.get_follow(@member) From 80e0d964e15a58f75cecd09b41f24869a8ce21bc Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Wed, 23 Jan 2019 21:59:06 +1300 Subject: [PATCH 194/207] indentation clean up --- app/helpers/buttons_helper.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/helpers/buttons_helper.rb b/app/helpers/buttons_helper.rb index 30c992946..df4a48f6c 100644 --- a/app/helpers/buttons_helper.rb +++ b/app/helpers/buttons_helper.rb @@ -43,7 +43,7 @@ module ButtonsHelper link_to planting_path(planting, planting: { finished: 1 }), method: :put, class: 'btn btn-default btn-xs append-date' do - finished_icon + ' ' + t('buttons.mark_as_finished') + finished_icon + ' ' + t('buttons.mark_as_finished') end end From a54db7d5ffecd41e53a95a410fbdcd1953ee491a Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Wed, 23 Jan 2019 22:30:44 +1300 Subject: [PATCH 195/207] Tidied up the planting actions on gardens#index --- app/assets/stylesheets/overrides.sass | 6 ++++-- app/views/plantings/_thumbnail.html.haml | 27 +++++++++++++++--------- 2 files changed, 21 insertions(+), 12 deletions(-) diff --git a/app/assets/stylesheets/overrides.sass b/app/assets/stylesheets/overrides.sass index b255536ea..1e9374184 100644 --- a/app/assets/stylesheets/overrides.sass +++ b/app/assets/stylesheets/overrides.sass @@ -132,11 +132,13 @@ p.stats padding: 0 border: 1px solid darken($beige, 10%) border-radius: 4px - .planting-actions - top: -8em .planting-name position: relative top: -1em + .planting-quick-actions + position: absolute + top: 0 + right: 2em dl.planting-attributes dt diff --git a/app/views/plantings/_thumbnail.html.haml b/app/views/plantings/_thumbnail.html.haml index a6b8349b8..bfe4892a8 100644 --- a/app/views/plantings/_thumbnail.html.haml +++ b/app/views/plantings/_thumbnail.html.haml @@ -1,13 +1,20 @@ .planting .planting-badges = render 'plantings/badges', planting: planting - .hover-wrapper - .thumbnail - .planting-thumbnail{ class: planting_classes(planting) } - = link_to image_tag(planting_image_path(planting), - alt: planting.crop.name, class: 'img'), planting_path(planting) - = render 'plantings/progress', planting: planting, show_explanation: false - .planting-name - = link_to planting.crop.name, planting - .text - .planting-actions= render 'plantings/actions', planting: planting + + .planting-quick-actions.pull-right + %a.btn.btn-default.btn-xs#actionsMenu.nav-link.dropdown-toggle{"aria-expanded" => "false", "aria-haspopup" => "true", "data-toggle" => "dropdown", href: "#"} + =icon('fas', 'bars') + .dropdown-menu{"aria-labelledby" => "actionsMenu"} + %p= render 'plantings/actions', planting: planting + + .thumbnail + + .planting-thumbnail{ class: planting_classes(planting) } + = link_to image_tag(planting_image_path(planting), + alt: planting.crop.name, class: 'img'), planting_path(planting) + = render 'plantings/progress', planting: planting, show_explanation: false + + .planting-name + = link_to planting.crop.name, planting + From 8bfe3278cc4fd9510e2a53e997e5bed871119b88 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Thu, 24 Jan 2019 09:17:13 +1300 Subject: [PATCH 196/207] Include icon helper from button helper --- app/helpers/buttons_helper.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/app/helpers/buttons_helper.rb b/app/helpers/buttons_helper.rb index df4a48f6c..ad31f45c4 100644 --- a/app/helpers/buttons_helper.rb +++ b/app/helpers/buttons_helper.rb @@ -1,4 +1,5 @@ module ButtonsHelper + include IconHelper def garden_plant_something_button(garden) link_to new_planting_path(garden_id: garden.id), class: "btn btn-default btn-xs btn-primary" do planting_icon + ' ' + t('buttons.plant_something_here') From e202c73584549f236a7fe184ab3ad0b0e77d0dc9 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Thu, 24 Jan 2019 09:18:46 +1300 Subject: [PATCH 197/207] Update buttons_helper.rb --- app/helpers/buttons_helper.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/helpers/buttons_helper.rb b/app/helpers/buttons_helper.rb index ad31f45c4..7ae28247e 100644 --- a/app/helpers/buttons_helper.rb +++ b/app/helpers/buttons_helper.rb @@ -1,5 +1,5 @@ module ButtonsHelper - include IconHelper + include IconsHelper def garden_plant_something_button(garden) link_to new_planting_path(garden_id: garden.id), class: "btn btn-default btn-xs btn-primary" do planting_icon + ' ' + t('buttons.plant_something_here') From d73f8716c07018429d5df828c4fbb6f57c520cc8 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Thu, 24 Jan 2019 11:51:48 +1300 Subject: [PATCH 198/207] Include font awesome (so specs pass) --- app/helpers/icons_helper.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/app/helpers/icons_helper.rb b/app/helpers/icons_helper.rb index ab3a042b5..a42aaf5d8 100644 --- a/app/helpers/icons_helper.rb +++ b/app/helpers/icons_helper.rb @@ -1,4 +1,5 @@ module IconsHelper + include FontAwesome::Sass::Rails::ViewHelpers def garden_icon icon('far', 'square') end From 449e8da25a984593718fe6e362ea3dc20d376389 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Thu, 24 Jan 2019 11:54:55 +1300 Subject: [PATCH 199/207] Added missing translation for Edit profile button --- config/locales/en.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/config/locales/en.yml b/config/locales/en.yml index 023d7b5a5..12942554f 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -221,6 +221,7 @@ en: links: my_gardens: My gardens members: + edit_profile: Edit profile index: title: "%{site_name} members" signup: From f6deaffb94ec75aa80d7b1d0cb5f2b0a8d6cc370 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Thu, 24 Jan 2019 11:58:58 +1300 Subject: [PATCH 200/207] Fixed nested row on layout, that was breaking photo add page --- app/views/layouts/application.html.haml | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/app/views/layouts/application.html.haml b/app/views/layouts/application.html.haml index f7fc3f5de..d36f217b8 100644 --- a/app/views/layouts/application.html.haml +++ b/app/views/layouts/application.html.haml @@ -6,7 +6,8 @@ = render partial: "layouts/header" #maincontainer - = render partial: "shared/flash_messages", flash: flash + .row + .col-md-12= render partial: "shared/flash_messages", flash: flash .row .col-md-6 - if content_for?(:title) @@ -21,10 +22,13 @@ .col-md-6 = render 'shared/global_actions' - = yield + + .row + .col-md-12 + = yield %footer - = render partial: "layouts/footer" + = render "layouts/footer" / Javascripts \================================================== From fc6183eb5239f2add7becff0838857a8e8b3a308 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Thu, 24 Jan 2019 13:46:35 +1300 Subject: [PATCH 201/207] DRY actions more --- app/views/layouts/application.html.haml | 3 +-- app/views/photos/_actions.html.haml | 4 ++-- app/views/photos/_photo_association_delete.haml | 2 +- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/app/views/layouts/application.html.haml b/app/views/layouts/application.html.haml index d36f217b8..c1f2c2e33 100644 --- a/app/views/layouts/application.html.haml +++ b/app/views/layouts/application.html.haml @@ -6,8 +6,6 @@ = render partial: "layouts/header" #maincontainer - .row - .col-md-12= render partial: "shared/flash_messages", flash: flash .row .col-md-6 - if content_for?(:title) @@ -25,6 +23,7 @@ .row .col-md-12 + = render partial: "shared/flash_messages", flash: flash = yield %footer diff --git a/app/views/photos/_actions.html.haml b/app/views/photos/_actions.html.haml index 06fc37f0e..95d9de0d1 100644 --- a/app/views/photos/_actions.html.haml +++ b/app/views/photos/_actions.html.haml @@ -2,6 +2,6 @@ - if can?(:edit, @photo) && can?(:destroy, @photo) %p - if can?(:edit, @photo) - = render 'shared/buttons/edit', path: edit_photo_path(@photo) + = edit_button(@photo) - if can?(:destroy, @photo) - = render 'shared/buttons/delete', path: photo_path(@photo) + = delete_button(@photo) diff --git a/app/views/photos/_photo_association_delete.haml b/app/views/photos/_photo_association_delete.haml index d505b47ad..fd950821c 100644 --- a/app/views/photos/_photo_association_delete.haml +++ b/app/views/photos/_photo_association_delete.haml @@ -1,4 +1,4 @@ - if can? :edit, photo = link_to photo_associations_path(photo_id: photo.id, type: type, id: thing.id), method: 'delete', class: 'btn btn-default btn-xs' do - %span.glyphicon.glyphicon-remove{ title: "Remove link" } + = delete_icon From 532355820460042789a70e81a26e2437c5b63d51 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" Date: Thu, 24 Jan 2019 07:34:02 +0000 Subject: [PATCH 202/207] Bump capybara from 3.12.0 to 3.13.0 Bumps [capybara](https://github.com/teamcapybara/capybara) from 3.12.0 to 3.13.0. - [Release notes](https://github.com/teamcapybara/capybara/releases) - [Changelog](https://github.com/teamcapybara/capybara/blob/master/History.md) - [Commits](https://github.com/teamcapybara/capybara/compare/3.12.0...3.13.0) Signed-off-by: dependabot[bot] --- Gemfile.lock | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 76383e33d..48db71096 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -51,7 +51,7 @@ GEM i18n (>= 0.7, < 2) minitest (~> 5.1) tzinfo (~> 1.1) - addressable (2.5.2) + addressable (2.6.0) public_suffix (>= 2.0.2, < 4.0) arel (9.0.0) ast (2.4.0) @@ -80,7 +80,7 @@ GEM uniform_notifier (~> 1.11) byebug (10.0.2) cancancan (2.3.0) - capybara (3.12.0) + capybara (3.13.0) addressable mini_mime (>= 0.1.3) nokogiri (~> 1.8) From 02d96bcc517d275db137e8491383167571c97002 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Sat, 26 Jan 2019 14:02:50 +1300 Subject: [PATCH 203/207] Removed another mandril reference --- config/application.yml.example | 5 ----- 1 file changed, 5 deletions(-) diff --git a/config/application.yml.example b/config/application.yml.example index 568a276c7..7d42e4250 100644 --- a/config/application.yml.example +++ b/config/application.yml.example @@ -31,11 +31,6 @@ RAILS_SECRET_TOKEN: "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" # name that appears on the site, eg. in page titles GROWSTUFF_SITE_NAME: Growstuff (dev) -# Mandrill is used to send transactional email (eg. signup -# confirmations). If using Heroku connect to Mandrill via Heroku addons -# list then go to tools menu (upper right) and choose "SMTP and API -# Credentials" - # Mailchimp is used for subscribing/unsubscribing people from the newsletter # To fetch list IDs using Gibbon (and thus find the ID of your newsletter): # $ rails c From 9c130641917b13db41088c2d0e796b371679cb16 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" Date: Sat, 26 Jan 2019 22:56:56 +0000 Subject: [PATCH 204/207] Bump newrelic_rpm from 5.6.0.349 to 5.7.0.350 Bumps [newrelic_rpm](https://github.com/newrelic/rpm) from 5.6.0.349 to 5.7.0.350. - [Release notes](https://github.com/newrelic/rpm/releases) - [Changelog](https://github.com/newrelic/rpm/blob/master/CHANGELOG.md) - [Commits](https://github.com/newrelic/rpm/commits) Signed-off-by: dependabot[bot] --- Gemfile.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile.lock b/Gemfile.lock index 48db71096..c7886a746 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -294,7 +294,7 @@ GEM multi_json (1.11.3) multi_xml (0.6.0) multipart-post (2.0.0) - newrelic_rpm (5.6.0.349) + newrelic_rpm (5.7.0.350) nio4r (2.3.1) nokogiri (1.10.1) mini_portile2 (~> 2.4.0) From 3d3d1407cd91307634102a10158cdff17a3d1b4d Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Sun, 27 Jan 2019 18:28:42 +1300 Subject: [PATCH 205/207] Fixed link in global actions --- app/views/shared/_global_actions.html.haml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/shared/_global_actions.html.haml b/app/views/shared/_global_actions.html.haml index 638ce87d0..0f51209bf 100644 --- a/app/views/shared/_global_actions.html.haml +++ b/app/views/shared/_global_actions.html.haml @@ -1,7 +1,7 @@ - if signed_in? .global-actions.pull-right .btn-group - = link_to gardens_by_owner_path(owner: current_member.slug), class: 'btn btn-default' do + = link_to member_gardens_path(current_member), class: 'btn btn-default' do = garden_icon = t('links.my_gardens') From 964dbe5e5403ad7261850bba259e72624f5c3cce Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" Date: Tue, 29 Jan 2019 07:20:30 +0000 Subject: [PATCH 206/207] Bump newrelic_rpm from 5.7.0.350 to 6.0.0.351 Bumps [newrelic_rpm](https://github.com/newrelic/rpm) from 5.7.0.350 to 6.0.0.351. - [Release notes](https://github.com/newrelic/rpm/releases) - [Changelog](https://github.com/newrelic/rpm/blob/master/CHANGELOG.md) - [Commits](https://github.com/newrelic/rpm/commits) Signed-off-by: dependabot[bot] --- Gemfile.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile.lock b/Gemfile.lock index c7886a746..632eb6224 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -294,7 +294,7 @@ GEM multi_json (1.11.3) multi_xml (0.6.0) multipart-post (2.0.0) - newrelic_rpm (5.7.0.350) + newrelic_rpm (6.0.0.351) nio4r (2.3.1) nokogiri (1.10.1) mini_portile2 (~> 2.4.0) From 6acc6bd5eea09c34187dcb22509b457850fcafd7 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Wed, 30 Jan 2019 15:25:07 +1300 Subject: [PATCH 207/207] Tell rspec which gardens button to use --- spec/features/gardens_spec.rb | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/spec/features/gardens_spec.rb b/spec/features/gardens_spec.rb index 0ae9429a9..ab88ea9ea 100644 --- a/spec/features/gardens_spec.rb +++ b/spec/features/gardens_spec.rb @@ -14,9 +14,13 @@ feature "Planting a crop", js: true do scenario "View gardens" do visit gardens_path expect(page).to have_content "Everyone's gardens" - click_link "My gardens" + within '.layout-actions' do + click_link "My gardens" + end expect(page).to have_content "#{garden.owner.login_name}'s gardens" - click_link "Everyone's gardens" + within '.layout-actions' do + click_link "Everyone's gardens" + end expect(page).to have_content "Everyone's gardens" end