From cbed8cc259e0679ddf192fd91d67dbfc90ba2f57 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Mon, 8 Jul 2019 20:00:55 +1200 Subject: [PATCH 01/66] likes for photos --- app/assets/javascripts/{posts.js => likes.js} | 19 +++++++++++++++++++ app/controllers/likes_controller.rb | 11 ++++++++--- app/models/photo.rb | 1 + app/views/photos/_likes.html.haml | 17 +++++++++++++++++ app/views/photos/show.html.haml | 11 ++++++++--- 5 files changed, 53 insertions(+), 6 deletions(-) rename app/assets/javascripts/{posts.js => likes.js} (52%) create mode 100644 app/views/photos/_likes.html.haml diff --git a/app/assets/javascripts/posts.js b/app/assets/javascripts/likes.js similarity index 52% rename from app/assets/javascripts/posts.js rename to app/assets/javascripts/likes.js index 37269e78e..cb759bbf3 100644 --- a/app/assets/javascripts/posts.js +++ b/app/assets/javascripts/likes.js @@ -1,7 +1,9 @@ $(document).ready(function() { + $('.post-like').show(); $('.post-like').on('ajax:success', function(event, data) { + debugger; var likeControl = $('#post-' + data.id + ' .post-like'); $('#post-' + data.id + ' .like-count').text(data.description); @@ -15,4 +17,21 @@ $(document).ready(function() { likeControl.text('Like'); } }); + + $('.photo-like').show(); + + $('.photo-like').on('ajax:success', function(event, data) { + var likeControl = $('.photo-like'); + + $('.like-count').text(data.description); + if (data.liked_by_member) { + likeControl.data('method', 'delete'); + likeControl.attr('href', data.url); + likeControl.text('Unlike'); + } else { + likeControl.data('method', 'post'); + likeControl.attr('href', '/likes.json?photo_id=' + data.id); + likeControl.text('Like'); + } + }); }); diff --git a/app/controllers/likes_controller.rb b/app/controllers/likes_controller.rb index e942d5b1f..c99ae552f 100644 --- a/app/controllers/likes_controller.rb +++ b/app/controllers/likes_controller.rb @@ -19,7 +19,11 @@ class LikesController < ApplicationController private def find_likeable - Post.find(params[:post_id]) if params[:post_id] + if params[:post_id] + Post.find(params[:post_id]) + elsif params[:photo_id] + Photo.find(params[:photo_id]) + end end def render_json(like, liked_by_member: true) @@ -35,8 +39,9 @@ class LikesController < ApplicationController respond_to do |format| format.html { redirect_to like.likeable } format.json do - render(json: render_json(like, liked_by_member: liked_by_member), - status: status_code) + render(json: render_json(like, + liked_by_member: liked_by_member), + status: status_code) end end end diff --git a/app/models/photo.rb b/app/models/photo.rb index 2481fab2e..25ca565b6 100644 --- a/app/models/photo.rb +++ b/app/models/photo.rb @@ -1,4 +1,5 @@ class Photo < ApplicationRecord + include Likeable include Ownable PHOTO_CAPABLE = %w(Garden Planting Harvest Seed).freeze diff --git a/app/views/photos/_likes.html.haml b/app/views/photos/_likes.html.haml new file mode 100644 index 000000000..93acc4bf0 --- /dev/null +++ b/app/views/photos/_likes.html.haml @@ -0,0 +1,17 @@ + +- if member_signed_in? + - if !photo.members.include? current_member + - if can?(:new, Like) + = link_to 'Like', likes_path(photo_id: photo.id, format: :json), + method: :post, remote: true, class: 'photo-like btn' + - else + - like = photo.likes.find_by(member: current_member) + - if like && can?(:destroy, like) + = link_to 'Unlike', like_path(id: like.id, format: :json), + method: :delete, remote: true, class: 'photo-like btn' + +%span.badge.badge-info + .like-count + - unless photo.likes.empty? + = like_icon + = pluralize(photo.likes.count, "like") diff --git a/app/views/photos/show.html.haml b/app/views/photos/show.html.haml index bd8632f4d..53c6a14a7 100644 --- a/app/views/photos/show.html.haml +++ b/app/views/photos/show.html.haml @@ -11,17 +11,22 @@ %li.breadcrumb-item= link_to 'Photos', photos_path %li.breadcrumb-item.active= link_to @photo, @photo -.row +.row#photo .col-md-8 %h1.text-center.ellipsis=@photo.title %p.text-center = image_tag(@photo.fullsize_url, alt: @photo.title, class: 'rounded img-fluid shadow-sm') .col-md-4 - %p.text-center + %p.text-center{ id: "photo-#{@photo.id}" } = render 'photos/actions', photo: @photo = link_to "View on Flickr", @photo.link_url, class: 'btn' + + = render 'photos/likes', photo: @photo + - if @crops.size.positive? - %p= render @crops + .index-cards + - @crops.each do |crop| + = render 'crops/thumbnail', crop: crop %p = photo_icon %strong Photo by From f638d0c2d33f5cfc8d12f644dcca1bee126482d7 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Mon, 8 Jul 2019 20:03:27 +1200 Subject: [PATCH 02/66] rubocop lint --- app/controllers/likes_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/likes_controller.rb b/app/controllers/likes_controller.rb index c99ae552f..75113289c 100644 --- a/app/controllers/likes_controller.rb +++ b/app/controllers/likes_controller.rb @@ -41,7 +41,7 @@ class LikesController < ApplicationController format.json do render(json: render_json(like, liked_by_member: liked_by_member), - status: status_code) + status: status_code) end end end From bff31ddb5cb17f8ac296dd93b5ade99bfef89838 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Mon, 8 Jul 2019 20:04:27 +1200 Subject: [PATCH 03/66] Removed extra blank lines --- app/assets/javascripts/likes.js | 1 - 1 file changed, 1 deletion(-) diff --git a/app/assets/javascripts/likes.js b/app/assets/javascripts/likes.js index cb759bbf3..ed6627fb3 100644 --- a/app/assets/javascripts/likes.js +++ b/app/assets/javascripts/likes.js @@ -1,5 +1,4 @@ $(document).ready(function() { - $('.post-like').show(); $('.post-like').on('ajax:success', function(event, data) { From f1df90f1894307066f854934e1169b657f30033d Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Mon, 8 Jul 2019 20:05:48 +1200 Subject: [PATCH 04/66] Remove debugger --- app/assets/javascripts/likes.js | 1 - 1 file changed, 1 deletion(-) diff --git a/app/assets/javascripts/likes.js b/app/assets/javascripts/likes.js index ed6627fb3..5a03bedd5 100644 --- a/app/assets/javascripts/likes.js +++ b/app/assets/javascripts/likes.js @@ -2,7 +2,6 @@ $(document).ready(function() { $('.post-like').show(); $('.post-like').on('ajax:success', function(event, data) { - debugger; var likeControl = $('#post-' + data.id + ' .post-like'); $('#post-' + data.id + ' .like-count').text(data.description); From cfab855a0f502e543a65855c8b48b53639ff3b9d Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Mon, 8 Jul 2019 20:06:48 +1200 Subject: [PATCH 05/66] revert adding id --- app/views/photos/show.html.haml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/photos/show.html.haml b/app/views/photos/show.html.haml index 53c6a14a7..302d6cbaf 100644 --- a/app/views/photos/show.html.haml +++ b/app/views/photos/show.html.haml @@ -11,7 +11,7 @@ %li.breadcrumb-item= link_to 'Photos', photos_path %li.breadcrumb-item.active= link_to @photo, @photo -.row#photo +.row .col-md-8 %h1.text-center.ellipsis=@photo.title %p.text-center From e40a2c31769b6aaf0a47fdb8edbb352dce1319de Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Mon, 8 Jul 2019 20:12:42 +1200 Subject: [PATCH 06/66] remove debugger --- app/assets/javascripts/likes.js | 1 + 1 file changed, 1 insertion(+) diff --git a/app/assets/javascripts/likes.js b/app/assets/javascripts/likes.js index 5a03bedd5..c1c6c5364 100644 --- a/app/assets/javascripts/likes.js +++ b/app/assets/javascripts/likes.js @@ -1,4 +1,5 @@ $(document).ready(function() { + $('.post-like').show(); $('.post-like').on('ajax:success', function(event, data) { From dd6446b1956c269c6e5dfe8c815021afa14dd0e8 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Mon, 8 Jul 2019 20:13:21 +1200 Subject: [PATCH 07/66] fix icon method name --- app/helpers/icons_helper.rb | 2 +- app/views/members/show.html.haml | 2 +- app/views/shared/_global_actions.html.haml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/helpers/icons_helper.rb b/app/helpers/icons_helper.rb index 7422a44e6..828d8cffa 100644 --- a/app/helpers/icons_helper.rb +++ b/app/helpers/icons_helper.rb @@ -45,7 +45,7 @@ module IconsHelper icon('fas', 'seedling') end - def blog_icon + def post_icon image_icon 'post' end diff --git a/app/views/members/show.html.haml b/app/views/members/show.html.haml index eb6867759..287e8f963 100644 --- a/app/views/members/show.html.haml +++ b/app/views/members/show.html.haml @@ -87,7 +87,7 @@ = link_to comment.post, comment.post - elsif event.event_type == 'post' - post = Post.find(event.id) - = blog_icon + = post_icon wrote a post about = link_to post, post - elsif event.event_type == 'photo' diff --git a/app/views/shared/_global_actions.html.haml b/app/views/shared/_global_actions.html.haml index a2a60d3a8..282ffa026 100644 --- a/app/views/shared/_global_actions.html.haml +++ b/app/views/shared/_global_actions.html.haml @@ -17,4 +17,4 @@ = link_to new_post_path, class: 'btn btn-default', 'data-toggle': "tooltip", 'data-placement': "bottom", title: t('buttons.new_post') do - = blog_icon + = post_icon From 5d07a30d17c180b17467122b38cdeff9d1e69926 Mon Sep 17 00:00:00 2001 From: codefactor-io Date: Mon, 8 Jul 2019 08:16:24 +0000 Subject: [PATCH 08/66] [CodeFactor] Apply fixes --- app/assets/javascripts/likes.js | 1 - 1 file changed, 1 deletion(-) diff --git a/app/assets/javascripts/likes.js b/app/assets/javascripts/likes.js index c1c6c5364..5a03bedd5 100644 --- a/app/assets/javascripts/likes.js +++ b/app/assets/javascripts/likes.js @@ -1,5 +1,4 @@ $(document).ready(function() { - $('.post-like').show(); $('.post-like').on('ajax:success', function(event, data) { From dde666829305046803742256701d554c8586d4cc Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Thu, 11 Jul 2019 11:33:46 +1200 Subject: [PATCH 09/66] Notifications responsiveness --- app/views/members/_follow_buttons.haml | 6 +++ app/views/members/show.html.haml | 8 +-- app/views/notifications/_form.html.haml | 44 ++++++++-------- .../notifications/_notification.html.haml | 2 +- app/views/notifications/index.html.haml | 52 ++++++++----------- app/views/notifications/reply.html.haml | 4 +- app/views/notifications/show.html.haml | 14 +++-- 7 files changed, 66 insertions(+), 64 deletions(-) create mode 100644 app/views/members/_follow_buttons.haml diff --git a/app/views/members/_follow_buttons.haml b/app/views/members/_follow_buttons.haml new file mode 100644 index 000000000..82a2b7d88 --- /dev/null +++ b/app/views/members/_follow_buttons.haml @@ -0,0 +1,6 @@ +- 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: member), method: :post, class: 'btn btn-block' + - if follow && can?(:destroy, follow) # already following + = link_to 'Unfollow', follow_path(follow), method: :delete, class: 'btn btn-block' \ No newline at end of file diff --git a/app/views/members/show.html.haml b/app/views/members/show.html.haml index 536b0c688..8031e151a 100644 --- a/app/views/members/show.html.haml +++ b/app/views/members/show.html.haml @@ -43,12 +43,8 @@ = icon('fas', 'envelope') Send message - - 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: @member), method: :post, class: 'btn btn-block' - - if follow && can?(:destroy, follow) # already following - = link_to 'Unfollow', follow_path(follow), method: :delete, class: 'btn btn-block' + = render 'members/follow_buttons', member: @member + = render "stats", member: @member .card-footer = render "contact", member: @member, twitter_auth: @twitter_auth, diff --git a/app/views/notifications/_form.html.haml b/app/views/notifications/_form.html.haml index 23c844813..5f5880a93 100644 --- a/app/views/notifications/_form.html.haml +++ b/app/views/notifications/_form.html.haml @@ -1,24 +1,26 @@ -= form_for @notification do |f| - - if @notification.errors.any? - #error_explanation - %h2 - = pluralize(@post.errors.size, "error") - prohibited this message from being sent: - %ul - - @notification.errors.full_messages.each do |msg| - %li= msg += bootstrap_form_for @notification do |f| + .card + .card-body + - if @notification.errors.any? + #error_explanation + %h2 + = pluralize(@post.errors.size, "error") + prohibited this message from being sent: + %ul + - @notification.errors.full_messages.each do |msg| + %li= msg - .field - = f.hidden_field :recipient_id, value: @recipient.id + .field + = f.hidden_field :recipient_id, value: @recipient.id - %p - To: - = link_to @recipient, @recipient - = label_tag :notification, "Subject:" - = f.text_field :subject, value: @subject, class: 'form-control', maxlength: 255 - = label_tag :body, "Type your message here:" - = f.text_area :body, rows: 12, class: 'form-control' - %span.help-block - = render partial: "shared/markdown_help" + %p + To + = link_to @recipient, @recipient + = render 'members/tiny', member: @recipient + = f.text_field :subject, value: @subject, class: 'form-control', maxlength: 255 + = f.text_area :body, rows: 12, label: "Type your message here" + %span.help-block= render partial: "shared/markdown_help" + .card-footer - = f.submit "Send", class: 'btn btn-primary' + = link_to 'cancel', notifications_path, class: 'btn' + .float-right= f.submit "Send", class: 'btn btn-primary' diff --git a/app/views/notifications/_notification.html.haml b/app/views/notifications/_notification.html.haml index 898bfe736..881b93c50 100644 --- a/app/views/notifications/_notification.html.haml +++ b/app/views/notifications/_notification.html.haml @@ -1,4 +1,4 @@ -%p +%p.text-muted From = link_to notification.sender, notification.sender on diff --git a/app/views/notifications/index.html.haml b/app/views/notifications/index.html.haml index 8dc28b27b..39a7ccea6 100644 --- a/app/views/notifications/index.html.haml +++ b/app/views/notifications/index.html.haml @@ -4,35 +4,27 @@ .alert.alert-success{role: "alert"} You have no messages. - else = paginate @notifications, theme: 'twitter-bootstrap-3' - %table.table.table-striped - %thead - %tr - %th From - %th Subject - %th Date - %th + .index-cards - @notifications.each do |n| - - if can? :read, n - %tr - %td - - if n.sender.present? - - if n.read - = link_to n.sender, member_path(n.sender) - - else - %strong= link_to n.sender, member_path(n.sender) - - else - *deleted member* - %td - - if n.read - = link_to n.subject, notification_path(n) - - else - %strong= link_to n.subject, notification_path(n) - %td - - if n.read - = n.created_at - - else - %strong= n.created_at - %td - = link_to 'Delete', n, method: :delete, data: { confirm: 'Are you sure?' }, class: 'btn btn-default background-danger btn-xs' - = paginate @notifications, theme: 'twitter-bootstrap-3' + .card.message + .card-body + .row + .col-6 + %p= link_to n.subject, notification_path(n) + %p + - if n.read + = n.created_at + - else + %strong= n.created_at + .col-6 + = render 'members/tiny', member: n.sender + = n.sender + = render 'members/follow_buttons', member: n.sender + .card-footer + = link_to 'Read', n, class: 'btn btn-primary' + = link_to 'Reply', reply_link(n), class: 'btn btn-secondary' + = link_to n, method: :delete, data: { confirm: 'Are you sure?' }, class: 'btn btn-default btn-danger btn-xs' do + = delete_icon + = t('buttons.delete') + = paginate @notifications \ No newline at end of file diff --git a/app/views/notifications/reply.html.haml b/app/views/notifications/reply.html.haml index a363fe8bc..5cd3b8478 100644 --- a/app/views/notifications/reply.html.haml +++ b/app/views/notifications/reply.html.haml @@ -1,6 +1,6 @@ = content_for :title, "Send a message to #{@recipient}" -= render @sender_notification - +.card + .card-body= render @sender_notification = render 'form' diff --git a/app/views/notifications/show.html.haml b/app/views/notifications/show.html.haml index e506f3bac..fd4241eae 100644 --- a/app/views/notifications/show.html.haml +++ b/app/views/notifications/show.html.haml @@ -1,7 +1,13 @@ = content_for :title, @notification.subject -= render @notification +.card + .card-header + .card-title= @notification.subject + .card-body + = render @notification -%p - = link_to 'Delete', @notification, method: :delete, data: { confirm: 'Are you sure?' }, class: 'btn btn-default' - = link_to 'Reply', @reply_link, class: 'btn btn-primary' + .card-footer + = link_to 'Reply', @reply_link, class: 'btn btn-primary' + = link_to @notification, method: :delete, data: { confirm: 'Are you sure?' }, class: 'btn btn-default btn-danger' do + = delete_icon + = t('buttons.delete') From a7837f0d8fab6bb5fbc0e5923325da05d3734d54 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Thu, 11 Jul 2019 11:48:10 +1200 Subject: [PATCH 10/66] Update notification spec to count messages, not rows --- spec/features/notifications_spec.rb | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/spec/features/notifications_spec.rb b/spec/features/notifications_spec.rb index d925d785f..77ac4ce38 100644 --- a/spec/features/notifications_spec.rb +++ b/spec/features/notifications_spec.rb @@ -22,6 +22,7 @@ describe "Notifications", :js do it "Replying to the notification" do click_link "Reply" expect(page).to have_content "Notification body" + Percy.snapshot(page, name: 'Replying to notification') fill_in 'notification_body', with: "Response body" Percy.snapshot(page, name: "notifications#new") @@ -44,12 +45,12 @@ describe "Notifications", :js do end it 'paginates at 30 notifications per page' do - expect(page).to have_selector 'tr', count: 31 + expect(page).to have_selector '.message', count: 30 end it 'navigates pages' do first('a[rel="next"]').click - expect(page).to have_selector 'tr', count: 5 + expect(page).to have_selector '.message', count: 4 end end end From 6383dbc19f368a523ddef63dbbe1717e54598047 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Thu, 11 Jul 2019 12:08:15 +1200 Subject: [PATCH 11/66] more percy specs --- spec/features/admin/admin_spec.rb | 16 ++++++++++++++++ .../comments/commenting_a_comment_spec.rb | 1 + spec/features/crops/alternate_name_spec.rb | 2 ++ spec/features/members/deletion_spec.rb | 1 + spec/features/notifications_spec.rb | 3 +++ spec/features/percy/percy_spec.rb | 5 ----- spec/features/photos/new_photo_spec.rb | 1 + spec/features/photos/show_photo_spec.rb | 1 + spec/features/places/searching_a_place_spec.rb | 1 + 9 files changed, 26 insertions(+), 5 deletions(-) create mode 100644 spec/features/admin/admin_spec.rb diff --git a/spec/features/admin/admin_spec.rb b/spec/features/admin/admin_spec.rb new file mode 100644 index 000000000..6ee586ee7 --- /dev/null +++ b/spec/features/admin/admin_spec.rb @@ -0,0 +1,16 @@ +require 'rails_helper' + +describe "forums", js: true do + context "as an admin user" do + let(:member) { create :admin_member } + + before do + login_as member + end + + it "navigating to forum admin with js" do + visit admin_path + Percy.snapshot(page, name: 'Admin page') + end + end +end diff --git a/spec/features/comments/commenting_a_comment_spec.rb b/spec/features/comments/commenting_a_comment_spec.rb index 2ab3fa615..f2136e98e 100644 --- a/spec/features/comments/commenting_a_comment_spec.rb +++ b/spec/features/comments/commenting_a_comment_spec.rb @@ -14,6 +14,7 @@ describe 'Commenting on a post' do click_button "Post comment" expect(page).to have_content "comment was successfully created." expect(page).to have_content "Posted by" + Percy.snapshot(page, name: 'Posting a comment') end context "editing a comment" do diff --git a/spec/features/crops/alternate_name_spec.rb b/spec/features/crops/alternate_name_spec.rb index cfb4bf3e3..903b6d3a7 100644 --- a/spec/features/crops/alternate_name_spec.rb +++ b/spec/features/crops/alternate_name_spec.rb @@ -34,6 +34,7 @@ describe "Alternate names", js: true do # expect(page.status_code).to equal 200 expect(page).to have_css "option[value='#{crop.id}'][selected=selected]" fill_in 'Name', with: "alternative aubergine" + Percy.snapshot(page, name: 'Crop wrangler adding alternate name') click_on "Save" # expect(page.status_code).to equal 200 expect(page).to have_content "alternative aubergine" @@ -77,6 +78,7 @@ describe "Alternate names", js: true do it "Displays crop rejection message" do visit alternate_name_path(pending_alt_name) expect(page).to have_content "This crop was rejected for the following reason: Totally fake" + Percy.snapshot(page, name: 'Rejecting crops') end end end diff --git a/spec/features/members/deletion_spec.rb b/spec/features/members/deletion_spec.rb index 7d5ac5972..5feb7014b 100644 --- a/spec/features/members/deletion_spec.rb +++ b/spec/features/members/deletion_spec.rb @@ -70,6 +70,7 @@ describe "member deletion" do visit member_path(member) click_link 'Edit profile' click_link 'Delete Account' + Percy.snapshot(page, name: 'Account deletion') fill_in "current_pw_for_delete", with: "password1", match: :prefer_exact click_button "Delete" logout diff --git a/spec/features/notifications_spec.rb b/spec/features/notifications_spec.rb index 77ac4ce38..4b2140d3f 100644 --- a/spec/features/notifications_spec.rb +++ b/spec/features/notifications_spec.rb @@ -37,6 +37,9 @@ describe "Notifications", :js do FactoryBot.create_list :notification, 34, recipient: recipient login_as recipient visit notifications_path + end + + it do Percy.snapshot(page, name: "notifications#index") end diff --git a/spec/features/percy/percy_spec.rb b/spec/features/percy/percy_spec.rb index 9bd59dd78..7b614d169 100644 --- a/spec/features/percy/percy_spec.rb +++ b/spec/features/percy/percy_spec.rb @@ -256,11 +256,6 @@ rest of the garden. end describe '#new' do - it 'plantings#new' do - visit new_planting_path - Percy.snapshot(page, name: "#{prefix}/plantings#new") - end - it 'crops#new' do visit new_crop_path Percy.snapshot(page, name: "#{prefix}/crops#new") diff --git a/spec/features/photos/new_photo_spec.rb b/spec/features/photos/new_photo_spec.rb index 8bf89fc7e..de0ae5664 100644 --- a/spec/features/photos/new_photo_spec.rb +++ b/spec/features/photos/new_photo_spec.rb @@ -18,6 +18,7 @@ describe "new photo page" do click_link('Add photo') end expect(page).to have_text planting.crop.name + Percy.snapshot(page, name: 'Add photo to planting') end end diff --git a/spec/features/photos/show_photo_spec.rb b/spec/features/photos/show_photo_spec.rb index a8d2ff802..2c027d57d 100644 --- a/spec/features/photos/show_photo_spec.rb +++ b/spec/features/photos/show_photo_spec.rb @@ -47,6 +47,7 @@ describe "show photo page" do before do garden.photos << photo visit photo_path(photo) + Percy.snapshot(page, name: 'Show photo of a garden') end it { expect(page).to have_link "garden named \"#{garden.name}\" by #{garden.owner}", href: garden_path(garden) } diff --git a/spec/features/places/searching_a_place_spec.rb b/spec/features/places/searching_a_place_spec.rb index 2db703c0a..fa64ea568 100644 --- a/spec/features/places/searching_a_place_spec.rb +++ b/spec/features/places/searching_a_place_spec.rb @@ -36,6 +36,7 @@ describe "User searches" do expect(page).to have_content "Nearby members" expect(page).to have_content "Seeds available for trade near Philippines" expect(page).to have_content "Recent plantings near Philippines" + Percy.snapshot(page, name: 'places map') end it "goes to members' index page" do From 5233df666d9178b272a9f0f34a66d8293fa759a6 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Thu, 11 Jul 2019 12:12:05 +1200 Subject: [PATCH 12/66] update notification view spec, not a table anymore --- spec/views/notifications/index.html.haml_spec.rb | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/spec/views/notifications/index.html.haml_spec.rb b/spec/views/notifications/index.html.haml_spec.rb index d02e43038..c4ec0280c 100644 --- a/spec/views/notifications/index.html.haml_spec.rb +++ b/spec/views/notifications/index.html.haml_spec.rb @@ -15,9 +15,8 @@ describe "notifications/index" do end it "renders a list of notifications" do - assert_select "table" - assert_select "tr>td", text: @notification.sender.to_s, count: 2 - assert_select "tr>td", text: @notification.subject, count: 2 + has_content @notification.sender.to_s, count: 2 + has_content @notification.subject, count: 2 end it "links to sender's profile" do From 8b47e277ecfb1e5a4a98b934b5b510ab55854e9c Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Thu, 11 Jul 2019 12:14:54 +1200 Subject: [PATCH 13/66] fixes percy error, running same snapshot more than once --- spec/features/members/deletion_spec.rb | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/spec/features/members/deletion_spec.rb b/spec/features/members/deletion_spec.rb index 5feb7014b..7a5ccf273 100644 --- a/spec/features/members/deletion_spec.rb +++ b/spec/features/members/deletion_spec.rb @@ -63,6 +63,17 @@ describe "member deletion" do expect(page).to have_text "The page you were looking for doesn't exist." end + describe 'percy spec' do + it do + logout + login_as(member) + visit member_path(member) + click_link 'Edit profile' + click_link 'Delete Account' + Percy.snapshot(page, name: 'Account deletion') + end + end + context "deletes and" do before do logout @@ -70,7 +81,6 @@ describe "member deletion" do visit member_path(member) click_link 'Edit profile' click_link 'Delete Account' - Percy.snapshot(page, name: 'Account deletion') fill_in "current_pw_for_delete", with: "password1", match: :prefer_exact click_button "Delete" logout From 13813c46938957b79b2446cd0bd2938897fcc0fd Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Thu, 11 Jul 2019 12:41:02 +1200 Subject: [PATCH 14/66] Fix spec for notifications#index --- spec/views/notifications/index.html.haml_spec.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spec/views/notifications/index.html.haml_spec.rb b/spec/views/notifications/index.html.haml_spec.rb index c4ec0280c..eece9f23e 100644 --- a/spec/views/notifications/index.html.haml_spec.rb +++ b/spec/views/notifications/index.html.haml_spec.rb @@ -15,8 +15,8 @@ describe "notifications/index" do end it "renders a list of notifications" do - has_content @notification.sender.to_s, count: 2 - has_content @notification.subject, count: 2 + expect(rendered).to have_content @notification.sender.to_s, count: 2 + expect(rendered).to have_content @notification.subject, count: 2 end it "links to sender's profile" do From b064d8db96ad320dcee84e38583ba012921407fc Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Thu, 11 Jul 2019 13:06:02 +1200 Subject: [PATCH 15/66] tidy up larger screen display of inbox --- app/assets/stylesheets/application.scss | 21 +++++----- app/assets/stylesheets/notifications.scss | 3 ++ app/views/notifications/index.html.haml | 47 ++++++++++++----------- 3 files changed, 39 insertions(+), 32 deletions(-) create mode 100644 app/assets/stylesheets/notifications.scss diff --git a/app/assets/stylesheets/application.scss b/app/assets/stylesheets/application.scss index fc958cd69..03c66c680 100644 --- a/app/assets/stylesheets/application.scss +++ b/app/assets/stylesheets/application.scss @@ -8,16 +8,6 @@ @import 'leaflet'; @import 'leaflet.markercluster'; -@import 'predictions'; -@import 'plantings'; -@import 'members'; -@import 'harvests'; -@import 'seeds'; -@import 'posts'; -@import 'crops'; - -@import 'homepage'; -@import 'photos'; // Font Awesome @import 'font-awesome-sprockets'; @@ -26,3 +16,14 @@ @import 'rails_bootstrap_forms'; @import 'overrides'; +@import 'crops'; +@import 'harvests'; +@import 'members'; +@import 'notifications'; +@import 'plantings'; +@import 'posts'; +@import 'predictions'; +@import 'seeds'; + +@import 'homepage'; +@import 'photos'; diff --git a/app/assets/stylesheets/notifications.scss b/app/assets/stylesheets/notifications.scss new file mode 100644 index 000000000..fde249d0a --- /dev/null +++ b/app/assets/stylesheets/notifications.scss @@ -0,0 +1,3 @@ +.message { + width: 100%; +} diff --git a/app/views/notifications/index.html.haml b/app/views/notifications/index.html.haml index 39a7ccea6..d275b7161 100644 --- a/app/views/notifications/index.html.haml +++ b/app/views/notifications/index.html.haml @@ -5,26 +5,29 @@ - else = paginate @notifications, theme: 'twitter-bootstrap-3' - .index-cards - - @notifications.each do |n| - .card.message - .card-body - .row - .col-6 - %p= link_to n.subject, notification_path(n) - %p - - if n.read - = n.created_at - - else - %strong= n.created_at - .col-6 - = render 'members/tiny', member: n.sender - = n.sender - = render 'members/follow_buttons', member: n.sender - .card-footer - = link_to 'Read', n, class: 'btn btn-primary' - = link_to 'Reply', reply_link(n), class: 'btn btn-secondary' - = link_to n, method: :delete, data: { confirm: 'Are you sure?' }, class: 'btn btn-default btn-danger btn-xs' do - = delete_icon - = t('buttons.delete') + - @notifications.each do |n| + .card.message + .card-body + .row + .col-6.col-md-9 + %h3= link_to n.subject, notification_path(n) + %p + - if n.read + = icon 'far', 'envelope-open' + - else + = icon 'far', 'envelope' + %strong unread + = n.created_at + .col-6.col-md-3.text-right + = link_to n.sender do + %h3 + = render 'members/tiny', member: n.sender + = n.sender + = render 'members/follow_buttons', member: n.sender + .card-footer + = link_to 'Read', n, class: 'btn btn-primary' + = link_to 'Reply', reply_link(n), class: 'btn btn-secondary' + = link_to n, method: :delete, data: { confirm: 'Are you sure?' }, class: 'btn btn-default btn-danger btn-xs' do + = delete_icon + = t('buttons.delete') = paginate @notifications \ No newline at end of file From edf4985da0f7e45ab2b5790635e410fd3de0b62d Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Thu, 11 Jul 2019 13:13:11 +1200 Subject: [PATCH 16/66] adding breadcrumbs --- app/views/notifications/index.html.haml | 2 ++ app/views/notifications/new.html.haml | 2 ++ app/views/notifications/reply.html.haml | 2 ++ app/views/notifications/show.html.haml | 7 +++++++ 4 files changed, 13 insertions(+) diff --git a/app/views/notifications/index.html.haml b/app/views/notifications/index.html.haml index d275b7161..6568fef89 100644 --- a/app/views/notifications/index.html.haml +++ b/app/views/notifications/index.html.haml @@ -1,4 +1,6 @@ - content_for :title, "Inbox" +- content_for :breadcrumbs do + %li.breadcrumb-item.active= link_to 'Messages', notifications_path - if @notifications.empty? .alert.alert-success{role: "alert"} You have no messages. diff --git a/app/views/notifications/new.html.haml b/app/views/notifications/new.html.haml index 633e26193..721dcca7d 100644 --- a/app/views/notifications/new.html.haml +++ b/app/views/notifications/new.html.haml @@ -1,4 +1,6 @@ = content_for :title, "Send a message to #{@recipient}" +- content_for :breadcrumbs do + %li.breadcrumb-item= link_to 'Messages', notifications_path = render 'form' diff --git a/app/views/notifications/reply.html.haml b/app/views/notifications/reply.html.haml index 5cd3b8478..54230dff4 100644 --- a/app/views/notifications/reply.html.haml +++ b/app/views/notifications/reply.html.haml @@ -1,4 +1,6 @@ = content_for :title, "Send a message to #{@recipient}" +- content_for :breadcrumbs do + %li.breadcrumb-item= link_to 'Messages', notifications_path .card .card-body= render @sender_notification diff --git a/app/views/notifications/show.html.haml b/app/views/notifications/show.html.haml index fd4241eae..2303c9ea5 100644 --- a/app/views/notifications/show.html.haml +++ b/app/views/notifications/show.html.haml @@ -1,8 +1,15 @@ = content_for :title, @notification.subject +- content_for :breadcrumbs do + %li.breadcrumb-item= link_to 'Messages', notifications_path + .card .card-header .card-title= @notification.subject + .float-right + = link_to @notification.sender do + = @notification.sender + = render 'members/tiny', member: @notification.sender .card-body = render @notification From 5c69dc052867a53b43578479f1c2db1c8b3a36cd Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Thu, 11 Jul 2019 13:17:31 +1200 Subject: [PATCH 17/66] use badges for unread message count --- app/views/layouts/_header.html.haml | 10 ++++++---- config/locales/en.yml | 2 +- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/app/views/layouts/_header.html.haml b/app/views/layouts/_header.html.haml index 780789096..8093caccb 100644 --- a/app/views/layouts/_header.html.haml +++ b/app/views/layouts/_header.html.haml @@ -29,7 +29,8 @@ %li.nav-item.dropdown %a.nav-link.dropdown-toggle{"aria-expanded" => "false", "aria-haspopup" => "true", "data-toggle" => "dropdown", href: "#", role: "button"} - if current_member.notifications.unread_count.positive? - = t('.your_stuff', unread_count: current_member.notifications.unread_count) + = t('.your_stuff') + %span.badge.badge-info= current_member.notifications.unread_count - else = t('.current_memberlogin_name', current_memberlogin_name: current_member.login_name) .dropdown-menu{"aria-labelledby" => "navbarDropdown"} @@ -47,9 +48,10 @@ - if current_member.notifications.unread_count.positive? .dropdown-divider - %strong= link_to(t('.inbox_unread', - unread_count: current_member.notifications.unread_count), - notifications_path, class: 'dropdown-item') + %strong + = link_to(notifications_path, class: 'dropdown-item') do + = t('.inbox') + %span.badge.badge-info= current_member.notifications.unread_count - else = link_to t('.inbox'), notifications_path, class: 'dropdown-item' diff --git a/config/locales/en.yml b/config/locales/en.yml index 627762143..3c6a765e2 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -236,7 +236,7 @@ en: skip: Skip navigation menu support_growstuff: Support Growstuff toggle_navigation: Toggle Navigation - your_stuff: Your Stuff (%{unread_count}) + your_stuff: Your Stuff links: my_gardens: My gardens members: From 88da4a724d0f8d19acd88348f265498c0630e486 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Thu, 11 Jul 2019 13:20:40 +1200 Subject: [PATCH 18/66] Add the unread inbox menu display to percy --- spec/features/notifications_spec.rb | 3 +++ 1 file changed, 3 insertions(+) diff --git a/spec/features/notifications_spec.rb b/spec/features/notifications_spec.rb index 4b2140d3f..dc149c7d9 100644 --- a/spec/features/notifications_spec.rb +++ b/spec/features/notifications_spec.rb @@ -15,6 +15,9 @@ describe "Notifications", :js do before do login_as recipient + visit root_path + click_link 'Your Stuff' + Percy.snapshot(page, name: "notification menu") visit notification_path(notification) Percy.snapshot(page, name: "notifications#show") end From 347417b7edd0bd46fe07d669b365830ce5bef1a1 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Thu, 11 Jul 2019 17:26:40 +1200 Subject: [PATCH 19/66] Put newest messages at the top of the page --- 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 0b145b04b..a340bd6f7 100644 --- a/app/controllers/notifications_controller.rb +++ b/app/controllers/notifications_controller.rb @@ -6,7 +6,7 @@ class NotificationsController < ApplicationController # GET /notifications def index - @notifications = Notification.by_recipient(current_member).order(:created_at).paginate(page: params[:page], per_page: 30) + @notifications = Notification.by_recipient(current_member).order(created_at: desc).paginate(page: params[:page], per_page: 30) end # GET /notifications/1 From 2a390f9c246b96047ce0ad985a66e369f53ea892 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Thu, 11 Jul 2019 19:53:45 +1200 Subject: [PATCH 20/66] Fix sorting --- 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 a340bd6f7..9b93b7324 100644 --- a/app/controllers/notifications_controller.rb +++ b/app/controllers/notifications_controller.rb @@ -6,7 +6,7 @@ class NotificationsController < ApplicationController # GET /notifications def index - @notifications = Notification.by_recipient(current_member).order(created_at: desc).paginate(page: params[:page], per_page: 30) + @notifications = Notification.by_recipient(current_member).order(created_at: :desc).paginate(page: params[:page], per_page: 30) end # GET /notifications/1 From 01e8cafb9f0c6d43e9f6175346341dff921d7af9 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Thu, 11 Jul 2019 20:11:49 +1200 Subject: [PATCH 21/66] Update inbox link in spec --- spec/views/layouts/_header_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/views/layouts/_header_spec.rb b/spec/views/layouts/_header_spec.rb index f4521ee88..184825051 100644 --- a/spec/views/layouts/_header_spec.rb +++ b/spec/views/layouts/_header_spec.rb @@ -82,7 +82,7 @@ describe 'layouts/_header.html.haml', type: "view" do it 'shows inbox link' do rendered.should have_content 'Inbox' - rendered.should_not match(/Inbox \(\d+\)/) + rendered.should_not match(/Inbox \d+/) end context 'has notifications' do From 93e7703a6a5230a700d0b232d9f0e80e874c8ccb Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Thu, 11 Jul 2019 20:13:10 +1200 Subject: [PATCH 22/66] Add missing translation --- config/locales/en.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/config/locales/en.yml b/config/locales/en.yml index 3c6a765e2..11dd0a781 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -89,6 +89,7 @@ en: plant_something_here: Plant something here record_harvest: Record Harvest save_seeds: Save seeds + timeline: Timeline write_blog_post: Write blog post crops: search: Search crops From 5c1dd2ac6bd62d0f3507b273ccd1bedf221017cd Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Thu, 11 Jul 2019 22:01:03 +1200 Subject: [PATCH 23/66] Update inbox link in spec --- spec/views/layouts/_header_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/views/layouts/_header_spec.rb b/spec/views/layouts/_header_spec.rb index 184825051..4a39e99b3 100644 --- a/spec/views/layouts/_header_spec.rb +++ b/spec/views/layouts/_header_spec.rb @@ -89,7 +89,7 @@ describe 'layouts/_header.html.haml', type: "view" do it 'shows inbox count' do FactoryBot.create(:notification, recipient: @member) render - rendered.should have_content 'Inbox (1)' + rendered.should have_content 'Inbox 1' end end end From 738644ffbc2077ed628b6be0b245a97e571320e3 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Thu, 11 Jul 2019 22:06:55 +1200 Subject: [PATCH 24/66] Remove unnecesary theme param from pagination --- app/views/notifications/index.html.haml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/notifications/index.html.haml b/app/views/notifications/index.html.haml index 6568fef89..484fe6c10 100644 --- a/app/views/notifications/index.html.haml +++ b/app/views/notifications/index.html.haml @@ -5,7 +5,7 @@ - if @notifications.empty? .alert.alert-success{role: "alert"} You have no messages. - else - = paginate @notifications, theme: 'twitter-bootstrap-3' + = paginate @notifications - @notifications.each do |n| .card.message From 40e966223452610a1277d2372dbb2ba4b1c66377 Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Thu, 11 Jul 2019 10:29:45 +0000 Subject: [PATCH 25/66] Bump jsonapi-resources from 0.9.9 to 0.9.10 Bumps [jsonapi-resources](https://github.com/cerebris/jsonapi-resources) from 0.9.9 to 0.9.10. - [Release notes](https://github.com/cerebris/jsonapi-resources/releases) - [Commits](https://github.com/cerebris/jsonapi-resources/compare/v0.9.9...v0.9.10) Signed-off-by: dependabot-preview[bot] --- Gemfile.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile.lock b/Gemfile.lock index 0fd7810ab..ffaf233b4 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -249,7 +249,7 @@ GEM railties (>= 4) sprockets-rails json (2.2.0) - jsonapi-resources (0.9.9) + jsonapi-resources (0.9.10) activerecord (>= 4.1) concurrent-ruby railties (>= 4.1) From ae1e48129c9b1284db758e4e354368439283dc7d Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Thu, 11 Jul 2019 12:08:15 +1200 Subject: [PATCH 26/66] more percy specs --- spec/features/members/deletion_spec.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/spec/features/members/deletion_spec.rb b/spec/features/members/deletion_spec.rb index 7a5ccf273..9d51ef6b1 100644 --- a/spec/features/members/deletion_spec.rb +++ b/spec/features/members/deletion_spec.rb @@ -81,6 +81,7 @@ describe "member deletion" do visit member_path(member) click_link 'Edit profile' click_link 'Delete Account' + Percy.snapshot(page, name: 'Account deletion') fill_in "current_pw_for_delete", with: "password1", match: :prefer_exact click_button "Delete" logout From 3d92cd1d1d3940b374f3f3e7a6ae096483582c9c Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Thu, 11 Jul 2019 12:14:54 +1200 Subject: [PATCH 27/66] fixes percy error, running same snapshot more than once --- spec/features/members/deletion_spec.rb | 1 - 1 file changed, 1 deletion(-) diff --git a/spec/features/members/deletion_spec.rb b/spec/features/members/deletion_spec.rb index 9d51ef6b1..7a5ccf273 100644 --- a/spec/features/members/deletion_spec.rb +++ b/spec/features/members/deletion_spec.rb @@ -81,7 +81,6 @@ describe "member deletion" do visit member_path(member) click_link 'Edit profile' click_link 'Delete Account' - Percy.snapshot(page, name: 'Account deletion') fill_in "current_pw_for_delete", with: "password1", match: :prefer_exact click_button "Delete" logout From 7b6dc1943a80543f68444e907b6c46f46ebbf131 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Thu, 11 Jul 2019 22:35:17 +1200 Subject: [PATCH 28/66] Fixes staging linking to production --- config/environments/production.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/environments/production.rb b/config/environments/production.rb index fd66532d7..9adee7c27 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -100,7 +100,7 @@ Rails.application.configure do } ActionMailer::Base.delivery_method = :smtp - config.host = 'growstuff.org' + config.host = ENV['HOST'] config.analytics_code = <<-eos From 408e8388f2930a9ad5fe3b1fe7e6e82c158eba66 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Thu, 11 Jul 2019 22:38:39 +1200 Subject: [PATCH 29/66] Use relative paths for markdown crop links --- lib/haml/filters/growstuff_markdown.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/haml/filters/growstuff_markdown.rb b/lib/haml/filters/growstuff_markdown.rb index 4e7617c15..0a7c34000 100644 --- a/lib/haml/filters/growstuff_markdown.rb +++ b/lib/haml/filters/growstuff_markdown.rb @@ -54,7 +54,7 @@ module Haml::Filters # rubocop:disable Style/ClassAndModuleChildren def crop_link(crop, link_text) if crop - url = Rails.application.routes.url_helpers.crop_url(crop, host: HOST) + url = Rails.application.routes.url_helpers.crop_url(crop, only_path: true) "[#{link_text}](#{url})" else link_text From addb9a48cf266e9db1faa6d5fce41c7a982cc47c Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Thu, 11 Jul 2019 23:32:29 +1200 Subject: [PATCH 30/66] Fix growstuff markdown specs to expect path only links --- spec/lib/haml/filters/growstuff_markdown_spec.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spec/lib/haml/filters/growstuff_markdown_spec.rb b/spec/lib/haml/filters/growstuff_markdown_spec.rb index 597137f6d..cc27bd560 100644 --- a/spec/lib/haml/filters/growstuff_markdown_spec.rb +++ b/spec/lib/haml/filters/growstuff_markdown_spec.rb @@ -7,7 +7,7 @@ def input_link(name) end def output_link(crop, name = nil) - url = Rails.application.routes.url_helpers.crop_url(crop, host: Rails.application.config.host) + url = Rails.application.routes.url_helpers.crop_url(crop, only_path: true) return "#{name}" if name "#{crop.name}" @@ -62,7 +62,7 @@ describe 'Haml::Filters::Growstuff_Markdown' do end it "finds crops case insensitively" do - @crop = FactoryBot.create(:crop, name: 'tomato') + @crop = FactoryBot.create(:crop, name: 'tomato', slug: 'tomato') rendered = Haml::Filters::GrowstuffMarkdown.render(input_link('ToMaTo')) expect(rendered).to match(/#{output_link(@crop, 'ToMaTo')}/) end From 7d1f9c5a3af338066735179fb4ae648e2f65d8a7 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Fri, 12 Jul 2019 08:47:22 +1200 Subject: [PATCH 31/66] Most post like into a wrapper in the html --- app/assets/javascripts/likes.js | 6 +++--- app/views/photos/show.html.haml | 3 ++- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/app/assets/javascripts/likes.js b/app/assets/javascripts/likes.js index 5a03bedd5..cfa3ac94c 100644 --- a/app/assets/javascripts/likes.js +++ b/app/assets/javascripts/likes.js @@ -19,9 +19,9 @@ $(document).ready(function() { $('.photo-like').show(); $('.photo-like').on('ajax:success', function(event, data) { - var likeControl = $('.photo-like'); - - $('.like-count').text(data.description); + var likeControl = $('#photo-'+ data.id + ' .photo-like'); + console.log(data); + $('#photo-' + data.id + ' .like-count').text(data.description); if (data.liked_by_member) { likeControl.data('method', 'delete'); likeControl.attr('href', data.url); diff --git a/app/views/photos/show.html.haml b/app/views/photos/show.html.haml index 302d6cbaf..fb4e17cc2 100644 --- a/app/views/photos/show.html.haml +++ b/app/views/photos/show.html.haml @@ -11,12 +11,13 @@ %li.breadcrumb-item= link_to 'Photos', photos_path %li.breadcrumb-item.active= link_to @photo, @photo -.row +.row{id: "photo-#{@photo.id}"} .col-md-8 %h1.text-center.ellipsis=@photo.title %p.text-center = image_tag(@photo.fullsize_url, alt: @photo.title, class: 'rounded img-fluid shadow-sm') .col-md-4 + %p.text-center{ id: "photo-#{@photo.id}" } = render 'photos/actions', photo: @photo = link_to "View on Flickr", @photo.link_url, class: 'btn' From af0d84d9f15a4110b18f8f1c08ba20657b41618e Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Fri, 12 Jul 2019 09:28:45 +1200 Subject: [PATCH 32/66] Updating likes js code --- app/assets/javascripts/likes.js | 29 ++++++++++++++++----------- app/controllers/likes_controller.rb | 1 + app/helpers/icons_helper.rb | 2 +- app/views/photos/_card.html.haml | 3 ++- app/views/photos/_likes.html.haml | 18 ++++++++--------- app/views/photos/_thumbnail.html.haml | 3 +-- app/views/posts/_likes.html.haml | 10 ++++----- 7 files changed, 34 insertions(+), 32 deletions(-) diff --git a/app/assets/javascripts/likes.js b/app/assets/javascripts/likes.js index cfa3ac94c..9e06d0c4a 100644 --- a/app/assets/javascripts/likes.js +++ b/app/assets/javascripts/likes.js @@ -1,10 +1,10 @@ $(document).ready(function() { - $('.post-like').show(); + $('.like-btn').show(); $('.post-like').on('ajax:success', function(event, data) { var likeControl = $('#post-' + data.id + ' .post-like'); - $('#post-' + data.id + ' .like-count').text(data.description); + $('#post-' + data.id + ' .like-count').text(data.like_count); if (data.liked_by_member) { likeControl.data('method', 'delete'); likeControl.attr('href', data.url); @@ -16,20 +16,25 @@ $(document).ready(function() { } }); - $('.photo-like').show(); $('.photo-like').on('ajax:success', function(event, data) { - var likeControl = $('#photo-'+ data.id + ' .photo-like'); - console.log(data); - $('#photo-' + data.id + ' .like-count').text(data.description); + var like_badge = $('#photo-'+ data.id + ' .like-badge'); + var like_count = $('#photo-'+ data.id + ' .like-count'); + var like_button = $('#photo-'+ data.id + ' .like-btn'); + + $('#photo-' + data.id + ' .like-count').text(data.like_count); if (data.liked_by_member) { - likeControl.data('method', 'delete'); - likeControl.attr('href', data.url); - likeControl.text('Unlike'); + like_badge.addClass('text-success'); + // Turn the button into an unlike button + like_button.data('method', 'delete'); + like_button.attr('href', data.url); + like_button.text('Unlike'); } else { - likeControl.data('method', 'post'); - likeControl.attr('href', '/likes.json?photo_id=' + data.id); - likeControl.text('Like'); + like_badge.removeClass('text-success'); + // Turn the button into an *like* button + like_button.data('method', 'post'); + like_button.attr('href', '/likes.json?photo_id=' + data.id); + like_button.text('Like'); } }); }); diff --git a/app/controllers/likes_controller.rb b/app/controllers/likes_controller.rb index 75113289c..2837dfb0a 100644 --- a/app/controllers/likes_controller.rb +++ b/app/controllers/likes_controller.rb @@ -29,6 +29,7 @@ class LikesController < ApplicationController def render_json(like, liked_by_member: true) { id: like.likeable.id, + like_count: like.likeable.likes.count, liked_by_member: liked_by_member, description: ActionController::Base.helpers.pluralize(like.likeable.likes.count, "like"), url: like_path(like, format: :json) diff --git a/app/helpers/icons_helper.rb b/app/helpers/icons_helper.rb index 2fa078313..a691b5218 100644 --- a/app/helpers/icons_helper.rb +++ b/app/helpers/icons_helper.rb @@ -70,7 +70,7 @@ module IconsHelper end def like_icon - icon('fas', 'thumbs-up') + icon('fas', 'heart') end def sunniness_icon(sunniness) diff --git a/app/views/photos/_card.html.haml b/app/views/photos/_card.html.haml index d69c0230b..e0a99ab80 100644 --- a/app/views/photos/_card.html.haml +++ b/app/views/photos/_card.html.haml @@ -1,4 +1,4 @@ -.card.photo-card +.card.photo-card{id: "photo-#{photo.id}"} = link_to image_tag(photo.fullsize_url, alt: photo.title, class: 'img img-card'), photo .card-body %h3.ellipsis= link_to photo.title, photo @@ -7,3 +7,4 @@ - if photo.date_taken.present? %small= I18n.l(photo.date_taken.to_date) + = render 'photos/likes', photo: photo diff --git a/app/views/photos/_likes.html.haml b/app/views/photos/_likes.html.haml index 93acc4bf0..7f2bd2412 100644 --- a/app/views/photos/_likes.html.haml +++ b/app/views/photos/_likes.html.haml @@ -1,17 +1,15 @@ - if member_signed_in? - - if !photo.members.include? current_member - - if can?(:new, Like) - = link_to 'Like', likes_path(photo_id: photo.id, format: :json), - method: :post, remote: true, class: 'photo-like btn' + - if can?(:new, Like) + = link_to 'Like', likes_path(photo_id: photo.id, format: :json), + method: :post, remote: true, class: 'photo-like btn like-btn' - else - like = photo.likes.find_by(member: current_member) - if like && can?(:destroy, like) = link_to 'Unlike', like_path(id: like.id, format: :json), - method: :delete, remote: true, class: 'photo-like btn' + method: :delete, remote: true, class: 'photo-like btn like-btn' -%span.badge.badge-info - .like-count - - unless photo.likes.empty? - = like_icon - = pluralize(photo.likes.count, "like") +%span.badge.like-badge + = like_icon +   + %span.like-count= photo.likes.count diff --git a/app/views/photos/_thumbnail.html.haml b/app/views/photos/_thumbnail.html.haml index dfc6483d3..b6b619f63 100644 --- a/app/views/photos/_thumbnail.html.haml +++ b/app/views/photos/_thumbnail.html.haml @@ -1,5 +1,5 @@ .thumbnail - .photo-thumbnail + .photo-thumbnail{id: "photo-#{photo.id}"} = link_to image_tag(photo.thumbnail_url, alt: photo.title, class: 'img img-responsive rounded'), photo .text.ellipsis %p @@ -9,4 +9,3 @@ %i by = link_to photo.owner, photo.owner - diff --git a/app/views/posts/_likes.html.haml b/app/views/posts/_likes.html.haml index 56ed606d7..6df9c745e 100644 --- a/app/views/posts/_likes.html.haml +++ b/app/views/posts/_likes.html.haml @@ -10,9 +10,7 @@ = link_to 'Unlike', like_path(id: like.id, format: :json), method: :delete, remote: true, class: 'post-like btn' - -%span.badge.badge-info - .like-count - - unless post.likes.empty? - = like_icon - = pluralize(post.likes.count, "like") +%span.badge.like-badge + = like_icon +   + %span.like-count= post.likes.count From 2b1895968ba246baab6a0488770c0a15c11093c8 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Fri, 12 Jul 2019 09:32:03 +1200 Subject: [PATCH 33/66] reverting a line aparently this link works out if you've already like it --- app/views/photos/_likes.html.haml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/app/views/photos/_likes.html.haml b/app/views/photos/_likes.html.haml index 7f2bd2412..68255062a 100644 --- a/app/views/photos/_likes.html.haml +++ b/app/views/photos/_likes.html.haml @@ -1,8 +1,9 @@ - if member_signed_in? - - if can?(:new, Like) - = link_to 'Like', likes_path(photo_id: photo.id, format: :json), - method: :post, remote: true, class: 'photo-like btn like-btn' + - if !photo.members.include? current_member + - if can?(:new, Like) + = link_to 'Like', likes_path(photo_id: photo.id, format: :json), + method: :post, remote: true, class: 'photo-like btn like-btn' - else - like = photo.likes.find_by(member: current_member) - if like && can?(:destroy, like) From b36e80bbad998cd3b39a83536c2aed220bde4379 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Fri, 12 Jul 2019 09:37:44 +1200 Subject: [PATCH 34/66] Use our own class to indicate liked --- app/assets/javascripts/likes.js | 4 ++-- app/assets/stylesheets/_likes.scss | 4 ++++ app/assets/stylesheets/application.scss | 1 + 3 files changed, 7 insertions(+), 2 deletions(-) create mode 100644 app/assets/stylesheets/_likes.scss diff --git a/app/assets/javascripts/likes.js b/app/assets/javascripts/likes.js index 9e06d0c4a..bebc02aff 100644 --- a/app/assets/javascripts/likes.js +++ b/app/assets/javascripts/likes.js @@ -24,13 +24,13 @@ $(document).ready(function() { $('#photo-' + data.id + ' .like-count').text(data.like_count); if (data.liked_by_member) { - like_badge.addClass('text-success'); + like_badge.addClass('liked'); // Turn the button into an unlike button like_button.data('method', 'delete'); like_button.attr('href', data.url); like_button.text('Unlike'); } else { - like_badge.removeClass('text-success'); + like_badge.removeClass('liked'); // Turn the button into an *like* button like_button.data('method', 'post'); like_button.attr('href', '/likes.json?photo_id=' + data.id); diff --git a/app/assets/stylesheets/_likes.scss b/app/assets/stylesheets/_likes.scss new file mode 100644 index 000000000..18f256844 --- /dev/null +++ b/app/assets/stylesheets/_likes.scss @@ -0,0 +1,4 @@ +.liked { + background-color: $white; + color: $red; +} \ No newline at end of file diff --git a/app/assets/stylesheets/application.scss b/app/assets/stylesheets/application.scss index 03c66c680..15c7d43c2 100644 --- a/app/assets/stylesheets/application.scss +++ b/app/assets/stylesheets/application.scss @@ -18,6 +18,7 @@ @import 'overrides'; @import 'crops'; @import 'harvests'; +@import 'likes'; @import 'members'; @import 'notifications'; @import 'plantings'; From a87248a43e59f1263afc3cad0691e62efe604dce Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Fri, 12 Jul 2019 09:42:45 +1200 Subject: [PATCH 35/66] DRY up detecting if photo/post already liked --- app/models/concerns/likeable.rb | 4 ++++ app/views/photos/_likes.html.haml | 9 ++++----- app/views/posts/_likes.html.haml | 9 ++++----- 3 files changed, 12 insertions(+), 10 deletions(-) diff --git a/app/models/concerns/likeable.rb b/app/models/concerns/likeable.rb index 328cf3153..4937af53e 100644 --- a/app/models/concerns/likeable.rb +++ b/app/models/concerns/likeable.rb @@ -5,4 +5,8 @@ module Likeable has_many :likes, as: :likeable, inverse_of: :likeable, dependent: :destroy has_many :members, through: :likes end + + def liked_by?(member) + member && members.include?(member) + end end diff --git a/app/views/photos/_likes.html.haml b/app/views/photos/_likes.html.haml index 68255062a..91f315dd2 100644 --- a/app/views/photos/_likes.html.haml +++ b/app/views/photos/_likes.html.haml @@ -1,16 +1,15 @@ - if member_signed_in? - - if !photo.members.include? current_member - - if can?(:new, Like) - = link_to 'Like', likes_path(photo_id: photo.id, format: :json), - method: :post, remote: true, class: 'photo-like btn like-btn' + - if can?(:new, Like) && !photo.liked_by?(current_member) + = link_to 'Like', likes_path(photo_id: photo.id, format: :json), + method: :post, remote: true, class: 'photo-like btn like-btn' - else - like = photo.likes.find_by(member: current_member) - if like && can?(:destroy, like) = link_to 'Unlike', like_path(id: like.id, format: :json), method: :delete, remote: true, class: 'photo-like btn like-btn' -%span.badge.like-badge +%span.badge.like-badge{class: (photo.liked_by?(current_member)) ? 'liked' : ''} = like_icon   %span.like-count= photo.likes.count diff --git a/app/views/posts/_likes.html.haml b/app/views/posts/_likes.html.haml index 6df9c745e..c936bbd20 100644 --- a/app/views/posts/_likes.html.haml +++ b/app/views/posts/_likes.html.haml @@ -1,16 +1,15 @@ - if member_signed_in? - - if !post.members.include? current_member - - if can?(:new, Like) - = link_to 'Like', likes_path(post_id: post.id, format: :json), - method: :post, remote: true, class: 'post-like btn' + - if can?(:new, Like) && !post.liked_by?(current_member) + = link_to 'Like', likes_path(post_id: post.id, format: :json), + method: :post, remote: true, class: 'post-like btn' - else - like = post.likes.find_by(member: current_member) - if like && can?(:destroy, like) = link_to 'Unlike', like_path(id: like.id, format: :json), method: :delete, remote: true, class: 'post-like btn' -%span.badge.like-badge +%span.badge.like-badge{class: (post.liked_by?(current_member)) ? 'liked' : ''} = like_icon   %span.like-count= post.likes.count From 96863058574a920a7f2b27957779b44fde070be9 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Fri, 12 Jul 2019 10:13:24 +1200 Subject: [PATCH 36/66] The like icons are now the buttons --- app/assets/javascripts/likes.js | 20 ++++++++++---------- app/assets/stylesheets/_likes.scss | 5 ++++- app/views/likes/_count.haml | 4 ++++ app/views/photos/_card.html.haml | 13 +++++++------ app/views/photos/_likes.html.haml | 18 ++++++++---------- app/views/photos/show.html.haml | 4 ++-- app/views/posts/_likes.html.haml | 9 +++++---- 7 files changed, 40 insertions(+), 33 deletions(-) create mode 100644 app/views/likes/_count.haml diff --git a/app/assets/javascripts/likes.js b/app/assets/javascripts/likes.js index bebc02aff..2cd95dc54 100644 --- a/app/assets/javascripts/likes.js +++ b/app/assets/javascripts/likes.js @@ -2,24 +2,26 @@ $(document).ready(function() { $('.like-btn').show(); $('.post-like').on('ajax:success', function(event, data) { - var likeControl = $('#post-' + data.id + ' .post-like'); + var like_button = $('#post-' + data.id + ' .post-like'); + var like_badge = $('#post-'+ data.id + ' .like-badge'); $('#post-' + data.id + ' .like-count').text(data.like_count); if (data.liked_by_member) { - likeControl.data('method', 'delete'); - likeControl.attr('href', data.url); - likeControl.text('Unlike'); + like_badge.addClass('liked'); + like_button.data('method', 'delete'); + like_button.attr('href', data.url); + like_button.text('Unlike'); } else { - likeControl.data('method', 'post'); - likeControl.attr('href', '/likes.json?post_id=' + data.id); - likeControl.text('Like'); + like_badge.removeClass('liked'); + like_button.data('method', 'post'); + like_button.attr('href', '/likes.json?post_id=' + data.id); + like_button.text('Like'); } }); $('.photo-like').on('ajax:success', function(event, data) { var like_badge = $('#photo-'+ data.id + ' .like-badge'); - var like_count = $('#photo-'+ data.id + ' .like-count'); var like_button = $('#photo-'+ data.id + ' .like-btn'); $('#photo-' + data.id + ' .like-count').text(data.like_count); @@ -28,13 +30,11 @@ $(document).ready(function() { // Turn the button into an unlike button like_button.data('method', 'delete'); like_button.attr('href', data.url); - like_button.text('Unlike'); } else { like_badge.removeClass('liked'); // Turn the button into an *like* button like_button.data('method', 'post'); like_button.attr('href', '/likes.json?photo_id=' + data.id); - like_button.text('Like'); } }); }); diff --git a/app/assets/stylesheets/_likes.scss b/app/assets/stylesheets/_likes.scss index 18f256844..8e837f409 100644 --- a/app/assets/stylesheets/_likes.scss +++ b/app/assets/stylesheets/_likes.scss @@ -1,4 +1,7 @@ .liked { - background-color: $white; color: $red; +} + +.like-btn { + color: $brown } \ No newline at end of file diff --git a/app/views/likes/_count.haml b/app/views/likes/_count.haml new file mode 100644 index 000000000..56f72e7e7 --- /dev/null +++ b/app/views/likes/_count.haml @@ -0,0 +1,4 @@ +%span.badge.like-badge{class: (likeable.liked_by?(current_member)) ? 'liked' : ''} + = like_icon +   + %span.like-count= likeable.likes.count diff --git a/app/views/photos/_card.html.haml b/app/views/photos/_card.html.haml index e0a99ab80..46afcbf7b 100644 --- a/app/views/photos/_card.html.haml +++ b/app/views/photos/_card.html.haml @@ -1,10 +1,11 @@ .card.photo-card{id: "photo-#{photo.id}"} = link_to image_tag(photo.fullsize_url, alt: photo.title, class: 'img img-card'), photo .card-body - %h3.ellipsis= link_to photo.title, photo - %p - %i by #{link_to photo.owner, photo.owner} - - if photo.date_taken.present? - %small= I18n.l(photo.date_taken.to_date) + %h5.ellipsis= link_to photo.title, photo + %i by #{link_to photo.owner, photo.owner} + - if photo.date_taken.present? + %small + %time{datetime: photo.date_taken} + = I18n.l(photo.date_taken.to_date) + = render 'photos/likes', photo: photo - = render 'photos/likes', photo: photo diff --git a/app/views/photos/_likes.html.haml b/app/views/photos/_likes.html.haml index 91f315dd2..47cca8634 100644 --- a/app/views/photos/_likes.html.haml +++ b/app/views/photos/_likes.html.haml @@ -1,15 +1,13 @@ - - if member_signed_in? - if can?(:new, Like) && !photo.liked_by?(current_member) - = link_to 'Like', likes_path(photo_id: photo.id, format: :json), - method: :post, remote: true, class: 'photo-like btn like-btn' + = link_to likes_path(photo_id: photo.id, format: :json), + method: :post, remote: true, class: 'photo-like like-btn' do + = render 'likes/count', likeable: photo - else - like = photo.likes.find_by(member: current_member) - if like && can?(:destroy, like) - = link_to 'Unlike', like_path(id: like.id, format: :json), - method: :delete, remote: true, class: 'photo-like btn like-btn' - -%span.badge.like-badge{class: (photo.liked_by?(current_member)) ? 'liked' : ''} - = like_icon -   - %span.like-count= photo.likes.count + = link_to like_path(id: like.id, format: :json), + method: :delete, remote: true, class: 'photo-like like-btn' do + = render 'likes/count', likeable: photo +- else + = render 'likes/count', likeable: photo \ No newline at end of file diff --git a/app/views/photos/show.html.haml b/app/views/photos/show.html.haml index fb4e17cc2..ea309fe42 100644 --- a/app/views/photos/show.html.haml +++ b/app/views/photos/show.html.haml @@ -18,11 +18,11 @@ = image_tag(@photo.fullsize_url, alt: @photo.title, class: 'rounded img-fluid shadow-sm') .col-md-4 - %p.text-center{ id: "photo-#{@photo.id}" } + %p = render 'photos/actions', photo: @photo = link_to "View on Flickr", @photo.link_url, class: 'btn' + %span.btn= render 'photos/likes', photo: @photo - = render 'photos/likes', photo: @photo - if @crops.size.positive? .index-cards diff --git a/app/views/posts/_likes.html.haml b/app/views/posts/_likes.html.haml index c936bbd20..1c59e88ad 100644 --- a/app/views/posts/_likes.html.haml +++ b/app/views/posts/_likes.html.haml @@ -9,7 +9,8 @@ = link_to 'Unlike', like_path(id: like.id, format: :json), method: :delete, remote: true, class: 'post-like btn' -%span.badge.like-badge{class: (post.liked_by?(current_member)) ? 'liked' : ''} - = like_icon -   - %span.like-count= post.likes.count += render 'likes/count', likeable: post +-# %span.badge.like-badge{class: (post.liked_by?(current_member)) ? 'liked' : ''} +-# = like_icon +-#   +-# %span.like-count= post.likes.count From a7acaea03dc5ebfc5fbb4b6097389a7bdb65baa4 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Fri, 12 Jul 2019 10:47:48 +1200 Subject: [PATCH 37/66] Update posts liking spec to find where the count moved to --- spec/features/likeable_spec.rb | 46 +++++++++++++++++----------------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/spec/features/likeable_spec.rb b/spec/features/likeable_spec.rb index 0a39154b0..ae76040c4 100644 --- a/spec/features/likeable_spec.rb +++ b/spec/features/likeable_spec.rb @@ -6,35 +6,35 @@ describe 'Likeable', js: true do let(:post) { FactoryBot.create(:post) } context 'logged in member' do - before do - login_as member - visit post_path(post) - end + before { login_as member } - it 'can be liked' do - expect(page).to have_link 'Like' - click_link 'Like' - expect(page).to have_content '1 like' + describe 'posts' do + before { visit post_path(post) } + it 'can be liked' do + expect(page).to have_link 'Like' + click_link 'Like' + expect(page).to have_css(".like-count", text: "1") - visit post_path(post) + visit post_path(post) - expect(page).to have_link 'Unlike' - click_link 'Unlike' - expect(page).to have_content '0 likes' - end + expect(page).to have_link 'Unlike' + click_link 'Unlike' + expect(page).to have_css(".like-count", text: "0") + end - it 'displays correct number of likes' do - expect(page).to have_link 'Like' - click_link 'Like' - expect(page).to have_content '1 like' - logout(member) + it 'displays correct number of likes' do + expect(page).to have_link 'Like' + click_link 'Like' + expect(page).to have_css(".like-count", text: "1") - login_as(another_member) - visit post_path(post) + logout(member) + login_as(another_member) + visit post_path(post) - expect(page).to have_link 'Like' - click_link 'Like' - expect(page).to have_content '2 likes' + expect(page).to have_link 'Like' + click_link 'Like' + expect(page).to have_css(".like-count", text: "2") + end end end end From c9f9315d8deb575d514058c1ae80257185f50bfd Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Fri, 12 Jul 2019 11:29:47 +1200 Subject: [PATCH 38/66] specs for liking photos from photos#show --- app/views/posts/_likes.html.haml | 8 +--- spec/features/likeable_spec.rb | 64 ++++++++++++++++++++++++++++---- 2 files changed, 58 insertions(+), 14 deletions(-) diff --git a/app/views/posts/_likes.html.haml b/app/views/posts/_likes.html.haml index 1c59e88ad..18112c308 100644 --- a/app/views/posts/_likes.html.haml +++ b/app/views/posts/_likes.html.haml @@ -2,15 +2,11 @@ - if member_signed_in? - if can?(:new, Like) && !post.liked_by?(current_member) = link_to 'Like', likes_path(post_id: post.id, format: :json), - method: :post, remote: true, class: 'post-like btn' + method: :post, remote: true, class: 'post-like btn like-btn' - else - like = post.likes.find_by(member: current_member) - if like && can?(:destroy, like) = link_to 'Unlike', like_path(id: like.id, format: :json), - method: :delete, remote: true, class: 'post-like btn' + method: :delete, remote: true, class: 'post-like btn like-btn' = render 'likes/count', likeable: post --# %span.badge.like-badge{class: (post.liked_by?(current_member)) ? 'liked' : ''} --# = like_icon --#   --# %span.like-count= post.likes.count diff --git a/spec/features/likeable_spec.rb b/spec/features/likeable_spec.rb index ae76040c4..b33858798 100644 --- a/spec/features/likeable_spec.rb +++ b/spec/features/likeable_spec.rb @@ -1,30 +1,78 @@ require 'rails_helper' describe 'Likeable', js: true do - let(:member) { FactoryBot.create(:member) } - let(:another_member) { FactoryBot.create(:london_member) } - let(:post) { FactoryBot.create(:post) } + let(:member) { FactoryBot.create(:member) } + let(:another_member) { FactoryBot.create(:london_member) } + let(:post) { FactoryBot.create(:post, author: member) } + let(:photo) { FactoryBot.create(:photo, owner: member) } context 'logged in member' do before { login_as member } + describe 'photos' do + let(:like_count_class) { "#photo-#{photo.id} .like-count" } + + shared_examples 'photo can be liked' do + it 'can be liked' do + visit path + expect(page).to have_css(like_count_class, text: "0") + click_link '0' + expect(page).to have_css(like_count_class, text: "1") + + # Reload page + visit path + expect(page).to have_css(like_count_class, text: "1") + expect(page).to have_link '1' + + click_link '1' + expect(page).to have_css(like_count_class, text: "0") + end + + it 'displays correct number of likes' do + visit path + expect(page).to have_css(like_count_class, text: "0") + expect(page).to have_link '0' + click_link '0' + expect(page).to have_css(like_count_class, text: "1") + + logout(member) + login_as(another_member) + visit path + + expect(page).to have_css(like_count_class, text: "1") + click_link '1' + expect(page).to have_css(like_count_class, text: "2") + end + end + + describe 'photos#show' do + let(:path) { photo_path(photo) } + include_examples 'photo can be liked' + end + + end + describe 'posts' do + let(:like_count_class) { "#post-#{post.id} .like-count" } before { visit post_path(post) } it 'can be liked' do + expect(page).to have_css(".like-count", text: "0") expect(page).to have_link 'Like' - click_link 'Like' + click_link 'Like', class: 'like-btn' expect(page).to have_css(".like-count", text: "1") + # Reload page visit post_path(post) - + expect(page).to have_css(".like-count", text: "1") expect(page).to have_link 'Unlike' - click_link 'Unlike' + + click_link 'Unlike', class: 'like-btn' expect(page).to have_css(".like-count", text: "0") end it 'displays correct number of likes' do expect(page).to have_link 'Like' - click_link 'Like' + click_link 'Like', class: 'like-btn' expect(page).to have_css(".like-count", text: "1") logout(member) @@ -32,7 +80,7 @@ describe 'Likeable', js: true do visit post_path(post) expect(page).to have_link 'Like' - click_link 'Like' + click_link 'Like', class: 'like-btn' expect(page).to have_css(".like-count", text: "2") end end From 013860ba5a123434a9056246b77f6c8a4b4e8c8e Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Fri, 12 Jul 2019 11:55:43 +1200 Subject: [PATCH 39/66] specs for liking photos from crops#show and photos#index --- spec/features/likeable_spec.rb | 45 ++++++++++++++++++++-------------- 1 file changed, 27 insertions(+), 18 deletions(-) diff --git a/spec/features/likeable_spec.rb b/spec/features/likeable_spec.rb index b33858798..42aa03c6b 100644 --- a/spec/features/likeable_spec.rb +++ b/spec/features/likeable_spec.rb @@ -1,22 +1,22 @@ require 'rails_helper' describe 'Likeable', js: true do - let(:member) { FactoryBot.create(:member) } - let(:another_member) { FactoryBot.create(:london_member) } - let(:post) { FactoryBot.create(:post, author: member) } - let(:photo) { FactoryBot.create(:photo, owner: member) } + let(:member) { FactoryBot.create(:member) } + let(:another_member) { FactoryBot.create(:london_member) } + let!(:post) { FactoryBot.create(:post, author: member) } + let!(:photo) { FactoryBot.create(:photo, owner: member) } context 'logged in member' do before { login_as member } describe 'photos' do - let(:like_count_class) { "#photo-#{photo.id} .like-count" } + let(:like_count_class) { "#photo-#{photo.id} .like-count" } shared_examples 'photo can be liked' do it 'can be liked' do visit path expect(page).to have_css(like_count_class, text: "0") - click_link '0' + click_link '0', class: 'like-btn' expect(page).to have_css(like_count_class, text: "1") # Reload page @@ -24,7 +24,7 @@ describe 'Likeable', js: true do expect(page).to have_css(like_count_class, text: "1") expect(page).to have_link '1' - click_link '1' + click_link '1', class: 'like-btn' expect(page).to have_css(like_count_class, text: "0") end @@ -32,7 +32,7 @@ describe 'Likeable', js: true do visit path expect(page).to have_css(like_count_class, text: "0") expect(page).to have_link '0' - click_link '0' + click_link '0', class: 'like-btn' expect(page).to have_css(like_count_class, text: "1") logout(member) @@ -40,40 +40,49 @@ describe 'Likeable', js: true do visit path expect(page).to have_css(like_count_class, text: "1") - click_link '1' + click_link '1', class: 'like-btn' expect(page).to have_css(like_count_class, text: "2") end end - + describe 'photos#index' do + let(:path) { photos_path } + include_examples 'photo can be liked' + end describe 'photos#show' do let(:path) { photo_path(photo) } include_examples 'photo can be liked' end - + describe 'crops#show' do + let(:crop) { FactoryBot.create :crop } + let(:planting) { FactoryBot.create :planting, owner: member, crop: crop } + let(:path) { crop_path(crop) } + before { planting.photos << photo } + include_examples 'photo can be liked' + end end describe 'posts' do - let(:like_count_class) { "#post-#{post.id} .like-count" } + let(:like_count_class) { "#post-#{post.id} .like-count" } before { visit post_path(post) } it 'can be liked' do - expect(page).to have_css(".like-count", text: "0") + expect(page).to have_css(like_count_class, text: "0") expect(page).to have_link 'Like' click_link 'Like', class: 'like-btn' - expect(page).to have_css(".like-count", text: "1") + expect(page).to have_css(like_count_class, text: "1") # Reload page visit post_path(post) - expect(page).to have_css(".like-count", text: "1") + expect(page).to have_css(like_count_class, text: "1") expect(page).to have_link 'Unlike' click_link 'Unlike', class: 'like-btn' - expect(page).to have_css(".like-count", text: "0") + expect(page).to have_css(like_count_class, text: "0") end it 'displays correct number of likes' do expect(page).to have_link 'Like' click_link 'Like', class: 'like-btn' - expect(page).to have_css(".like-count", text: "1") + expect(page).to have_css(like_count_class, text: "1") logout(member) login_as(another_member) @@ -81,7 +90,7 @@ describe 'Likeable', js: true do expect(page).to have_link 'Like' click_link 'Like', class: 'like-btn' - expect(page).to have_css(".like-count", text: "2") + expect(page).to have_css(like_count_class, text: "2") end end end From 80ee3eb8f13e507d814eed79d2bf2583ea30e45b Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Fri, 12 Jul 2019 11:59:24 +1200 Subject: [PATCH 40/66] Newline at end of file --- app/assets/stylesheets/_likes.scss | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/assets/stylesheets/_likes.scss b/app/assets/stylesheets/_likes.scss index 8e837f409..abe56f495 100644 --- a/app/assets/stylesheets/_likes.scss +++ b/app/assets/stylesheets/_likes.scss @@ -4,4 +4,4 @@ .like-btn { color: $brown -} \ No newline at end of file +} From 1b87026df4716bb114cbf00aef4023d9ca319b93 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Fri, 12 Jul 2019 11:59:48 +1200 Subject: [PATCH 41/66] Use camel case in js --- app/assets/javascripts/likes.js | 36 ++++++++++++++++----------------- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/app/assets/javascripts/likes.js b/app/assets/javascripts/likes.js index 2cd95dc54..60b3e57e7 100644 --- a/app/assets/javascripts/likes.js +++ b/app/assets/javascripts/likes.js @@ -2,39 +2,39 @@ $(document).ready(function() { $('.like-btn').show(); $('.post-like').on('ajax:success', function(event, data) { - var like_button = $('#post-' + data.id + ' .post-like'); - var like_badge = $('#post-'+ data.id + ' .like-badge'); + var likeButton = $('#post-' + data.id + ' .post-like'); + var likeBadge = $('#post-'+ data.id + ' .like-badge'); $('#post-' + data.id + ' .like-count').text(data.like_count); if (data.liked_by_member) { - like_badge.addClass('liked'); - like_button.data('method', 'delete'); - like_button.attr('href', data.url); - like_button.text('Unlike'); + likeBadge.addClass('liked'); + likeButton.data('method', 'delete'); + likeButton.attr('href', data.url); + likeButton.text('Unlike'); } else { - like_badge.removeClass('liked'); - like_button.data('method', 'post'); - like_button.attr('href', '/likes.json?post_id=' + data.id); - like_button.text('Like'); + likeBadge.removeClass('liked'); + likeButton.data('method', 'post'); + likeButton.attr('href', '/likes.json?post_id=' + data.id); + likeButton.text('Like'); } }); $('.photo-like').on('ajax:success', function(event, data) { - var like_badge = $('#photo-'+ data.id + ' .like-badge'); - var like_button = $('#photo-'+ data.id + ' .like-btn'); + var likeBadge = $('#photo-'+ data.id + ' .like-badge'); + var likeButton = $('#photo-'+ data.id + ' .like-btn'); $('#photo-' + data.id + ' .like-count').text(data.like_count); if (data.liked_by_member) { - like_badge.addClass('liked'); + likeBadge.addClass('liked'); // Turn the button into an unlike button - like_button.data('method', 'delete'); - like_button.attr('href', data.url); + likeButton.data('method', 'delete'); + likeButton.attr('href', data.url); } else { - like_badge.removeClass('liked'); + likeBadge.removeClass('liked'); // Turn the button into an *like* button - like_button.data('method', 'post'); - like_button.attr('href', '/likes.json?photo_id=' + data.id); + likeButton.data('method', 'post'); + likeButton.attr('href', '/likes.json?photo_id=' + data.id); } }); }); From 6816fb90721dfafc1f931665a6ce7c65e451f7c7 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Fri, 12 Jul 2019 12:01:26 +1200 Subject: [PATCH 42/66] Added missing semicolon in scss --- app/assets/stylesheets/_likes.scss | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/assets/stylesheets/_likes.scss b/app/assets/stylesheets/_likes.scss index abe56f495..39bad5408 100644 --- a/app/assets/stylesheets/_likes.scss +++ b/app/assets/stylesheets/_likes.scss @@ -3,5 +3,5 @@ } .like-btn { - color: $brown + color: $brown; } From 3a746e775577dca1f584a965213fd93029c1855f Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Fri, 12 Jul 2019 09:30:15 +0000 Subject: [PATCH 43/66] Bump font-awesome-sass from 5.8.1 to 5.9.0 Bumps [font-awesome-sass](https://github.com/FortAwesome/font-awesome-sass) from 5.8.1 to 5.9.0. - [Release notes](https://github.com/FortAwesome/font-awesome-sass/releases) - [Commits](https://github.com/FortAwesome/font-awesome-sass/compare/5.8.1...5.9.0) Signed-off-by: dependabot-preview[bot] --- Gemfile.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile.lock b/Gemfile.lock index ffaf233b4..de1f534fe 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -177,7 +177,7 @@ GEM figaro (1.1.1) thor (~> 0.14) flickraw (0.9.10) - font-awesome-sass (5.8.1) + font-awesome-sass (5.9.0) sassc (>= 1.11) friendly_id (5.2.5) activerecord (>= 4.0.0) From 117d066917baee3023830b9bd9ae401e2c1f6b9d Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Fri, 12 Jul 2019 11:32:47 +0000 Subject: [PATCH 44/66] Bump puma from 4.0.0 to 4.0.1 Bumps [puma](https://github.com/puma/puma) from 4.0.0 to 4.0.1. - [Release notes](https://github.com/puma/puma/releases) - [Changelog](https://github.com/puma/puma/blob/master/History.md) - [Commits](https://github.com/puma/puma/compare/v4.0.0...v4.0.1) Signed-off-by: dependabot-preview[bot] --- Gemfile.lock | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index de1f534fe..2e91c8770 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -305,7 +305,7 @@ GEM multi_xml (0.6.0) multipart-post (2.1.1) newrelic_rpm (6.5.0.357) - nio4r (2.3.1) + nio4r (2.4.0) nokogiri (1.10.3) mini_portile2 (~> 2.4.0) oauth (0.5.4) @@ -346,7 +346,7 @@ GEM moneta (~> 1.0.0) popper_js (1.14.5) public_suffix (3.1.1) - puma (4.0.0) + puma (4.0.1) nio4r (~> 2.0) rack (2.0.7) rack-protection (2.0.5) From e0e10c29dc357f83527e148595bbb0b9e83318fc Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Thu, 11 Jul 2019 12:08:15 +1200 Subject: [PATCH 45/66] Renaming photographings to photo associations now it matches the name of its controller, and it is clearer to understand --- app/controllers/photo_associations_controller.rb | 2 +- app/controllers/photos_controller.rb | 2 +- app/models/concerns/photo_capable.rb | 4 ++-- app/models/crop.rb | 4 ++-- app/models/photo.rb | 12 ++++++------ .../{photographing.rb => photo_association.rb} | 4 ++-- app/views/photos/_association_delete_button.haml | 2 +- config/routes.rb | 2 +- .../20190130090437_add_crop_to_photographings.rb | 5 +++++ db/migrate/20190712234859_rename_photographings.rb | 5 +++++ db/schema.rb | 8 ++++---- 11 files changed, 30 insertions(+), 20 deletions(-) rename app/models/{photographing.rb => photo_association.rb} (88%) create mode 100644 db/migrate/20190712234859_rename_photographings.rb diff --git a/app/controllers/photo_associations_controller.rb b/app/controllers/photo_associations_controller.rb index 743966d5d..499dbefc0 100644 --- a/app/controllers/photo_associations_controller.rb +++ b/app/controllers/photo_associations_controller.rb @@ -6,7 +6,7 @@ class PhotoAssociationsController < ApplicationController raise "Photos not supported" unless Photo::PHOTO_CAPABLE.include? item_class @photo = Photo.find_by!(id: params[:photo_id], owner: current_member) - @item = Photographing.item(item_id, item_class) + @item = PhotoAssociation.item(item_id, item_class) @item.photos.delete(@photo) # @photo.destroy_if_unused respond_with(@photo) diff --git a/app/controllers/photos_controller.rb b/app/controllers/photos_controller.rb index a38dc6130..fe3f84d02 100644 --- a/app/controllers/photos_controller.rb +++ b/app/controllers/photos_controller.rb @@ -6,7 +6,7 @@ class PhotosController < ApplicationController responders :flash def show - @crops = Crop.distinct.joins(:photographings).where(photographings: { photo: @photo }) + @crops = Crop.distinct.joins(:photo_associations).where(photo_associations: { photo: @photo }) respond_with(@photo) end diff --git a/app/models/concerns/photo_capable.rb b/app/models/concerns/photo_capable.rb index 3ae7303d9..e9131cbf6 100644 --- a/app/models/concerns/photo_capable.rb +++ b/app/models/concerns/photo_capable.rb @@ -2,8 +2,8 @@ module PhotoCapable extend ActiveSupport::Concern included do - has_many :photographings, as: :photographable, dependent: :destroy, inverse_of: :photographable - has_many :photos, through: :photographings, as: :photographable + has_many :photo_associations, as: :photographable, dependent: :destroy, inverse_of: :photographable + has_many :photos, through: :photo_associations, as: :photographable scope :has_photos, -> { includes(:photos).where.not(photos: { id: nil }) } end diff --git a/app/models/crop.rb b/app/models/crop.rb index 4e56d4645..adcec8a5c 100644 --- a/app/models/crop.rb +++ b/app/models/crop.rb @@ -14,8 +14,8 @@ class Crop < ApplicationRecord has_many :plantings, dependent: :destroy has_many :seeds, dependent: :destroy has_many :harvests, dependent: :destroy - has_many :photographings, dependent: :destroy - has_many :photos, through: :photographings + has_many :photo_associations, dependent: :destroy + has_many :photos, through: :photo_associations has_many :plant_parts, -> { distinct.order("plant_parts.name") }, through: :harvests belongs_to :creator, class_name: 'Member', optional: true, inverse_of: :created_crops belongs_to :requester, class_name: 'Member', optional: true, inverse_of: :requested_crops diff --git a/app/models/photo.rb b/app/models/photo.rb index cf9877ebb..de44ebbbd 100644 --- a/app/models/photo.rb +++ b/app/models/photo.rb @@ -4,21 +4,21 @@ class Photo < ApplicationRecord PHOTO_CAPABLE = %w(Garden Planting Harvest Seed Post).freeze - has_many :photographings, foreign_key: :photo_id, dependent: :destroy, inverse_of: :photo - has_many :crops, through: :photographings + has_many :photo_associations, foreign_key: :photo_id, dependent: :destroy, inverse_of: :photo + has_many :crops, through: :photo_associations # creates a relationship for each assignee type PHOTO_CAPABLE.each do |type| has_many type.downcase.pluralize.to_s.to_sym, - through: :photographings, + through: :photo_associations, source: :photographable, source_type: type end default_scope { joins(:owner) } # Ensures the owner still exists - scope :by_crop, ->(crop) { joins(:photographings).where(photographings: { crop: crop }) } + scope :by_crop, ->(crop) { joins(:photo_associations).where(photo_associations: { crop: crop }) } scope :by_model, lambda { |model_name| - joins(:photographings).where(photographings: { photographable_type: model_name.to_s }) + joins(:photo_associations).where(photo_associations: { photographable_type: model_name.to_s }) } # This is split into a side-effect free method and a side-effecting method @@ -40,7 +40,7 @@ class Photo < ApplicationRecord end def associations? - photographings.size.positive? + photo_associations.size.positive? end def destroy_if_unused diff --git a/app/models/photographing.rb b/app/models/photo_association.rb similarity index 88% rename from app/models/photographing.rb rename to app/models/photo_association.rb index 2693725a2..24eb79e80 100644 --- a/app/models/photographing.rb +++ b/app/models/photo_association.rb @@ -1,5 +1,5 @@ -class Photographing < ApplicationRecord - belongs_to :photo, inverse_of: :photographings +class PhotoAssociation < ApplicationRecord + belongs_to :photo, inverse_of: :photo_associations belongs_to :photographable, polymorphic: true belongs_to :crop, optional: true diff --git a/app/views/photos/_association_delete_button.haml b/app/views/photos/_association_delete_button.haml index 1a0f0510f..f4144dd48 100644 --- a/app/views/photos/_association_delete_button.haml +++ b/app/views/photos/_association_delete_button.haml @@ -1,5 +1,5 @@ - if can? :edit, photo - = link_to photo_associations_path(photo_id: photo.id, type: type, id: thing.id), + = link_to photo_association_path(photo_id: photo.id, type: type, id: thing.id), data: { confirm: "Removing photo from this #{type}. Are you sure?" }, method: 'delete', class: 'text-warning btn-sm' do = delete_association_icon diff --git a/config/routes.rb b/config/routes.rb index aa93d3c5d..28b892018 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -54,7 +54,7 @@ Rails.application.routes.draw do resources :plant_parts resources :photos - delete 'photo_associations' => 'photo_associations#destroy' + resources :photo_associations, only: :destroy resources :crops, param: :slug, concerns: :has_photos do get 'gardens' => 'gardens#index' diff --git a/db/migrate/20190130090437_add_crop_to_photographings.rb b/db/migrate/20190130090437_add_crop_to_photographings.rb index 2ff0596f0..3b4ad8788 100644 --- a/db/migrate/20190130090437_add_crop_to_photographings.rb +++ b/db/migrate/20190130090437_add_crop_to_photographings.rb @@ -7,4 +7,9 @@ class AddCropToPhotographings < ActiveRecord::Migration[5.2] p.set_crop && p.save! end end + class Photographing < ApplicationRecord + belongs_to :photo, inverse_of: :photo_associations + belongs_to :photographable, polymorphic: true + belongs_to :crop, optional: true + end end diff --git a/db/migrate/20190712234859_rename_photographings.rb b/db/migrate/20190712234859_rename_photographings.rb new file mode 100644 index 000000000..7f9a5127e --- /dev/null +++ b/db/migrate/20190712234859_rename_photographings.rb @@ -0,0 +1,5 @@ +class RenamePhotographings < ActiveRecord::Migration[5.2] + def change + rename_table :photographings, :photo_associations + end +end diff --git a/db/schema.rb b/db/schema.rb index d6cb3cbf4..aaf3d4690 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 2019_03_26_224347) do +ActiveRecord::Schema.define(version: 2019_07_12_234859) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -339,7 +339,7 @@ ActiveRecord::Schema.define(version: 2019_03_26_224347) do t.integer "product_id" end - create_table "photographings", id: :serial, force: :cascade do |t| + create_table "photo_associations", id: :serial, force: :cascade do |t| t.integer "photo_id", null: false t.integer "photographable_id", null: false t.string "photographable_type", null: false @@ -455,8 +455,8 @@ ActiveRecord::Schema.define(version: 2019_03_26_224347) do end add_foreign_key "harvests", "plantings" - add_foreign_key "photographings", "crops" - add_foreign_key "photographings", "photos" + add_foreign_key "photo_associations", "crops" + add_foreign_key "photo_associations", "photos" add_foreign_key "plantings", "seeds", column: "parent_seed_id", name: "parent_seed", on_delete: :nullify add_foreign_key "seeds", "plantings", column: "parent_planting_id", name: "parent_planting", on_delete: :nullify end From 485b637e042daa47fec950c7b9ca9ba4a4416b07 Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Mon, 15 Jul 2019 08:52:06 +0000 Subject: [PATCH 46/66] Bump rubocop-rails from 2.2.0 to 2.2.1 Bumps [rubocop-rails](https://github.com/rubocop-hq/rubocop-rails) from 2.2.0 to 2.2.1. - [Release notes](https://github.com/rubocop-hq/rubocop-rails/releases) - [Changelog](https://github.com/rubocop-hq/rubocop-rails/blob/master/CHANGELOG.md) - [Commits](https://github.com/rubocop-hq/rubocop-rails/compare/v2.2.0...v2.2.1) Signed-off-by: dependabot-preview[bot] --- Gemfile.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile.lock b/Gemfile.lock index 2e91c8770..54846ef7d 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -431,7 +431,7 @@ GEM rainbow (>= 2.2.2, < 4.0) ruby-progressbar (~> 1.7) unicode-display_width (>= 1.4.0, < 1.7) - rubocop-rails (2.2.0) + rubocop-rails (2.2.1) rack (>= 1.1) rubocop (>= 0.72.0) rubocop-rspec (1.33.0) From d4cfcb37baf92908a19c4e54049b3b724420f6ad Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Thu, 11 Jul 2019 12:08:15 +1200 Subject: [PATCH 47/66] more percy specs --- spec/features/members/deletion_spec.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/spec/features/members/deletion_spec.rb b/spec/features/members/deletion_spec.rb index 7a5ccf273..9d51ef6b1 100644 --- a/spec/features/members/deletion_spec.rb +++ b/spec/features/members/deletion_spec.rb @@ -81,6 +81,7 @@ describe "member deletion" do visit member_path(member) click_link 'Edit profile' click_link 'Delete Account' + Percy.snapshot(page, name: 'Account deletion') fill_in "current_pw_for_delete", with: "password1", match: :prefer_exact click_button "Delete" logout From 9413d86b055efa4f1841e73cb7e48247b5931087 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Thu, 11 Jul 2019 12:14:54 +1200 Subject: [PATCH 48/66] fixes percy error, running same snapshot more than once --- spec/features/members/deletion_spec.rb | 1 - 1 file changed, 1 deletion(-) diff --git a/spec/features/members/deletion_spec.rb b/spec/features/members/deletion_spec.rb index 9d51ef6b1..7a5ccf273 100644 --- a/spec/features/members/deletion_spec.rb +++ b/spec/features/members/deletion_spec.rb @@ -81,7 +81,6 @@ describe "member deletion" do visit member_path(member) click_link 'Edit profile' click_link 'Delete Account' - Percy.snapshot(page, name: 'Account deletion') fill_in "current_pw_for_delete", with: "password1", match: :prefer_exact click_button "Delete" logout From acf58fc5e280755a99ea4b6494ae5554862e3c5f Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Fri, 12 Jul 2019 13:08:23 +1200 Subject: [PATCH 49/66] Choose crop photos by most liked --- app/models/concerns/likeable.rb | 2 +- app/models/crop.rb | 6 ++-- app/models/like.rb | 2 +- app/views/crops/_photos.html.haml | 2 +- app/views/likes/_count.haml | 2 +- app/views/photos/_card.html.haml | 1 - .../20190712003735_add_like_counter_caches.rb | 34 +++++++++++++++++++ db/schema.rb | 4 ++- 8 files changed, 44 insertions(+), 9 deletions(-) create mode 100644 db/migrate/20190712003735_add_like_counter_caches.rb diff --git a/app/models/concerns/likeable.rb b/app/models/concerns/likeable.rb index 4937af53e..4760a8f14 100644 --- a/app/models/concerns/likeable.rb +++ b/app/models/concerns/likeable.rb @@ -2,7 +2,7 @@ module Likeable extend ActiveSupport::Concern included do - has_many :likes, as: :likeable, inverse_of: :likeable, dependent: :destroy + has_many :likes, as: :likeable, inverse_of: :likeable, dependent: :destroy, counter_cache: true has_many :members, through: :likes end diff --git a/app/models/crop.rb b/app/models/crop.rb index 4e56d4645..86159d7c4 100644 --- a/app/models/crop.rb +++ b/app/models/crop.rb @@ -85,7 +85,7 @@ class Crop < ApplicationRecord # later we can choose a default photo based on different criteria, # eg. popularity def default_photo - first_photo(:plantings) || first_photo(:harvests) || first_photo(:seeds) + most_liked_photo end # returns hash indicating whether this crop is grown in @@ -213,7 +213,7 @@ class Crop < ApplicationRecord errors.add(:rejection_notes, "must be added if the reason for rejection is \"other\"") end - def first_photo(type) - Photo.joins(type).where("#{type}": { crop_id: id }).order("photos.created_at DESC").first + def most_liked_photo + photos.order(likes_count: :desc, created_at: :desc).first end end diff --git a/app/models/like.rb b/app/models/like.rb index 05911fc95..f74903739 100644 --- a/app/models/like.rb +++ b/app/models/like.rb @@ -1,6 +1,6 @@ class Like < ApplicationRecord belongs_to :member - belongs_to :likeable, polymorphic: true + belongs_to :likeable, polymorphic: true, counter_cache: true validates :member, :likeable, presence: true validates :member, uniqueness: { scope: :likeable } end diff --git a/app/views/crops/_photos.html.haml b/app/views/crops/_photos.html.haml index 170867ed8..71358d541 100644 --- a/app/views/crops/_photos.html.haml +++ b/app/views/crops/_photos.html.haml @@ -3,7 +3,7 @@ - [Planting, Harvest, Seed].each do |model_name| - if photos.by_model(model_name).size.positive? %h3 #{@crop.name.capitalize} #{t("activerecord.models.#{model_name.to_s.downcase}.other")} - = render 'photos/gallery', photos: photos.by_model(model_name).limit(8) + = render 'photos/gallery', photos: photos.by_model(model_name).order(likes_count: :desc).limit(8) = link_to 'more photos ยป', crop_photos_path(@crop), class: 'btn' %hr/ diff --git a/app/views/likes/_count.haml b/app/views/likes/_count.haml index 56f72e7e7..79fece151 100644 --- a/app/views/likes/_count.haml +++ b/app/views/likes/_count.haml @@ -1,4 +1,4 @@ %span.badge.like-badge{class: (likeable.liked_by?(current_member)) ? 'liked' : ''} = like_icon   - %span.like-count= likeable.likes.count + %span.like-count= likeable.likes_count diff --git a/app/views/photos/_card.html.haml b/app/views/photos/_card.html.haml index 46afcbf7b..0d17281f5 100644 --- a/app/views/photos/_card.html.haml +++ b/app/views/photos/_card.html.haml @@ -8,4 +8,3 @@ %time{datetime: photo.date_taken} = I18n.l(photo.date_taken.to_date) = render 'photos/likes', photo: photo - diff --git a/db/migrate/20190712003735_add_like_counter_caches.rb b/db/migrate/20190712003735_add_like_counter_caches.rb new file mode 100644 index 000000000..92c292494 --- /dev/null +++ b/db/migrate/20190712003735_add_like_counter_caches.rb @@ -0,0 +1,34 @@ +class AddLikeCounterCaches < ActiveRecord::Migration[5.2] + def change + change_table :photos do |t| + t.integer :likes_count, default: 0 + end + change_table :posts do |t| + t.integer :likes_count, default: 0 + end + reversible do |dir| + dir.up { data } + end + end + + def data + execute <<-SQL.squish + UPDATE photos + SET likes_count = ( + SELECT count(1) + FROM likes + WHERE likes.likeable_id = photos.id + AND likeable_type = 'Photo' + ) + SQL + execute <<-SQL.squish + UPDATE posts + SET likes_count = ( + SELECT count(1) + FROM likes + WHERE likes.likeable_id = posts.id + AND likeable_type = 'Post' + ) + SQL + end +end diff --git a/db/schema.rb b/db/schema.rb index d6cb3cbf4..6bbc72242 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 2019_03_26_224347) do +ActiveRecord::Schema.define(version: 2019_07_12_003735) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -362,6 +362,7 @@ ActiveRecord::Schema.define(version: 2019_03_26_224347) do t.string "link_url", null: false t.string "flickr_photo_id" t.datetime "date_taken" + t.integer "likes_count", default: 0 end create_table "photos_plantings", id: false, force: :cascade do |t| @@ -412,6 +413,7 @@ ActiveRecord::Schema.define(version: 2019_03_26_224347) do t.datetime "updated_at" t.string "slug" t.integer "forum_id" + t.integer "likes_count", default: 0 t.index ["created_at", "author_id"], name: "index_posts_on_created_at_and_author_id" t.index ["slug"], name: "index_posts_on_slug", unique: true end From e5e54d651b6d51be7676fe00b4ebd293ec7bb32c Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Fri, 12 Jul 2019 13:18:18 +1200 Subject: [PATCH 50/66] Remove duplicate and unused photo methods --- app/models/concerns/photo_capable.rb | 8 ++++++++ app/models/crop.rb | 26 ++------------------------ app/models/harvest.rb | 4 ---- app/models/planting.rb | 4 ---- app/models/seed.rb | 4 ---- 5 files changed, 10 insertions(+), 36 deletions(-) diff --git a/app/models/concerns/photo_capable.rb b/app/models/concerns/photo_capable.rb index 3ae7303d9..c944d06a5 100644 --- a/app/models/concerns/photo_capable.rb +++ b/app/models/concerns/photo_capable.rb @@ -6,5 +6,13 @@ module PhotoCapable has_many :photos, through: :photographings, as: :photographable scope :has_photos, -> { includes(:photos).where.not(photos: { id: nil }) } + + def default_photo + most_liked_photo + end + + def most_liked_photo + photos.order(likes_count: :desc, created_at: :desc).first + end end end diff --git a/app/models/crop.rb b/app/models/crop.rb index 86159d7c4..2c8f372b4 100644 --- a/app/models/crop.rb +++ b/app/models/crop.rb @@ -1,5 +1,6 @@ class Crop < ApplicationRecord extend FriendlyId + include PhotoCapable friendly_id :name, use: %i(slugged finders) ## @@ -57,18 +58,6 @@ class Crop < ApplicationRecord # Elastic search configuration searchkick word_start: %i(name alternate_names scientific_names), case_sensitive: false if ENV["GROWSTUFF_ELASTICSEARCH"] == "true" - def planting_photos - Photo.joins(:plantings).where("plantings.crop_id": id) - end - - def harvest_photos - Photo.joins(:harvests).where("harvests.crop_id": id) - end - - def seed_photos - Photo.joins(:seeds).where("seeds.crop_id": id) - end - def to_s name end @@ -78,14 +67,7 @@ class Crop < ApplicationRecord end def default_scientific_name - scientific_names.first.name unless scientific_names.empty? - end - - # currently returns the first available photo, but exists so that - # later we can choose a default photo based on different criteria, - # eg. popularity - def default_photo - most_liked_photo + scientific_names.first&.name end # returns hash indicating whether this crop is grown in @@ -212,8 +194,4 @@ class Crop < ApplicationRecord errors.add(:rejection_notes, "must be added if the reason for rejection is \"other\"") end - - def most_liked_photo - photos.order(likes_count: :desc, created_at: :desc).first - end end diff --git a/app/models/harvest.rb b/app/models/harvest.rb index a913ec8b9..2b24e2fa7 100644 --- a/app/models/harvest.rb +++ b/app/models/harvest.rb @@ -135,10 +135,6 @@ class Harvest < ApplicationRecord end.to_s end - def default_photo - photos.order(created_at: :desc).first || crop.default_photo - end - private def crop_must_match_planting diff --git a/app/models/planting.rb b/app/models/planting.rb index e57bf6fb0..67bdd281d 100644 --- a/app/models/planting.rb +++ b/app/models/planting.rb @@ -85,10 +85,6 @@ class Planting < ApplicationRecord I18n.t('plantings.string', crop: crop.name, garden: garden.name, owner: owner) end - def default_photo - photos.order(created_at: :desc).first - end - def finished? finished || (finished_at.present? && finished_at <= Time.zone.today) end diff --git a/app/models/seed.rb b/app/models/seed.rb index 8025f66e2..b335127c0 100644 --- a/app/models/seed.rb +++ b/app/models/seed.rb @@ -55,10 +55,6 @@ class Seed < ApplicationRecord scope :recent, -> { order(created_at: :desc) } scope :active, -> { where('finished_at < ?', Time.zone.now) } - def default_photo - photos.order(created_at: :desc).first - end - def tradable? tradable_to != 'nowhere' end From d8df4338a79450a99f5798fc0f6a25858826a32a Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Fri, 12 Jul 2019 13:21:36 +1200 Subject: [PATCH 51/66] DRY garden model - get default photo from photo_capable concern --- app/models/garden.rb | 4 ---- 1 file changed, 4 deletions(-) diff --git a/app/models/garden.rb b/app/models/garden.rb index 6c8318f42..8eb27cc78 100644 --- a/app/models/garden.rb +++ b/app/models/garden.rb @@ -89,8 +89,4 @@ class Garden < ApplicationRecord p.save end end - - def default_photo - photos.order(created_at: :desc).first - end end From b654fd483b4d7a85452d230423936eb9088cd183 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Fri, 12 Jul 2019 15:07:41 +1200 Subject: [PATCH 52/66] counter cache was on the wrong side of the relationship --- app/models/concerns/likeable.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/concerns/likeable.rb b/app/models/concerns/likeable.rb index 4760a8f14..4937af53e 100644 --- a/app/models/concerns/likeable.rb +++ b/app/models/concerns/likeable.rb @@ -2,7 +2,7 @@ module Likeable extend ActiveSupport::Concern included do - has_many :likes, as: :likeable, inverse_of: :likeable, dependent: :destroy, counter_cache: true + has_many :likes, as: :likeable, inverse_of: :likeable, dependent: :destroy has_many :members, through: :likes end From 2879979db49b6e23f7fbb3f7c98cf96f06ebcc37 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Fri, 12 Jul 2019 15:08:02 +1200 Subject: [PATCH 53/66] tests that likes are deleted when their photo is deleted --- spec/models/like_spec.rb | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/spec/models/like_spec.rb b/spec/models/like_spec.rb index 363585aea..56f35bf1d 100644 --- a/spec/models/like_spec.rb +++ b/spec/models/like_spec.rb @@ -48,6 +48,12 @@ describe 'like' do expect(Like.all).not_to include like end + it 'destroys like if post no longer exists' do + like = Like.create(member: member, likeable: post) + post.destroy + expect(Like.all).not_to include like + end + it 'destroys like if member no longer exists' do like = Like.create(member: member, likeable: post) member.destroy From 32695e32412546e354b5637d5f789b1594fca673 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Fri, 12 Jul 2019 15:08:39 +1200 Subject: [PATCH 54/66] photos behave like likeable --- spec/models/photo_spec.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/spec/models/photo_spec.rb b/spec/models/photo_spec.rb index d71a6cd1c..bbcd2c74b 100644 --- a/spec/models/photo_spec.rb +++ b/spec/models/photo_spec.rb @@ -4,6 +4,8 @@ describe Photo do let(:photo) { FactoryBot.create(:photo, owner: member) } let(:member) { FactoryBot.create(:member) } + it_behaves_like "it is likeable" + describe 'add/delete functionality' do let(:planting) { FactoryBot.create(:planting, owner: member) } let(:harvest) { FactoryBot.create(:harvest, owner: member) } From b1ebf67960841bdf4546686882a775ce820f0723 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Fri, 12 Jul 2019 15:13:10 +1200 Subject: [PATCH 55/66] added more possible photo associations in photo model spec --- spec/models/photo_spec.rb | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/spec/models/photo_spec.rb b/spec/models/photo_spec.rb index bbcd2c74b..1729655c4 100644 --- a/spec/models/photo_spec.rb +++ b/spec/models/photo_spec.rb @@ -8,7 +8,9 @@ describe Photo do describe 'add/delete functionality' do let(:planting) { FactoryBot.create(:planting, owner: member) } + let(:seed) { FactoryBot.create(:seed, owner: member) } let(:harvest) { FactoryBot.create(:harvest, owner: member) } + let(:post) { FactoryBot.create(:post, author: member) } let(:garden) { FactoryBot.create(:garden, owner: member) } context "adds photos" do @@ -24,11 +26,23 @@ describe Photo do expect(harvest.photos.first).to eq photo end + it 'to a seed' do + seed.photos << photo + expect(seed.photos.size).to eq 1 + expect(seed.photos.first).to eq photo + end + it 'to a garden' do garden.photos << photo expect(garden.photos.size).to eq 1 expect(garden.photos.first).to eq photo end + + it 'to a post' do + post.photos << photo + expect(post.photos.size).to eq 1 + expect(post.photos.first).to eq photo + end end context "removing photos" do From 60a510e73f65f6f35a3daecced2ab18f004a1672 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Fri, 12 Jul 2019 15:21:18 +1200 Subject: [PATCH 56/66] tests the default photo changes when someone likes a photo --- spec/models/photo_spec.rb | 30 ++++++++++++++++++++++++------ 1 file changed, 24 insertions(+), 6 deletions(-) diff --git a/spec/models/photo_spec.rb b/spec/models/photo_spec.rb index 1729655c4..f21a49270 100644 --- a/spec/models/photo_spec.rb +++ b/spec/models/photo_spec.rb @@ -2,7 +2,8 @@ require 'rails_helper' describe Photo do let(:photo) { FactoryBot.create(:photo, owner: member) } - let(:member) { FactoryBot.create(:member) } + let(:old_photo) { FactoryBot.create(:photo, owner: member, created_at: 1.year.ago, date_taken: 2.years.ago) } + let(:member) { FactoryBot.create(:member) } it_behaves_like "it is likeable" @@ -11,13 +12,30 @@ describe Photo do let(:seed) { FactoryBot.create(:seed, owner: member) } let(:harvest) { FactoryBot.create(:harvest, owner: member) } let(:post) { FactoryBot.create(:post, author: member) } - let(:garden) { FactoryBot.create(:garden, owner: member) } + let(:garden) { FactoryBot.create(:garden, owner: member) } context "adds photos" do - it 'to a planting' do - planting.photos << photo - expect(planting.photos.size).to eq 1 - expect(planting.photos.first).to eq photo + describe 'to a planting' do + before { planting.photos << photo } + + it { expect(planting.photos.size).to eq 1 } + it { expect(planting.photos.first).to eq photo } + # there's only one photo, so that's the default + it { expect(planting.default_photo).to eq photo } + it { expect(planting.crop.default_photo).to eq photo } + + describe 'with a second older photo' do + # Add an old photo + before { planting.photos << old_photo } + it { expect(planting.default_photo).to eq photo } + it { expect(planting.crop.default_photo).to eq photo } + + describe 'and someone likes the old photo' do + before { Like.create(likeable: old_photo) } + it { expect(planting.default_photo).to eq photo } + it { expect(planting.crop.default_photo).to eq photo } + end + end end it 'to a harvest' do From 99c119c07fdd1598db3281f5909f2c01c66d1834 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Fri, 12 Jul 2019 15:29:05 +1200 Subject: [PATCH 57/66] fixed looking up photo counts in spec --- spec/models/crop_spec.rb | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/spec/models/crop_spec.rb b/spec/models/crop_spec.rb index fa642a540..ed17069c9 100644 --- a/spec/models/crop_spec.rb +++ b/spec/models/crop_spec.rb @@ -185,9 +185,9 @@ describe Crop do end it { expect(crop.photos.size).to eq 0 } - it { expect(crop.planting_photos.size).to eq 0 } - it { expect(crop.harvest_photos.size).to eq 0 } - it { expect(crop.seed_photos.size).to eq 0 } + it { expect(crop.photos.by_model(Planting).size).to eq 0 } + it { expect(crop.photos.by_model(Harvest).size).to eq 0 } + it { expect(crop.photos.by_model(Seed).size).to eq 0 } end describe 'finding all photos' do @@ -203,9 +203,9 @@ describe Crop do end it { expect(crop.photos.size).to eq 3 } - it { expect(crop.planting_photos.size).to eq 1 } - it { expect(crop.harvest_photos.size).to eq 1 } - it { expect(crop.seed_photos.size).to eq 1 } + it { expect(crop.photos.by_model(Planting).size).to eq 1 } + it { expect(crop.photos.by_model(Harvest).size).to eq 1 } + it { expect(crop.photos.by_model(Seed).size).to eq 1 } end end From efe14d43cbff1e619a3dce6a96dcd0d30fe63b50 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Fri, 12 Jul 2019 16:36:54 +1200 Subject: [PATCH 58/66] read photo from a harvest's planting --- app/models/harvest.rb | 4 ++++ spec/models/harvest_spec.rb | 1 + 2 files changed, 5 insertions(+) diff --git a/app/models/harvest.rb b/app/models/harvest.rb index 2b24e2fa7..6dffbca6a 100644 --- a/app/models/harvest.rb +++ b/app/models/harvest.rb @@ -74,6 +74,10 @@ class Harvest < ApplicationRecord harvested_at - planting.planted_at end + def default_photo + most_liked_photo || planting&.default_photo + end + # we're storing the harvest weight in kilograms in the db too # to make data manipulation easier def set_si_weight diff --git a/spec/models/harvest_spec.rb b/spec/models/harvest_spec.rb index 35cb9ba5f..168b2bcdc 100644 --- a/spec/models/harvest_spec.rb +++ b/spec/models/harvest_spec.rb @@ -237,6 +237,7 @@ describe Harvest do @planting = FactoryBot.create(:planting, crop: @harvest.crop) @photo = FactoryBot.create(:photo, owner: @planting.owner) @planting.photos << @photo + @harvest.update(planting: @planting) end it 'has a default photo' do From 3cd67bcc9ff136e80d134bc3999a5d347b68362e Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Fri, 12 Jul 2019 22:27:55 +1200 Subject: [PATCH 59/66] Fix liked photo spec --- spec/models/photo_spec.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/spec/models/photo_spec.rb b/spec/models/photo_spec.rb index f21a49270..1102253f8 100644 --- a/spec/models/photo_spec.rb +++ b/spec/models/photo_spec.rb @@ -31,9 +31,9 @@ describe Photo do it { expect(planting.crop.default_photo).to eq photo } describe 'and someone likes the old photo' do - before { Like.create(likeable: old_photo) } - it { expect(planting.default_photo).to eq photo } - it { expect(planting.crop.default_photo).to eq photo } + before { FactoryBot.create :like, likeable: old_photo } + it { expect(planting.default_photo).to eq old_photo } + it { expect(planting.crop.default_photo).to eq old_photo } end end end From 2162c11280cbe756d1efaa33f31a401016b0a781 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Mon, 15 Jul 2019 13:49:10 +1200 Subject: [PATCH 60/66] Couple breadcrumbs tidied --- app/views/admin/index.html.haml | 6 +----- app/views/devise/registrations/edit.html.haml | 3 +++ 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/app/views/admin/index.html.haml b/app/views/admin/index.html.haml index f21c5f93a..5586cfec3 100644 --- a/app/views/admin/index.html.haml +++ b/app/views/admin/index.html.haml @@ -1,11 +1,7 @@ - content_for :title, 'Admin' - content_for :breadcrumbs do - %nav{"aria-label" => "breadcrumb"} - %ol.breadcrumb - %li.breadcrumb-item - = link_to 'Home', root_path - %li.breadcrumb-item.active= link_to 'Admin', admin_path + %li.breadcrumb-item.active= link_to 'Admin', admin_path %h2 Manage diff --git a/app/views/devise/registrations/edit.html.haml b/app/views/devise/registrations/edit.html.haml index 075fdd4a3..3a3fe90b4 100644 --- a/app/views/devise/registrations/edit.html.haml +++ b/app/views/devise/registrations/edit.html.haml @@ -1,5 +1,8 @@ - content_for :title, "Settings for #{current_member.login_name}" +- content_for :breadcrumbs do + %li.breadcrumb-item= link_to 'My Profile', member_path(current_member) + %h1 = member_icon Settings for #{current_member.login_name} From 2dfef909bd9d38a67b628d1caf4dbd7601acf667 Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Tue, 16 Jul 2019 07:15:22 +0000 Subject: [PATCH 61/66] Bump chartkick from 3.2.0 to 3.2.1 Bumps [chartkick](https://github.com/ankane/chartkick) from 3.2.0 to 3.2.1. - [Release notes](https://github.com/ankane/chartkick/releases) - [Changelog](https://github.com/ankane/chartkick/blob/master/CHANGELOG.md) - [Commits](https://github.com/ankane/chartkick/compare/v3.2.0...v3.2.1) Signed-off-by: dependabot-preview[bot] --- Gemfile.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile.lock b/Gemfile.lock index 54846ef7d..7e89b3ed3 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -100,7 +100,7 @@ GEM capybara-screenshot (1.0.23) capybara (>= 1.0, < 4) launchy - chartkick (3.2.0) + chartkick (3.2.1) childprocess (1.0.1) rake (< 13.0) codeclimate-test-reporter (1.0.9) From f46cc3151540f6ae10798a42ed554e781630d7ec Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Tue, 16 Jul 2019 10:54:48 +0000 Subject: [PATCH 62/66] Bump capybara from 3.25.0 to 3.26.0 Bumps [capybara](https://github.com/teamcapybara/capybara) from 3.25.0 to 3.26.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.25.0...3.26.0) Signed-off-by: dependabot-preview[bot] --- Gemfile.lock | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 7e89b3ed3..b4f9ede7e 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -86,7 +86,7 @@ GEM uniform_notifier (~> 1.11) byebug (11.0.1) cancancan (3.0.1) - capybara (3.25.0) + capybara (3.26.0) addressable mini_mime (>= 0.1.3) nokogiri (~> 1.8) @@ -297,7 +297,7 @@ GEM mime-types-data (3.2019.0331) mimemagic (0.3.3) mini_magick (4.9.3) - mini_mime (1.0.1) + mini_mime (1.0.2) mini_portile2 (2.4.0) minitest (5.11.3) moneta (1.0.0) From b7175a2e327678c05c3adb2e56c9f2726339cf44 Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Wed, 17 Jul 2019 09:31:43 +0000 Subject: [PATCH 63/66] [Security] Bump mini_magick from 4.9.3 to 4.9.4 Bumps [mini_magick](https://github.com/minimagick/minimagick) from 4.9.3 to 4.9.4. **This update includes security fixes.** - [Release notes](https://github.com/minimagick/minimagick/releases) - [Commits](https://github.com/minimagick/minimagick/compare/v4.9.3...v4.9.4) Signed-off-by: dependabot-preview[bot] --- Gemfile.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile.lock b/Gemfile.lock index b4f9ede7e..faf9341f9 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -296,7 +296,7 @@ GEM mime-types-data (~> 3.2015) mime-types-data (3.2019.0331) mimemagic (0.3.3) - mini_magick (4.9.3) + mini_magick (4.9.4) mini_mime (1.0.2) mini_portile2 (2.4.0) minitest (5.11.3) From 64fa4584b990778c3d4feb2e2edd150479b3b335 Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Wed, 17 Jul 2019 20:29:38 +0000 Subject: [PATCH 64/66] Bump rubocop from 0.72.0 to 0.73.0 Bumps [rubocop](https://github.com/rubocop-hq/rubocop) from 0.72.0 to 0.73.0. - [Release notes](https://github.com/rubocop-hq/rubocop/releases) - [Changelog](https://github.com/rubocop-hq/rubocop/blob/master/CHANGELOG.md) - [Commits](https://github.com/rubocop-hq/rubocop/compare/v0.72.0...v0.73.0) Signed-off-by: dependabot-preview[bot] --- Gemfile.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile.lock b/Gemfile.lock index faf9341f9..d90e7fc2b 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -424,7 +424,7 @@ GEM rspec-mocks (~> 3.8.0) rspec-support (~> 3.8.0) rspec-support (3.8.2) - rubocop (0.72.0) + rubocop (0.73.0) jaro_winkler (~> 1.5.1) parallel (~> 1.10) parser (>= 2.6) From e4512beb03ea8513f53c89123ae5c1527f6cd9a9 Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Thu, 18 Jul 2019 16:23:55 +0000 Subject: [PATCH 65/66] Bump oj from 3.7.12 to 3.8.0 Bumps [oj](https://github.com/ohler55/oj) from 3.7.12 to 3.8.0. - [Release notes](https://github.com/ohler55/oj/releases) - [Changelog](https://github.com/ohler55/oj/blob/develop/CHANGELOG.md) - [Commits](https://github.com/ohler55/oj/compare/v3.7.12...v3.8.0) Signed-off-by: dependabot-preview[bot] --- Gemfile.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile.lock b/Gemfile.lock index d90e7fc2b..64bd00aea 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -315,7 +315,7 @@ GEM multi_json (~> 1.3) multi_xml (~> 0.5) rack (>= 1.2, < 3) - oj (3.7.12) + oj (3.8.0) omniauth (1.9.0) hashie (>= 3.4.6, < 3.7.0) rack (>= 1.6.2, < 3) From f0ec15805359b3a16bb5f06105f0b4526fad6c92 Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Fri, 19 Jul 2019 07:15:47 +0000 Subject: [PATCH 66/66] Bump webdrivers from 4.1.0 to 4.1.1 Bumps [webdrivers](https://github.com/titusfortner/webdrivers) from 4.1.0 to 4.1.1. - [Release notes](https://github.com/titusfortner/webdrivers/releases) - [Changelog](https://github.com/titusfortner/webdrivers/blob/master/CHANGELOG.md) - [Commits](https://github.com/titusfortner/webdrivers/compare/v4.1.0...v4.1.1) Signed-off-by: dependabot-preview[bot] --- Gemfile.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile.lock b/Gemfile.lock index 64bd00aea..0ed34529c 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -511,7 +511,7 @@ GEM uniform_notifier (1.12.1) warden (1.2.8) rack (>= 2.0.6) - webdrivers (4.1.0) + webdrivers (4.1.1) nokogiri (~> 1.6) rubyzip (~> 1.0) selenium-webdriver (>= 3.0, < 4.0)