created list of crop wranglers on the crop wranglers page

This commit is contained in:
Marlena Compton committed 2014-08-21 20:11:10 -07:00
1 parent eaaceb5951
commit ec25f2ab91
12 files changed
+79 -11

No files matched your search

+1
View File
@@ -124,4 +124,5 @@ group :development, :test do
gem 'webrat' # provides HTML matchers for view tests
gem 'factory_girl_rails', '~> 4.0' # for creating test data
gem 'coveralls', require: false # coverage analysis
gem 'capybara' # integration tests
end
+9
View File
@@ -73,6 +73,12 @@ GEM
railties (>= 3.0)
builder (3.0.4)
cancan (1.6.10)
capybara (2.3.0)
mime-types (>= 1.16)
nokogiri (>= 1.3.3)
rack (>= 1.0.0)
rack-test (>= 0.5.4)
xpath (~> 2.0)
chunky_png (1.3.1)
coderay (1.1.0)
coffee-rails (3.2.2)
@@ -277,6 +283,8 @@ GEM
rack (>= 1.0)
rack-test (>= 0.5.3)
will_paginate (3.0.5)
xpath (2.0.0)
nokogiri (~> 1.3)
PLATFORMS
ruby
@@ -290,6 +298,7 @@ DEPENDENCIES
bootstrap-datepicker-rails
bundler (>= 1.1.5)
cancan
capybara
coffee-rails (~> 3.2.1)
compass-rails (~> 1.0.3)
coveralls
@@ -1,3 +0,0 @@
# Place all the behaviors and hooks related to the matching controller here.
# All this logic will automatically be available in application.js.
# You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script/
+8 -1
View File
@@ -31,10 +31,17 @@ class CropsController < ApplicationController
end
end
def wrangler_index
@crop_wranglers = Role.crop_wranglers
respond_to do |format|
format.html
end
end
# GET /crops/wrangle
def wrangle
@crops = Crop.recent.paginate(:page => params[:page])
@crop_wranglers = Role.crop_wranglers
respond_to do |format|
format.html
end
+4
View File
@@ -3,4 +3,8 @@ class Role < ActiveRecord::Base
friendly_id :name, use: :slugged
attr_accessible :description, :name, :members, :slug
has_and_belongs_to_many :members
def self.crop_wranglers
Role.where(slug: 'crop-wrangler').try(:first).try(:members)
end
end
+7
View File
@@ -8,6 +8,13 @@
%li= link_to "Full crop hierarchy", crops_hierarchy_path
%li= link_to "Add Crop", new_crop_path
%div.crop_wranglers
%h2 Crop Wranglers:
%ul
- @crop_wranglers.each do |crop_wrangler|
%li.crop_wrangler
= link_to crop_wrangler.login_name, crop_wrangler
%h2 Recently added crops
%div.pagination
@@ -16,6 +16,7 @@ describe CropsController do
get :wrangle
response.should be_success
response.should render_template("crops/wrangle")
expect(assigns[:crop_wranglers]).to eq(Role.crop_wranglers)
end
end
+1
View File
@@ -60,6 +60,7 @@ FactoryGirl.define do
factory :crop_wrangling_member do
roles { [ FactoryGirl.create(:crop_wrangler) ] }
sequence(:login_name) {|n| "wrangler#{n}"}
end
factory :invalid_member_shortname do
+1 -1
View File
@@ -10,7 +10,7 @@ FactoryGirl.define do
end
factory :crop_wrangler do
name "crop wrangler"
name "Crop Wrangler"
description "they wrangle crops"
end
end
+30
View File
@@ -0,0 +1,30 @@
require 'spec_helper'
feature "crop wranglers" do
context "signed in user" do
let(:crop_wrangler_role) { FactoryGirl.create :crop_wrangler }
let!(:crop_wranglers) { FactoryGirl.create_list(:crop_wrangling_member, 3, roles: [crop_wrangler_role]) }
let(:user){crop_wranglers.first}
before :each do
visit root_path
click_link 'Sign in'
fill_in 'Login', with: user.login_name
fill_in 'Password', with: user.password
click_button 'Sign in'
page.should have_content user.login_name
end
scenario "crop wranglers are listed on the crop wrangler page" do
click_link 'Crop Wrangling'
within '.crop_wranglers' do
expect(page).to have_content 'Crop Wranglers:'
crop_wranglers.each_with_index do |crop_wrangler, index|
link = find(".crop_wrangler:nth-child(#{index + 1}) a")
expect(link.text).to eq(crop_wrangler.login_name)
expect(link['href']).to eq(member_path(crop_wrangler))
end
end
end
end
end
+16 -6
View File
@@ -1,17 +1,27 @@
require 'spec_helper'
describe Role do
before(:each) do
@member = FactoryGirl.create(:member)
@role = FactoryGirl.create(:role)
@role.members << @member
let(:member) { FactoryGirl.create(:member) }
subject do
role = FactoryGirl.create(:role, name: 'Crop Wrangler')
role.members << member
role
end
it 'has members' do
@role.members.first.should eq @member
subject.members.first.should eq member
end
it 'has a slug' do
@role.slug.should eq 'moderator'
subject.slug.should eq 'crop-wrangler'
end
describe '.crop_wranglers' do
let(:crop_wrangler_role) { FactoryGirl.create :crop_wrangler }
let!(:crop_wranglers) { FactoryGirl.create_list(:crop_wrangling_member, 3, roles: [crop_wrangler_role]) }
it 'return the crop wranglers that are members of that role' do
expect(Role.crop_wranglers).to eq(crop_wranglers)
end
end
end
@@ -13,6 +13,7 @@ describe "crops/wrangle" do
pager.replace([ @tomato, @maize ])
end
assign(:crops, crops)
assign(:crop_wranglers, Role.crop_wranglers)
end
it 'contains handy links for wranglers' do