mirror of
https://github.com/Growstuff/growstuff.git
synced 2026-05-19 06:15:44 -04:00
@@ -3,7 +3,11 @@ class GardensController < ApplicationController
|
||||
# GET /gardens
|
||||
# GET /gardens.json
|
||||
def index
|
||||
@gardens = Garden.all
|
||||
@gardens = Garden.paginate(:page => params[:page])
|
||||
@owner = Member.find_by_slug(params[:owner])
|
||||
if @owner
|
||||
@gardens = @owner.gardens.paginate(:page => params[:page])
|
||||
end
|
||||
|
||||
respond_to do |format|
|
||||
format.html # index.html.erb
|
||||
|
||||
@@ -7,6 +7,10 @@ class PlantingsController < ApplicationController
|
||||
# GET /plantings.json
|
||||
def index
|
||||
@plantings = Planting.paginate(:page => params[:page])
|
||||
@owner = Member.find_by_slug(params[:owner])
|
||||
if @owner
|
||||
@plantings = @owner.plantings.paginate(:page => params[:page])
|
||||
end
|
||||
|
||||
respond_to do |format|
|
||||
format.html # index.html.erb
|
||||
|
||||
@@ -8,6 +8,10 @@ class PostsController < ApplicationController
|
||||
|
||||
def index
|
||||
@posts = Post.paginate(:page => params[:page])
|
||||
@author = Member.find_by_slug(params[:author])
|
||||
if @author
|
||||
@posts = @author.posts.paginate(:page => params[:page])
|
||||
end
|
||||
|
||||
respond_to do |format|
|
||||
format.html # index.html.haml
|
||||
|
||||
@@ -3,10 +3,10 @@ class SeedsController < ApplicationController
|
||||
# GET /seeds
|
||||
# GET /seeds.json
|
||||
def index
|
||||
@seeds = Seed.all
|
||||
@owner = Member.find_by_id(params[:owner_id])
|
||||
@seeds = Seed.paginate(:page => params[:page])
|
||||
@owner = Member.find_by_slug(params[:owner])
|
||||
if @owner
|
||||
@seeds = @owner.seeds.all
|
||||
@seeds = @owner.seeds.paginate(:page => params[:page])
|
||||
end
|
||||
|
||||
respond_to do |format|
|
||||
|
||||
@@ -8,6 +8,8 @@ class Seed < ActiveRecord::Base
|
||||
belongs_to :crop
|
||||
belongs_to :owner, :class_name => 'Member', :foreign_key => 'owner_id'
|
||||
|
||||
default_scope order("created_at desc")
|
||||
|
||||
validates :quantity,
|
||||
:numericality => { :only_integer => true },
|
||||
:allow_nil => true
|
||||
|
||||
@@ -1,23 +1,59 @@
|
||||
%h1 Listing gardens
|
||||
- content_for :title, @owner ? "#{@owner}'s gardens" : "Everyone's gardens"
|
||||
|
||||
- if can? :create, Garden
|
||||
%p= link_to 'New Garden', new_garden_path, :class => 'btn btn-primary'
|
||||
%p
|
||||
- if can? :create, Garden
|
||||
- if @owner
|
||||
%p
|
||||
- if @owner == current_member
|
||||
= link_to 'Add a garden', new_garden_path, :class => 'btn btn-primary'
|
||||
= link_to "View everyone's gardens", gardens_path, :class => 'btn'
|
||||
- else # everyone's gardens
|
||||
= link_to 'Add a garden', new_garden_path, :class => 'btn btn-primary'
|
||||
- if current_member
|
||||
= link_to 'View your gardens', gardens_by_owner_path(:owner => current_member.slug), :class => 'btn'
|
||||
- else
|
||||
= render :partial => 'shared/signin_signup', :locals => { :to => 'add a new garden' }
|
||||
|
||||
%table
|
||||
%tr
|
||||
%th Name
|
||||
%th User
|
||||
%th Slug
|
||||
%th
|
||||
%th
|
||||
- if @gardens.length > 0
|
||||
|
||||
- @gardens.each do |garden|
|
||||
%div.pagination
|
||||
= page_entries_info @gardens, :model => "gardens"
|
||||
= will_paginate @gardens
|
||||
|
||||
%table.table.table-striped
|
||||
%tr
|
||||
%td= link_to garden.name, garden
|
||||
%td= garden.owner
|
||||
%td= garden.slug
|
||||
- if can? :edit, garden
|
||||
%td= link_to 'Edit', edit_garden_path(garden), :class => 'btn btn-mini'
|
||||
- if can? :destroy, garden
|
||||
%td= link_to 'Delete', garden, method: :delete, data: { confirm: 'Are you sure?' }, :class => 'btn btn-mini'
|
||||
- unless @owner
|
||||
%th Owner
|
||||
%th Garden name
|
||||
%th Description
|
||||
%th Plantings
|
||||
%th
|
||||
|
||||
- @gardens.each do |garden|
|
||||
%tr
|
||||
- unless @owner
|
||||
%td= link_to garden.owner.login_name, garden.owner
|
||||
%td= link_to garden.name, garden
|
||||
%td= garden.description
|
||||
%td
|
||||
- if garden.plantings.empty?
|
||||
None
|
||||
- else
|
||||
%ul
|
||||
- garden.plantings.each do |p|
|
||||
%li
|
||||
= p.quantity
|
||||
= link_to p.crop.system_name, p
|
||||
- if p.planted_at
|
||||
planted on
|
||||
= p.planted_at
|
||||
|
||||
%td= link_to 'Details', garden, :class => 'btn btn-mini'
|
||||
|
||||
%div.pagination
|
||||
= page_entries_info @gardens, :model => "gardens"
|
||||
= will_paginate @gardens
|
||||
|
||||
- else
|
||||
%p There are no gardens to display.
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
.span9
|
||||
%div
|
||||
:markdown
|
||||
#{@garden.description}
|
||||
#{strip_tags @garden.description}
|
||||
- if can? :edit, @garden
|
||||
= link_to 'Edit garden', edit_garden_path(@garden), :class => 'btn btn-mini'
|
||||
- if can? :destroy, @garden
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
|
||||
%p
|
||||
%b Your seed stash:
|
||||
= link_to pluralize(current_member.seeds.count, "variety"), seeds_path(:owner_id => current_member.id)
|
||||
= link_to pluralize(current_member.seeds.count, "variety"), seeds_by_owner_path(:owner => current_member.slug)
|
||||
= link_to 'Add', new_seed_path, :class => 'btn btn-mini'
|
||||
|
||||
.span4
|
||||
|
||||
@@ -9,30 +9,46 @@
|
||||
.nav-collapse.collapse
|
||||
%ul.nav
|
||||
%li= link_to "Crops", crops_path
|
||||
%li= link_to "Members", members_path
|
||||
%li= link_to "Posts", posts_path
|
||||
%li= link_to "Forums", forums_path
|
||||
%li= link_to "Shop", shop_path
|
||||
-if member_signed_in? and current_member.has_role?(:admin)
|
||||
%li= link_to "Admin", admin_path
|
||||
%li.divider-vertical
|
||||
%li= link_to "Seeds", seeds_path
|
||||
%li.dropdown<
|
||||
%a.dropdown-toggle{'data-toggle' => 'dropdown', :href => members_path}
|
||||
Community
|
||||
%b.caret
|
||||
%ul.dropdown-menu
|
||||
%li= link_to "Members", members_path
|
||||
%li= link_to "Posts", posts_path
|
||||
%li= link_to "Forums", forums_path
|
||||
|
||||
%li.divider-vertical
|
||||
|
||||
- if member_signed_in?
|
||||
%li.dropdown<
|
||||
%a.dropdown-toggle{'data-toggle' => 'dropdown', :href => member_path(current_member)}
|
||||
= current_member.login_name
|
||||
%a.dropdown-toggle{'data-toggle' => 'dropdown', :href => root_path}
|
||||
- if current_member.notifications.unread_count > 0
|
||||
Your Stuff (#{current_member.notifications.unread_count})
|
||||
- else
|
||||
Your Stuff
|
||||
%b.caret
|
||||
%ul.dropdown-menu
|
||||
%li= link_to "Profile", member_path(current_member)
|
||||
%li= link_to "Settings", edit_member_registration_path
|
||||
%li= link_to "Account", orders_path
|
||||
%li= link_to "Sign out", destroy_member_session_path, :method => :delete
|
||||
%li
|
||||
- if current_member.notifications.unread_count > 0
|
||||
= link_to("Inbox (#{current_member.notifications.unread_count})", notifications_path)
|
||||
- else
|
||||
= link_to("Inbox", notifications_path)
|
||||
%ul.dropdown-menu
|
||||
%li= link_to "Profile", member_path(current_member)
|
||||
%li= link_to "Gardens", gardens_by_owner_path(:owner => current_member.slug)
|
||||
%li= link_to "Plantings", plantings_by_owner_path(:owner => current_member.slug)
|
||||
%li= link_to "Seeds", seeds_by_owner_path(:owner => current_member.slug)
|
||||
%li= link_to "Posts", posts_by_author_path(:author => current_member.slug)
|
||||
%li= link_to "Account", orders_path
|
||||
%li
|
||||
- if current_member.notifications.unread_count > 0
|
||||
= link_to("Inbox (#{current_member.notifications.unread_count})", notifications_path)
|
||||
- else
|
||||
= link_to("Inbox", notifications_path)
|
||||
|
||||
%li= link_to "Shop", shop_path
|
||||
- if current_member.has_role?(:admin)
|
||||
%li= link_to "Admin", admin_path
|
||||
|
||||
%li= link_to "Sign out", destroy_member_session_path, :method => :delete
|
||||
|
||||
- else
|
||||
%li.pull-right= link_to 'Sign in', new_member_session_path
|
||||
%li.pull-right= link_to 'Sign up', new_member_registration_path
|
||||
%li= link_to 'Sign in', new_member_session_path
|
||||
%li= link_to 'Sign up', new_member_registration_path
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
.container
|
||||
.row
|
||||
.span12
|
||||
- if content_for?(:title)
|
||||
- if content_for?(:title)
|
||||
%h1= yield(:title)
|
||||
- if notice
|
||||
.alert.alert-success
|
||||
|
||||
@@ -1,14 +1,53 @@
|
||||
=content_for :title, "What's been planted recently?"
|
||||
- content_for :title, @owner ? "#{@owner}'s plantings" : "Everyone's plantings"
|
||||
|
||||
%p Here are the latest things planted by #{Growstuff::Application.config.site_name} members.
|
||||
%p
|
||||
- if can? :create, Planting
|
||||
- if @owner
|
||||
%p
|
||||
- if @owner == current_member
|
||||
= link_to 'Plant something', new_planting_path, :class => 'btn btn-primary'
|
||||
= link_to "View everyone's plantings", plantings_path, :class => 'btn'
|
||||
- else # everyone's plantings
|
||||
= link_to 'Plant something', new_planting_path, :class => 'btn btn-primary'
|
||||
- if current_member
|
||||
= link_to 'View your plantings', plantings_by_owner_path(:owner => current_member.slug), :class => 'btn'
|
||||
- else
|
||||
= render :partial => 'shared/signin_signup', :locals => { :to => "track what you've planted" }
|
||||
|
||||
%div.pagination
|
||||
= page_entries_info @plantings, :model => "plantings"
|
||||
= will_paginate @plantings
|
||||
%div.pagination
|
||||
= page_entries_info @plantings, :model => "plantings"
|
||||
= will_paginate @plantings
|
||||
|
||||
- @plantings.each do |p|
|
||||
= render :partial => "plantings/thumbnail", :locals => { :planting => p }
|
||||
- if @plantings.length > 0
|
||||
|
||||
%div.pagination
|
||||
= page_entries_info @plantings, :model => "plantings"
|
||||
= will_paginate @plantings
|
||||
%table.table.table-striped
|
||||
%tr
|
||||
- unless @owner
|
||||
%th Owner
|
||||
%th Crop
|
||||
%th Garden
|
||||
%th Description
|
||||
%th Quantity
|
||||
%th Planted on
|
||||
%th Sun/shade?
|
||||
%th Planted from
|
||||
%th
|
||||
|
||||
- @plantings.each do |planting|
|
||||
%tr
|
||||
- unless @owner
|
||||
%td= link_to planting.owner.login_name, planting.owner
|
||||
%td= link_to planting.crop.system_name, planting.crop
|
||||
%td= link_to planting.garden.name, planting.garden
|
||||
%td
|
||||
:markdown
|
||||
#{ strip_tags planting.description }
|
||||
%td= planting.quantity
|
||||
%td= planting.planted_at
|
||||
%td= planting.sunniness
|
||||
%td= planting.planted_from
|
||||
%td= link_to 'Details', planting, :class => 'btn btn-mini'
|
||||
|
||||
%div.pagination
|
||||
= page_entries_info @plantings, :model => "plantings"
|
||||
= will_paginate @plantings
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
%rss{:version => 2.0}
|
||||
%channel
|
||||
%title #{Growstuff::Application.config.site_name} - Recent plantings from all members
|
||||
%title
|
||||
#{Growstuff::Application.config.site_name} - Recent plantings from #{ @owner ? @owner : 'all members' }
|
||||
%link= plantings_url
|
||||
- @plantings.each do |planting|
|
||||
%item
|
||||
|
||||
@@ -1,14 +1,27 @@
|
||||
= content_for :title, "Recent #{Growstuff::Application.config.site_name} member posts"
|
||||
- content_for :title, @author ? "#{@author}'s posts" : "Everyone's posts"
|
||||
|
||||
%p= link_to 'Post something', new_post_path, :class => 'btn btn-primary'
|
||||
%p
|
||||
- if can? :create, Post
|
||||
- if @author
|
||||
%p
|
||||
- if @author == current_member
|
||||
= link_to 'Post something', new_post_path, :class => 'btn btn-primary'
|
||||
= link_to "View everyone's posts", posts_path, :class => 'btn'
|
||||
- else # everyone's posts
|
||||
= link_to 'Post something', new_post_path, :class => 'btn btn-primary'
|
||||
- if current_member
|
||||
= link_to 'View your posts', posts_by_author_path(:author => current_member.slug), :class => 'btn'
|
||||
- else
|
||||
= render :partial => 'shared/signin_signup', :locals => { :to => 'write a post' }
|
||||
|
||||
%div.pagination
|
||||
= page_entries_info @posts, :model => "posts"
|
||||
= will_paginate @posts
|
||||
|
||||
- @posts.each do |post|
|
||||
= render :partial => "single", :locals => { :post => post, :subject => true }
|
||||
- unless @posts.empty?
|
||||
- @posts.each do |post|
|
||||
= render :partial => "single", :locals => { :post => post, :subject => true }
|
||||
|
||||
%div.pagination
|
||||
= page_entries_info @posts, :model => "posts"
|
||||
= will_paginate @posts
|
||||
%div.pagination
|
||||
= page_entries_info @posts, :model => "posts"
|
||||
= will_paginate @posts
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
%rss{:version => 2.0}
|
||||
%channel
|
||||
%title #{Growstuff::Application.config.site_name} - Recent posts from all members
|
||||
%title
|
||||
#{Growstuff::Application.config.site_name} - Recent posts from #{ @author ? @author : 'all members' }
|
||||
%link= posts_url
|
||||
- @posts.each do |post|
|
||||
%item
|
||||
|
||||
@@ -10,14 +10,20 @@
|
||||
- else # everyone's seeds
|
||||
= link_to 'Add seeds', new_seed_path, :class => 'btn btn-primary'
|
||||
- if current_member
|
||||
= link_to 'View your seeds', seeds_path(:owner_id => current_member.id), :class => 'btn'
|
||||
= link_to 'View your seeds', seeds_by_owner_path(:owner => current_member.slug), :class => 'btn'
|
||||
- else
|
||||
= render :partial => 'shared/signin_signup', :locals => { :to => 'add seeds to your stash' }
|
||||
|
||||
%div.pagination
|
||||
= page_entries_info @seeds, :model => "seeds"
|
||||
= will_paginate @seeds
|
||||
|
||||
- if @seeds.length > 0
|
||||
|
||||
%table.table.table-striped
|
||||
%tr
|
||||
%th Owner
|
||||
- unless @owner
|
||||
%th Owner
|
||||
%th Crop
|
||||
%th Description
|
||||
%th Quantity
|
||||
@@ -28,7 +34,8 @@
|
||||
|
||||
- @seeds.each do |seed|
|
||||
%tr
|
||||
%td= link_to seed.owner.login_name, seed.owner
|
||||
- unless @owner
|
||||
%td= link_to seed.owner.login_name, seed.owner
|
||||
%td= link_to seed.crop.system_name, seed.crop
|
||||
%td= seed.description
|
||||
%td= seed.quantity
|
||||
@@ -38,5 +45,7 @@
|
||||
- if seed.tradable?
|
||||
= seed.owner.location.blank? ? "unspecified" : seed.owner.location
|
||||
%td= link_to 'Details', seed, :class => 'btn btn-mini'
|
||||
- else
|
||||
%p There are no seeds to display.
|
||||
|
||||
%div.pagination
|
||||
= page_entries_info @seeds, :model => "seeds"
|
||||
= will_paginate @seeds
|
||||
|
||||
@@ -4,12 +4,21 @@ Growstuff::Application.routes.draw do
|
||||
resources :members
|
||||
|
||||
resources :photos
|
||||
resources :seeds
|
||||
|
||||
resources :authentications
|
||||
|
||||
resources :plantings
|
||||
match '/plantings/owner/:owner' => 'plantings#index', :as => 'plantings_by_owner'
|
||||
|
||||
resources :gardens
|
||||
match '/gardens/owner/:owner' => 'gardens#index', :as => 'gardens_by_owner'
|
||||
|
||||
resources :seeds
|
||||
match '/seeds/owner/:owner' => 'seeds#index', :as => 'seeds_by_owner'
|
||||
|
||||
resources :posts
|
||||
match '/posts/author/:author' => 'posts#index', :as => 'posts_by_author'
|
||||
|
||||
resources :scientific_names
|
||||
resources :crops
|
||||
resources :comments
|
||||
|
||||
@@ -11,6 +11,14 @@ describe PlantingsController do
|
||||
}
|
||||
end
|
||||
|
||||
describe "GET index" do
|
||||
it "picks up owner from params" do
|
||||
owner = FactoryGirl.create(:member)
|
||||
get :index, {:owner => owner.slug}
|
||||
assigns(:owner).should eq(owner)
|
||||
end
|
||||
end
|
||||
|
||||
describe "GET new" do
|
||||
|
||||
it "picks up crop from params" do
|
||||
|
||||
@@ -4,7 +4,7 @@ describe SeedsController do
|
||||
describe "GET index" do
|
||||
it "picks up owner from params" do
|
||||
owner = FactoryGirl.create(:member)
|
||||
get :index, {:owner_id => owner.id}
|
||||
get :index, {:owner => owner.slug}
|
||||
assigns(:owner).should eq(owner)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -4,10 +4,16 @@ describe "gardens/index" do
|
||||
before(:each) do
|
||||
controller.stub(:current_user) { nil }
|
||||
@owner = FactoryGirl.create(:member)
|
||||
assign(:gardens, [
|
||||
FactoryGirl.create(:garden, :owner => @owner),
|
||||
FactoryGirl.create(:garden, :owner => @owner)
|
||||
])
|
||||
page = 1
|
||||
per_page = 2
|
||||
total_entries = 2
|
||||
gardens = WillPaginate::Collection.create(page, per_page, total_entries) do |pager|
|
||||
pager.replace([
|
||||
FactoryGirl.create(:garden, :owner => @owner),
|
||||
FactoryGirl.create(:garden, :owner => @owner)
|
||||
])
|
||||
end
|
||||
assign(:gardens, gardens)
|
||||
end
|
||||
|
||||
it "renders a list of gardens" do
|
||||
|
||||
90
spec/views/layouts/_header_spec.rb
Normal file
90
spec/views/layouts/_header_spec.rb
Normal file
@@ -0,0 +1,90 @@
|
||||
require 'spec_helper'
|
||||
|
||||
describe 'layouts/_header.html.haml', :type => "view" do
|
||||
context "when not logged in" do
|
||||
before(:each) do
|
||||
controller.stub(:current_user) { nil }
|
||||
render
|
||||
end
|
||||
|
||||
it 'shows the title' do
|
||||
rendered.should contain Growstuff::Application.config.site_name
|
||||
end
|
||||
|
||||
it 'should have signup/signin links' do
|
||||
rendered.should contain 'Sign up'
|
||||
rendered.should contain 'Sign in'
|
||||
end
|
||||
|
||||
it 'has a Crops link' do
|
||||
rendered.should contain "Crops"
|
||||
end
|
||||
|
||||
it 'has a Seeds link' do
|
||||
rendered.should contain "Seeds"
|
||||
end
|
||||
|
||||
it 'has a Community section' do
|
||||
rendered.should contain "Community"
|
||||
end
|
||||
|
||||
it 'links to members' do
|
||||
assert_select("a[href=#{members_path}]", 'Members')
|
||||
end
|
||||
|
||||
it 'links to posts' do
|
||||
assert_select("a[href=#{posts_path}]", 'Posts')
|
||||
end
|
||||
|
||||
it 'links to forums' do
|
||||
assert_select("a[href=#{forums_path}]", 'Forums')
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
context "logged in" do
|
||||
|
||||
before(:each) do
|
||||
@member = FactoryGirl.create(:member)
|
||||
sign_in @member
|
||||
controller.stub(:current_user) { @member }
|
||||
render
|
||||
end
|
||||
|
||||
context "your stuff" do
|
||||
it 'should have a Your Stuff section' do
|
||||
rendered.should contain "Your Stuff"
|
||||
end
|
||||
it "should show link to member's gardens" do
|
||||
assert_select("a[href=#{gardens_by_owner_path(:owner => @member.slug)}]", "Gardens")
|
||||
end
|
||||
it "should show link to member's plantings" do
|
||||
assert_select("a[href=#{plantings_by_owner_path(:owner => @member.slug)}]", "Plantings")
|
||||
end
|
||||
it "should show link to member's seeds" do
|
||||
assert_select("a[href=#{seeds_by_owner_path(:owner => @member.slug)}]", "Seeds")
|
||||
end
|
||||
it "should show link to member's posts" do
|
||||
assert_select("a[href=#{posts_by_author_path(:author => @member.slug)}]", "Posts")
|
||||
end
|
||||
end
|
||||
|
||||
it 'should show signout link' do
|
||||
rendered.should contain 'Sign out'
|
||||
end
|
||||
|
||||
it 'should show inbox link' do
|
||||
rendered.should contain 'Inbox'
|
||||
rendered.should_not match(/Inbox \(\d+\)/)
|
||||
end
|
||||
|
||||
context 'has notifications' do
|
||||
it 'should show inbox count' do
|
||||
FactoryGirl.create(:notification, :recipient => @member)
|
||||
render
|
||||
rendered.should contain 'Inbox (1)'
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
@@ -1,72 +1,15 @@
|
||||
require 'spec_helper'
|
||||
|
||||
describe 'layouts/application.html.haml', :type => "view" do
|
||||
context "when not logged in" do
|
||||
|
||||
before(:each) do
|
||||
controller.stub(:current_user) { nil }
|
||||
render
|
||||
end
|
||||
|
||||
it 'shows the title' do
|
||||
rendered.should contain Growstuff::Application.config.site_name
|
||||
end
|
||||
|
||||
it 'should have signup/login links' do
|
||||
rendered.should contain 'Sign up'
|
||||
rendered.should contain 'Sign in'
|
||||
end
|
||||
|
||||
before(:each) do
|
||||
controller.stub(:current_user) { nil }
|
||||
end
|
||||
|
||||
context "logged in" do
|
||||
|
||||
before(:each) do
|
||||
@member = FactoryGirl.create(:member)
|
||||
sign_in @member
|
||||
controller.stub(:current_user) { @member }
|
||||
render
|
||||
end
|
||||
|
||||
it 'should show login name' do
|
||||
rendered.should contain /member\d+/
|
||||
end
|
||||
|
||||
it "should show member's name" do
|
||||
assert_select("a[href=/members/#{@member.login_name}]", "Profile")
|
||||
end
|
||||
|
||||
it "should show settings link" do
|
||||
assert_select "a[href=/members/edit]", "Settings"
|
||||
end
|
||||
|
||||
it "should show settings link" do
|
||||
assert_select "a[href=#{orders_path}]", "Account"
|
||||
end
|
||||
|
||||
it 'should show logout link' do
|
||||
rendered.should contain 'Sign out'
|
||||
end
|
||||
|
||||
it 'should show inbox link' do
|
||||
rendered.should contain 'Inbox'
|
||||
rendered.should_not match(/Inbox \(\d+\)/)
|
||||
end
|
||||
|
||||
context 'has notifications' do
|
||||
it 'should show inbox count' do
|
||||
FactoryGirl.create(:notification, :recipient => @member)
|
||||
render
|
||||
rendered.should contain 'Inbox (1)'
|
||||
end
|
||||
end
|
||||
|
||||
it 'includes the analytics code' do
|
||||
Growstuff::Application.config.analytics_code = '<script>alert("foo!")</script>'
|
||||
render
|
||||
assert_select "script", :text => 'alert("foo!")'
|
||||
rendered.should_not contain 'script'
|
||||
end
|
||||
|
||||
it 'includes the analytics code' do
|
||||
Growstuff::Application.config.analytics_code = '<script>alert("foo!")</script>'
|
||||
render
|
||||
assert_select "script", :text => 'alert("foo!")'
|
||||
rendered.should_not contain 'script'
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -31,7 +31,8 @@ describe "plantings/index" do
|
||||
it "renders a list of plantings" do
|
||||
rendered.should contain 'Tomato'
|
||||
rendered.should contain 'Maize'
|
||||
rendered.should contain /member\d+'s Springfield Community Garden/
|
||||
rendered.should contain @member.login_name
|
||||
rendered.should contain @garden.name
|
||||
end
|
||||
|
||||
it "shows descriptions where they exist" do
|
||||
@@ -42,8 +43,4 @@ describe "plantings/index" do
|
||||
rendered.should contain 'January 13, 2013'
|
||||
end
|
||||
|
||||
it "renders markdown in the description" do
|
||||
assert_select "em", "really"
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -3,10 +3,10 @@ require 'spec_helper'
|
||||
describe 'posts/index.rss.haml', :type => "view" do
|
||||
before(:each) do
|
||||
controller.stub(:current_user) { nil }
|
||||
@author = FactoryGirl.create(:member)
|
||||
author = FactoryGirl.create(:member)
|
||||
assign(:posts, [
|
||||
FactoryGirl.build(:post, :id => 1, :author => @author),
|
||||
FactoryGirl.build(:post, :id => 2, :author => @author)
|
||||
FactoryGirl.build(:post, :id => 1, :author => author),
|
||||
FactoryGirl.build(:post, :id => 2, :author => author)
|
||||
])
|
||||
render
|
||||
end
|
||||
|
||||
@@ -6,7 +6,13 @@ describe "seeds/index" do
|
||||
sign_in @member
|
||||
controller.stub(:current_user) { @member }
|
||||
@seed1 = FactoryGirl.create(:seed, :owner => @member)
|
||||
assign(:seeds, [@seed1, @seed1])
|
||||
@page = 1
|
||||
@per_page = 2
|
||||
@total_entries = 2
|
||||
seeds = WillPaginate::Collection.create(@page, @per_page, @total_entries) do |pager|
|
||||
pager.replace([ @seed1, @seed1 ])
|
||||
end
|
||||
assign(:seeds, seeds)
|
||||
end
|
||||
|
||||
it "renders a list of seeds" do
|
||||
@@ -20,7 +26,10 @@ describe "seeds/index" do
|
||||
before(:each) do
|
||||
@owner = FactoryGirl.create(:london_member)
|
||||
@seed1 = FactoryGirl.create(:tradable_seed, :owner => @owner)
|
||||
assign(:seeds, [@seed1, @seed1])
|
||||
seeds = WillPaginate::Collection.create(@page, @per_page, @total_entries) do |pager|
|
||||
pager.replace([ @seed1, @seed1 ])
|
||||
end
|
||||
assign(:seeds, seeds)
|
||||
render
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user