mirror of
https://github.com/Growstuff/growstuff.git
synced 2026-05-24 16:58:35 -04:00
added a basic crop wrangler homepage
This commit is contained in:
@@ -15,6 +15,15 @@ class CropsController < ApplicationController
|
||||
end
|
||||
end
|
||||
|
||||
# GET /wrangle
|
||||
def wrangle
|
||||
@crops = Crop.recent.paginate(:page => params[:page])
|
||||
|
||||
respond_to do |format|
|
||||
format.html
|
||||
end
|
||||
end
|
||||
|
||||
# GET /crops/1
|
||||
# GET /crops/1.json
|
||||
def show
|
||||
|
||||
@@ -37,6 +37,7 @@ class Ability
|
||||
|
||||
# only crop wranglers can create/edit/destroy crops
|
||||
if member.has_role? :crop_wrangler
|
||||
can :wrangle, Crop
|
||||
can :manage, Crop
|
||||
can :manage, ScientificName
|
||||
end
|
||||
|
||||
38
app/views/crops/wrangle.html.haml
Normal file
38
app/views/crops/wrangle.html.haml
Normal file
@@ -0,0 +1,38 @@
|
||||
- content_for :title, "Crop Wrangling"
|
||||
|
||||
|
||||
%ul
|
||||
%li= link_to "Requests for new crops", 'http://growstuff.org/posts/skud-20130319-requests-for-new-crops'
|
||||
%li= link_to "Crop wrangler guidelines", "http://wiki.growstuff.org/index.php/Crop_wrangling"
|
||||
%li= link_to "crop-wranglers mailing list", "http://lists.growstuff.org/listinfo/crop-wranglers"
|
||||
%li= link_to "Add Crop", new_crop_path
|
||||
|
||||
%h2 Recently added crops
|
||||
|
||||
%div.pagination
|
||||
= page_entries_info @crops, :model => "crops"
|
||||
= will_paginate @crops
|
||||
|
||||
%table.table.table-striped
|
||||
%tr
|
||||
%th System name
|
||||
%th English Wikipedia URL
|
||||
%th Scientific names
|
||||
%th Added by
|
||||
%th When
|
||||
- @crops.each do |c|
|
||||
%tr
|
||||
%td= link_to c.system_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.creator, c.creator
|
||||
%td
|
||||
= distance_of_time_in_words(c.created_at, Time.zone.now)
|
||||
ago.
|
||||
|
||||
%div.pagination
|
||||
= page_entries_info @crops, :model => "crops"
|
||||
= will_paginate @crops
|
||||
@@ -43,6 +43,8 @@
|
||||
= link_to("Inbox", notifications_path)
|
||||
|
||||
%li= link_to "Shop", shop_path
|
||||
- if current_member.has_role?(:crop_wrangler)
|
||||
%li= link_to "Crop Wrangling", wrangle_crops_path
|
||||
- if current_member.has_role?(:admin)
|
||||
%li= link_to "Admin", admin_path
|
||||
|
||||
|
||||
@@ -20,7 +20,10 @@ Growstuff::Application.routes.draw do
|
||||
match '/posts/author/:author' => 'posts#index', :as => 'posts_by_author'
|
||||
|
||||
resources :scientific_names
|
||||
|
||||
match 'crops/wrangle' => 'crops#wrangle', :as => 'wrangle_crops'
|
||||
resources :crops
|
||||
|
||||
resources :comments
|
||||
resources :roles
|
||||
resources :forums
|
||||
|
||||
@@ -11,6 +11,14 @@ describe CropsController do
|
||||
}
|
||||
end
|
||||
|
||||
describe "GET crop wrangler homepage" do
|
||||
it 'fetches the crop wrangler homepage' do
|
||||
get :wrangle
|
||||
response.should be_success
|
||||
response.should render_template("crops/wrangle")
|
||||
end
|
||||
end
|
||||
|
||||
describe "GET RSS feed" do
|
||||
it "returns an RSS feed" do
|
||||
get :index, :format => "rss"
|
||||
|
||||
35
spec/views/crops/wrangle.html.haml_spec.rb
Normal file
35
spec/views/crops/wrangle.html.haml_spec.rb
Normal file
@@ -0,0 +1,35 @@
|
||||
require 'spec_helper'
|
||||
|
||||
describe "crops/wrangle" do
|
||||
before(:each) do
|
||||
@member = FactoryGirl.create(:crop_wrangling_member)
|
||||
controller.stub(:current_user) { @member }
|
||||
page = 1
|
||||
per_page = 2
|
||||
total_entries = 2
|
||||
@tomato = FactoryGirl.create(:tomato)
|
||||
@maize = FactoryGirl.create(:maize)
|
||||
crops = WillPaginate::Collection.create(page, per_page, total_entries) do |pager|
|
||||
pager.replace([ @tomato, @maize ])
|
||||
end
|
||||
assign(:crops, crops)
|
||||
end
|
||||
|
||||
it 'contains handy links for wranglers' do
|
||||
render
|
||||
rendered.should contain "Crop wrangler guidelines"
|
||||
rendered.should contain "mailing list"
|
||||
end
|
||||
|
||||
it 'has a link to add a crop' do
|
||||
render
|
||||
assert_select "a", :href => new_crop_path
|
||||
end
|
||||
|
||||
it "renders a list of crops" do
|
||||
render
|
||||
assert_select "a", :text => "Maize"
|
||||
assert_select "a", :text => "Tomato"
|
||||
end
|
||||
|
||||
end
|
||||
Reference in New Issue
Block a user