From 90ca5ec13beb42adc88fd3a5ea9dc2b005bc42d5 Mon Sep 17 00:00:00 2001 From: Shiho Takagi Date: Fri, 13 Feb 2015 23:39:31 +1100 Subject: [PATCH 1/4] added thumbnails of crops mentioned on post page --- app/views/posts/_single.html.haml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/app/views/posts/_single.html.haml b/app/views/posts/_single.html.haml index 8f5cc5507..e301ed76a 100644 --- a/app/views/posts/_single.html.haml +++ b/app/views/posts/_single.html.haml @@ -21,6 +21,14 @@ :growstuff_markdown #{ strip_tags post.body } + - unless post.crops.empty? + .hidden-xs + %h3 Crops mentioned in this post + - post.crops.each do |c| + - unless c.photos.empty? + .col-md-2{:style => 'padding-bottom: 6px'} + = render :partial => 'crops/image_with_popover', :locals => { :crop => c } + .col-md-11 - unless defined?(hide_comments) .post-comments %ul.list-inline From 17ccea4b280282593b5527842392f523a3347141 Mon Sep 17 00:00:00 2001 From: Shiho Takagi Date: Mon, 23 Feb 2015 21:41:42 +1100 Subject: [PATCH 2/4] moving photo on posts/show view --- app/views/posts/_single.html.haml | 8 -------- app/views/posts/show.html.haml | 30 +++++++++++++++++++----------- 2 files changed, 19 insertions(+), 19 deletions(-) diff --git a/app/views/posts/_single.html.haml b/app/views/posts/_single.html.haml index e301ed76a..8f5cc5507 100644 --- a/app/views/posts/_single.html.haml +++ b/app/views/posts/_single.html.haml @@ -21,14 +21,6 @@ :growstuff_markdown #{ strip_tags post.body } - - unless post.crops.empty? - .hidden-xs - %h3 Crops mentioned in this post - - post.crops.each do |c| - - unless c.photos.empty? - .col-md-2{:style => 'padding-bottom: 6px'} - = render :partial => 'crops/image_with_popover', :locals => { :crop => c } - .col-md-11 - unless defined?(hide_comments) .post-comments %ul.list-inline diff --git a/app/views/posts/show.html.haml b/app/views/posts/show.html.haml index b6e07bde7..e6cd99625 100644 --- a/app/views/posts/show.html.haml +++ b/app/views/posts/show.html.haml @@ -16,16 +16,24 @@ = render :partial => "single", :locals => { :post => @post, :subject => false, :hide_comments => true } -- if can? :edit, @post or can? :destroy, @post - .post-actions - - if can? :edit, @post - = link_to 'Edit Post', edit_post_path(@post), :class => 'btn btn-default btn-xs' - - if can? :destroy, @post - = link_to 'Delete Post', @post, method: :delete, | - data: { confirm: 'Are you sure?' }, :class => 'btn btn-default btn-xs' +- unless @post.crops.empty? + %h3 Crops mentioned in this post + - @post.crops.each do |c| + - unless c.photos.empty? + .col-md-2 + = render :partial => 'crops/thumbnail', :locals => { :crop => c } -= render :partial => "comments", :locals => { :post => @post } +.col-md-11 + - if can? :edit, @post or can? :destroy, @post + .post-actions + - if can? :edit, @post + = link_to 'Edit Post', edit_post_path(@post), :class => 'btn btn-default btn-xs' + - if can? :destroy, @post + = link_to 'Delete Post', @post, method: :delete, | + data: { confirm: 'Are you sure?' }, :class => 'btn btn-default btn-xs' -- if can? :create, Comment - .post-actions - =link_to 'Comment', new_comment_path(:post_id => @post.id), :class => 'btn btn-primary' + = render :partial => "comments", :locals => { :post => @post } + + - if can? :create, Comment + .post-actions + =link_to 'Comment', new_comment_path(:post_id => @post.id), :class => 'btn btn-primary' From 2abe6d7d122f5b23d5f078c7a24fb5fe0ac8aeb0 Mon Sep 17 00:00:00 2001 From: Shiho Takagi Date: Wed, 4 Mar 2015 12:53:08 +1100 Subject: [PATCH 3/4] show thumbnail even when there is no photo --- app/views/posts/show.html.haml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/app/views/posts/show.html.haml b/app/views/posts/show.html.haml index e6cd99625..1a656997d 100644 --- a/app/views/posts/show.html.haml +++ b/app/views/posts/show.html.haml @@ -19,9 +19,8 @@ - unless @post.crops.empty? %h3 Crops mentioned in this post - @post.crops.each do |c| - - unless c.photos.empty? - .col-md-2 - = render :partial => 'crops/thumbnail', :locals => { :crop => c } + .col-md-2 + = render :partial => 'crops/thumbnail', :locals => { :crop => c } .col-md-11 - if can? :edit, @post or can? :destroy, @post From 2d73dd2869df44122a800fc06377f36d58082993 Mon Sep 17 00:00:00 2001 From: Mackenzie Morgan Date: Wed, 25 Feb 2015 00:05:56 -0500 Subject: [PATCH 4/4] remove pending/rejected crops from browse and test that, change links on wrangling page to go directly to crop edit and update tests for that --- app/controllers/crops_controller.rb | 4 ++-- app/views/crops/wrangle.html.haml | 2 +- spec/features/crops/browse_crops_spec.rb | 11 +++++++++++ spec/features/crops/crop_wranglers_spec.rb | 10 ++-------- 4 files changed, 16 insertions(+), 11 deletions(-) diff --git a/app/controllers/crops_controller.rb b/app/controllers/crops_controller.rb index b8ad4f5c8..917b72570 100644 --- a/app/controllers/crops_controller.rb +++ b/app/controllers/crops_controller.rb @@ -12,11 +12,11 @@ class CropsController < ApplicationController if @sort == 'alpha' # alphabetical order @crops = Crop.includes(:scientific_names, {:plantings => :photos}) - @paginated_crops = @crops.paginate(:page => params[:page]) + @paginated_crops = @crops.approved.paginate(:page => params[:page]) else # default to sorting by popularity @crops = Crop.popular.includes(:scientific_names, {:plantings => :photos}) - @paginated_crops = @crops.paginate(:page => params[:page]) + @paginated_crops = @crops.approved.paginate(:page => params[:page]) end respond_to do |format| diff --git a/app/views/crops/wrangle.html.haml b/app/views/crops/wrangle.html.haml index 549a737a1..3a13ec68e 100644 --- a/app/views/crops/wrangle.html.haml +++ b/app/views/crops/wrangle.html.haml @@ -50,7 +50,7 @@ %th When - @crops.each do |c| %tr - %td= link_to c.name, c + %td= link_to c.name, edit_crop_path(c) %td= link_to c.en_wikipedia_url, c.en_wikipedia_url %td - c.scientific_names.each do |s| diff --git a/spec/features/crops/browse_crops_spec.rb b/spec/features/crops/browse_crops_spec.rb index 5df5dbd36..08e0b9247 100644 --- a/spec/features/crops/browse_crops_spec.rb +++ b/spec/features/crops/browse_crops_spec.rb @@ -4,6 +4,8 @@ feature "browse crops" do let(:tomato) { FactoryGirl.create(:tomato) } let(:maize) { FactoryGirl.create(:maize) } + let(:pending_crop) { FactoryGirl.create(:crop_request) } + let(:rejected_crop) { FactoryGirl.create(:rejected_crop) } scenario "has a form for sorting by" do visit crops_path @@ -16,4 +18,13 @@ feature "browse crops" do expect(page).to have_content crop1.name end + scenario "pending crops are not listed" do + visit crops_path + expect(page).not_to have_content pending_crop.name + end + + scenario "rejected crops are not listed" do + visit crops_path + expect(page).not_to have_content rejected_crop.name + end end diff --git a/spec/features/crops/crop_wranglers_spec.rb b/spec/features/crops/crop_wranglers_spec.rb index 1b2af3f06..b408e53bc 100644 --- a/spec/features/crops/crop_wranglers_spec.rb +++ b/spec/features/crops/crop_wranglers_spec.rb @@ -52,19 +52,13 @@ feature "crop wranglers" do end scenario "View pending crops" do - visit wrangle_crops_path(:approval_status => "pending") - within "#pending-crops" do - click_link "Ultra berry" - end + visit crop_path(requested_crop) expect(page).to have_content "This crop is currently pending approval." expect(page).to have_content "Please approve this even though it's fake." end scenario "View rejected crops" do - visit wrangle_crops_path(:approval_status => "rejected") - within "#rejected-crops" do - click_link "Fail bean" - end + visit crop_path(rejected_crop) expect(page).to have_content "This crop was rejected for the following reason: Totally fake" end