fix regressions

This commit is contained in:
Taylor Griffin
2015-02-02 00:01:49 +11:00
parent 40d13fadb3
commit 2f67ffd2f8
8 changed files with 37 additions and 29 deletions

View File

@@ -23,7 +23,7 @@ class Crop < ActiveRecord::Base
default_scope { order("lower(name) asc") }
scope :recent, -> { where(:approval_status => "approved").reorder("created_at desc") }
scope :toplevel, -> { where(approval_status => "approved", :parent_id => nil) }
scope :toplevel, -> { where(:approval_status => "approved", :parent_id => nil) }
scope :popular, -> { where(:approval_status => "approved").reorder("plantings_count desc, lower(name) asc") }
scope :randomized, -> { where(:approval_status => "approved").reorder('random()') } # ok on sqlite and psql, but not on mysql
scope :pending_approval, -> { where(:approval_status => "pending") }

View File

@@ -17,27 +17,30 @@
%h2 Requested crops
%table#requested-crops.table.table-striped
%thead
%tr
%th System name
%th English Wikipedia URL
%th Scientific names
%th Requested by
%th When requested
%tbody
- @pending_approval.each do |c|
- if @pending_approval
%table#requested-crops.table.table-striped
%thead
%tr
%td= link_to c.name, c
%td= link_to c.en_wikipedia_url, c.en_wikipedia_url
%td
- c.scientific_names.each do |s|
= link_to s.scientific_name, s
%br/
%td= link_to c.requester, c.requester
%td
= distance_of_time_in_words(c.created_at, Time.zone.now)
ago.
%th System name
%th English Wikipedia URL
%th Scientific names
%th Requested by
%th When requested
%tbody
- @pending_approval.each do |c|
%tr
%td= link_to c.name, c
%td= link_to c.en_wikipedia_url, c.en_wikipedia_url
%td
- c.scientific_names.each do |s|
= link_to s.scientific_name, s
%br/
%td= link_to c.requester, c.requester
%td
= distance_of_time_in_words(c.created_at, Time.zone.now)
ago.
- else
%p There are no crops pending approval.
%h2 Recently added crops
@@ -45,7 +48,7 @@
= page_entries_info @recent_crops, :model => "crops"
= will_paginate @recent_crops
%table.table.table-striped
%table#recently-added.table.table-striped
%tr
%th System name
%th English Wikipedia URL

View File

@@ -7,7 +7,8 @@ describe CropsController do
def valid_attributes
{
:name => "Tomato",
:en_wikipedia_url => 'http://en.wikipedia.org/wiki/Tomato'
:en_wikipedia_url => 'http://en.wikipedia.org/wiki/Tomato',
:approval_status => 'approved'
}
end

View File

@@ -3,6 +3,7 @@ FactoryGirl.define do
factory :crop do
name "magic bean"
en_wikipedia_url "http://en.wikipedia.org/wiki/Magic_bean"
approval_status "approved"
creator
factory :tomato do

View File

@@ -25,7 +25,7 @@ feature "crop wranglers" do
scenario "can see list of crops with extra detail of who created a crop" do
visit root_path
click_link 'Crop Wrangling'
within '.table' do
within '#recently-added' do
expect(page).to have_content "#{crops.first.creator.login_name}"
end
end

View File

@@ -90,9 +90,9 @@ describe Notifier do
end
it 'includes links to plant, harvest and stash seeds for the new crop' do
expect(mail.body.encoded).to match new_planting_url(crop_id: crop.id)
expect(mail.body.encoded).to match new_harvest_url(crop_id: crop.id)
expect(mail.body.encoded).to match new_seed_url(crop_id: crop.id)
expect(mail.body.encoded).to match new_planting_url
expect(mail.body.encoded).to match new_harvest_url
expect(mail.body.encoded).to match new_seed_url
end
end

View File

@@ -45,11 +45,14 @@ describe Ability do
context "standard member" do
it "can't manage crops" do
@ability.should_not be_able_to(:create, Crop)
@ability.should_not be_able_to(:update, @crop)
@ability.should_not be_able_to(:destroy, @crop)
end
it "can request crops" do
@ability.should be_able_to(:create, Crop)
end
it "can read crops" do
@ability.should be_able_to(:read, @crop)
end

View File

@@ -12,7 +12,7 @@ describe "crops/wrangle" do
crops = WillPaginate::Collection.create(page, per_page, total_entries) do |pager|
pager.replace([ @tomato, @maize ])
end
assign(:crops, crops)
assign(:recent_crops, crops)
assign(:crop_wranglers, Role.crop_wranglers)
end