mirror of
https://github.com/Growstuff/growstuff.git
synced 2026-02-02 05:31:01 -05:00
Merge pull request #722 from maco/approved_crops
remove pending/rejected crops from browse and test that, change links on...
This commit is contained in:
@@ -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|
|
||||
|
||||
@@ -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|
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user