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