mirror of
https://github.com/Growstuff/growstuff.git
synced 2026-10-26 08:48:28 -04:00
Merge branch 'dev' into payments-new
This commit is contained in:
commit
dd556d8638
41 files changed
+424
-151
No files matched your search
+3
-1
@@ -6,4 +6,6 @@
|
||||
*~
|
||||
*.DS_Store
|
||||
credentials.sh
|
||||
Pathogen:
|
||||
Pathogen:
|
||||
custom_plan.rb
|
||||
zeus.json
|
||||
@@ -0,0 +1,39 @@
|
||||
This is a list of contributors to Growstuff's codebase. We maintain
|
||||
this list because we work in pairs, but Github only knows about the
|
||||
person who actually does the commits. This gives credit to both members
|
||||
of the pair.
|
||||
|
||||
If you contribute, please add yourself to the bottom of the list and
|
||||
submit the change with your pull request.
|
||||
|
||||
## Committers
|
||||
|
||||
- Alex Bayley / [Skud](https://github.com/Skud)
|
||||
- Cesy / [cesy](https://github.com/cesy)
|
||||
- Miles Gould / [pozorvlak](https://github.com/pozorvlak)
|
||||
- Joseph Caudle / [jcaudle](https://github.com/jcaudle)
|
||||
|
||||
## Contributors
|
||||
|
||||
- Ricky Amianym / [amianym](https://github.com/amianym)
|
||||
- Juliet Kemp / [julietk](https://github.com/julietk)
|
||||
- Federico Mena Quintero / [federicomenaquintero](https://github.com/federicomenaquintero)
|
||||
- Jay Springett / [thejaymo](https://github.com/thejaymo)
|
||||
- Maia Sauren / [sauramaia](https://github.com/sauramaia)
|
||||
- Norman Ancajas / [nbancajas](https://github.com/nbancajas)
|
||||
- Jonathan "Duke" Leto / [leto](https://github.com/leto)
|
||||
- Mackenzie Morgan / [maco](https://github.com/maco)
|
||||
- Amy Hendrix / [sabreuse](https://github.com/sabreuse)
|
||||
- CephLPod / [cephLpod](https://github.com/cephLpod/)
|
||||
- Gemma Mason / [gemmaellen](https://github.com/gemmaellen)
|
||||
- Courtney Webster / [phazel](https://github.com/phazel/)
|
||||
- Cathy Sullivan / [cesullivan](https://github.com/cesullivan)
|
||||
- Jared McCorkindale / [jmcorkindale](https://github.com/jmcorkindale)
|
||||
- Florian Vallen / [flov](https://github.com/flov)
|
||||
- Samuel Cochrane / [sj26](https://github.com/sj26)
|
||||
- Craig Read / [Catharz](https://github.com/Catharz)
|
||||
- Ju Transcendancing / [transcendancing](https://github.com/transcendancing)
|
||||
- Lillian Ryan / [attlebish](https://github.com/attlebish)
|
||||
- Gary Traffanstedt / [blimey85](https://github.com/blimey85)
|
||||
- Yaw Boakye / [yawboakye](https://github.com/yawboakye)
|
||||
- Ryan Clark / [IAMRYO](https://github.com/IAMRYO)
|
||||
@@ -2,12 +2,12 @@ class CommentsController < ApplicationController
|
||||
# GET /comments
|
||||
# GET /comments.json
|
||||
def index
|
||||
@comments = Comment.all
|
||||
@recent_comments = Comment.limit(100).order('created_at desc').all
|
||||
@comments = Comment.paginate(:page => params[:page])
|
||||
|
||||
respond_to do |format|
|
||||
format.html # index.html.erb
|
||||
format.json { render json: @comments }
|
||||
format.rss { render :layout => false }
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -5,7 +5,6 @@ class CropsController < ApplicationController
|
||||
# GET /crops.json
|
||||
def index
|
||||
@crops = Crop.paginate(:page => params[:page])
|
||||
@new_crops = Crop.limit(20).order('created_at desc').all
|
||||
|
||||
respond_to do |format|
|
||||
format.html # index.html.haml
|
||||
|
||||
@@ -3,8 +3,7 @@ class PlantingsController < ApplicationController
|
||||
# GET /plantings
|
||||
# GET /plantings.json
|
||||
def index
|
||||
@plantings = Planting.all
|
||||
@recent_plantings = Planting.limit(100).order('created_at desc').all
|
||||
@plantings = Planting.paginate(:page => params[:page])
|
||||
|
||||
respond_to do |format|
|
||||
format.html # index.html.erb
|
||||
|
||||
@@ -5,7 +5,6 @@ class PostsController < ApplicationController
|
||||
|
||||
def index
|
||||
@posts = Post.paginate(:page => params[:page])
|
||||
@recent_posts = Post.limit(100).order('created_at desc').all
|
||||
|
||||
respond_to do |format|
|
||||
format.html # index.html.haml
|
||||
@@ -23,6 +22,10 @@ class PostsController < ApplicationController
|
||||
respond_to do |format|
|
||||
format.html # show.html.haml
|
||||
format.json { render json: @post }
|
||||
format.rss { render(
|
||||
:layout => false,
|
||||
:locals => { :post => @post }
|
||||
)}
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -3,7 +3,8 @@ class Comment < ActiveRecord::Base
|
||||
belongs_to :author, :class_name => 'Member'
|
||||
belongs_to :post
|
||||
|
||||
default_scope order("created_at asc")
|
||||
default_scope order("created_at DESC")
|
||||
scope :post_order, reorder("created_at ASC") # for display on post page
|
||||
|
||||
after_create do
|
||||
recipient = self.post.author.id
|
||||
|
||||
@@ -1,8 +1,3 @@
|
||||
= render :partial => "posts/single", :locals => { :post => @post || @comment.post, :subject => true }
|
||||
|
||||
= render :partial => "posts/comments"
|
||||
|
||||
%h2 Your comment
|
||||
= form_for @comment do |f|
|
||||
- if @comment.errors.any?
|
||||
#error_explanation
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
= content_for :title, "Editing comment"
|
||||
|
||||
%p
|
||||
Editing comment on
|
||||
= link_to @comment.post.subject, @comment.post
|
||||
|
||||
= render 'form'
|
||||
@@ -1,7 +1,15 @@
|
||||
= content_for :title, "Recent comments"
|
||||
|
||||
- @recent_comments.each do |comment|
|
||||
%div.pagination
|
||||
= page_entries_info @comments, :model => "comments"
|
||||
= will_paginate @comments
|
||||
|
||||
- @comments.each do |comment|
|
||||
%h2
|
||||
Comment on
|
||||
= link_to comment.post.subject, comment.post
|
||||
= render :partial => "single", :locals => { :comment => comment }
|
||||
|
||||
%div.pagination
|
||||
= page_entries_info @comments, :model => "comments"
|
||||
= will_paginate @comments
|
||||
@@ -0,0 +1,23 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
%rss{:version => 2.0}
|
||||
%channel
|
||||
%title #{Growstuff::Application.config.site_name} - Recent comments on all posts
|
||||
%link= comments_url
|
||||
- @comments.each do |comment|
|
||||
%item
|
||||
%title Comment by #{comment.author.login_name} on #{comment.post.subject}
|
||||
%author= comment.author.login_name
|
||||
%description
|
||||
|
||||
:escaped
|
||||
<p>
|
||||
Comment on
|
||||
#{ link_to comment.post.subject, post_url(comment.post) }
|
||||
</p>
|
||||
|
||||
:escaped_markdown
|
||||
#{ strip_tags comment.body }
|
||||
|
||||
%pubDate= comment.created_at.to_s(:rfc822)
|
||||
%link= post_url(comment.post)
|
||||
%guid= post_url(comment.post)
|
||||
@@ -1,3 +1,9 @@
|
||||
= content_for :title, "New comment"
|
||||
|
||||
= render :partial => "posts/single", :locals => { :post => @post || @comment.post, :subject => true }
|
||||
|
||||
= render :partial => "posts/comments", :locals => {:post => @post || @comment.post}
|
||||
|
||||
%p Your comment:
|
||||
|
||||
= render 'form'
|
||||
@@ -1,16 +0,0 @@
|
||||
xml.instruct! :xml, :version => "1.0"
|
||||
xml.rss :version => "2.0" do
|
||||
xml.channel do
|
||||
xml.title "#{Growstuff::Application.config.site_name} - Recently added crops"
|
||||
xml.link crops_url
|
||||
|
||||
for crop in @new_crops
|
||||
xml.item do
|
||||
xml.title crop.system_name
|
||||
xml.pubDate crop.created_at.to_s(:rfc822)
|
||||
xml.link crop_url(crop)
|
||||
xml.guid crop_url(crop)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,11 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
%rss{:version => 2.0}
|
||||
%channel
|
||||
%title #{Growstuff::Application.config.site_name} - Recently added crops
|
||||
%link= crops_url
|
||||
- @crops.each do |crop|
|
||||
%item
|
||||
%title= crop.system_name
|
||||
%pubDate= crop.created_at.to_s(:rfc822)
|
||||
%link= post_url(crop)
|
||||
%guid= post_url(crop)
|
||||
@@ -74,7 +74,7 @@
|
||||
|
||||
%div
|
||||
:markdown
|
||||
#{g.description}
|
||||
#{ strip_tags g.description }
|
||||
|
||||
%h3 What's planted here?
|
||||
- g.featured_plantings.each do |p|
|
||||
|
||||
@@ -1,18 +0,0 @@
|
||||
xml.instruct! :xml, :version => "1.0"
|
||||
xml.rss :version => "2.0" do
|
||||
xml.channel do
|
||||
xml.title "#{Growstuff::Application.config.site_name} - #{@member.login_name}'s recent posts"
|
||||
xml.link member_url(@member)
|
||||
|
||||
for post in @posts
|
||||
xml.item do
|
||||
xml.author @member.login_name
|
||||
xml.title post.subject
|
||||
xml.description post.body
|
||||
xml.pubDate post.created_at.to_s(:rfc822)
|
||||
xml.link post_url(post)
|
||||
xml.guid post_url(post)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,15 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
%rss{:version => 2.0}
|
||||
%channel
|
||||
%title #{Growstuff::Application.config.site_name} - #{@member.login_name}'s recent posts
|
||||
%link= member_url(@member)
|
||||
- @posts.each do |post|
|
||||
%item
|
||||
%pubDate= post.created_at.to_s(:rfc822)
|
||||
%link= post_url(post)
|
||||
%guid= post_url(post)
|
||||
%author= @member.login_name
|
||||
%title= post.subject
|
||||
%description
|
||||
:escaped_markdown
|
||||
#{ strip_tags post.body }
|
||||
@@ -2,7 +2,13 @@
|
||||
|
||||
%p Here are the latest things planted by #{Growstuff::Application.config.site_name} members.
|
||||
|
||||
- @recent_plantings.each do |p|
|
||||
%div.pagination
|
||||
= page_entries_info @plantings, :model => "plantings"
|
||||
= will_paginate @plantings
|
||||
|
||||
- @plantings.each do |p|
|
||||
= render :partial => "plantings/thumbnail", :locals => { :planting => p }
|
||||
|
||||
|
||||
%div.pagination
|
||||
= page_entries_info @plantings, :model => "plantings"
|
||||
= will_paginate @plantings
|
||||
@@ -1,18 +0,0 @@
|
||||
xml.instruct! :xml, :version => "1.0"
|
||||
xml.rss :version => "2.0" do
|
||||
xml.channel do
|
||||
xml.title "#{Growstuff::Application.config.site_name} - Recent plantings from all members"
|
||||
xml.link plantings_url
|
||||
|
||||
for planting in @recent_plantings
|
||||
xml.item do
|
||||
xml.author planting.owner.login_name
|
||||
xml.title planting.crop.system_name
|
||||
xml.pubDate planting.created_at.to_s(:rfc822)
|
||||
xml.description planting.description
|
||||
xml.link planting_url(planting)
|
||||
xml.guid planting_url(planting)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,15 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
%rss{:version => 2.0}
|
||||
%channel
|
||||
%title #{Growstuff::Application.config.site_name} - Recent plantings from all members
|
||||
%link= plantings_url
|
||||
- @plantings.each do |planting|
|
||||
%item
|
||||
%author= planting.owner.login_name
|
||||
%title= planting.crop.system_name
|
||||
%pubDate= planting.created_at.to_s(:rfc822)
|
||||
%description
|
||||
:escaped_markdown
|
||||
#{ strip_tags planting.description }
|
||||
%link= planting_url(planting)
|
||||
%guid= planting_url(planting)
|
||||
@@ -1,8 +1,8 @@
|
||||
%a{:name => "comments"}
|
||||
- if @comments
|
||||
- if post.comments
|
||||
%h2
|
||||
=pluralize(@comments.length, "comment")
|
||||
- @comments.each do |c|
|
||||
=pluralize(post.comments.length, "comment")
|
||||
- post.comments.post_order.each do |c|
|
||||
= render :partial => "comments/single", :locals => { :comment => c }
|
||||
|
||||
- else
|
||||
|
||||
@@ -1,18 +0,0 @@
|
||||
xml.instruct! :xml, :version => "1.0"
|
||||
xml.rss :version => "2.0" do
|
||||
xml.channel do
|
||||
xml.title "#{Growstuff::Application.config.site_name} - Recent posts from all members"
|
||||
xml.link posts_url
|
||||
|
||||
for post in @recent_posts
|
||||
xml.item do
|
||||
xml.author post.author.login_name
|
||||
xml.title post.subject
|
||||
xml.description post.body
|
||||
xml.pubDate post.created_at.to_s(:rfc822)
|
||||
xml.link post_url(post)
|
||||
xml.guid post_url(post)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,15 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
%rss{:version => 2.0}
|
||||
%channel
|
||||
%title #{Growstuff::Application.config.site_name} - Recent posts from all members
|
||||
%link= posts_url
|
||||
- @posts.each do |post|
|
||||
%item
|
||||
%author= post.author.login_name
|
||||
%title= post.subject
|
||||
%description
|
||||
:escaped_markdown
|
||||
#{ strip_tags post.body }
|
||||
%pubDate= post.created_at.to_s(:rfc822)
|
||||
%link= post_url(post)
|
||||
%guid= post_url(post)
|
||||
@@ -0,0 +1,23 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
%rss{:version => 2.0}
|
||||
%channel
|
||||
%title #{Growstuff::Application.config.site_name} - Recent comments on #{@post.subject}
|
||||
%link= post_url(@post)
|
||||
- @post.comments.each do |comment|
|
||||
%item
|
||||
%title Comment by #{comment.author.login_name} on #{comment.created_at.to_s}
|
||||
%author= comment.author.login_name
|
||||
%description
|
||||
|
||||
:escaped
|
||||
<p>
|
||||
Comment on
|
||||
#{ link_to @post.subject, post_url(@post) }
|
||||
</p>
|
||||
|
||||
:escaped_markdown
|
||||
#{ strip_tags comment.body }
|
||||
|
||||
%pubDate= comment.created_at.to_s(:rfc822)
|
||||
%link= post_url(@post)
|
||||
%guid= post_url(@post)
|
||||
@@ -0,0 +1 @@
|
||||
require 'haml/filters/escaped_markdown'
|
||||
@@ -0,0 +1,17 @@
|
||||
require 'bluecloth'
|
||||
|
||||
module Haml::Filters
|
||||
module EscapedMarkdown
|
||||
include Haml::Filters::Base
|
||||
|
||||
def render(text)
|
||||
bc = BlueCloth.new(text)
|
||||
return Haml::Helpers.html_escape bc.to_html
|
||||
end
|
||||
end
|
||||
|
||||
# Register it as the handler for the :escaped_markdown HAML command.
|
||||
# The automatic system gives us :escapedmarkdown, which is ugly.
|
||||
defined['escaped_markdown'] = EscapedMarkdown
|
||||
|
||||
end
|
||||
@@ -14,7 +14,15 @@ describe CommentsController do
|
||||
comment = Comment.create! valid_attributes
|
||||
get :index, {}
|
||||
assigns(:comments).should eq([comment])
|
||||
assigns(:recent_comments).should eq([comment])
|
||||
end
|
||||
end
|
||||
|
||||
describe "GET RSS feed" do
|
||||
it "returns an RSS feed" do
|
||||
get :index, :format => "rss"
|
||||
response.should be_success
|
||||
response.should render_template("comments/index")
|
||||
response.content_type.should eq("application/rss+xml")
|
||||
end
|
||||
end
|
||||
|
||||
@@ -63,7 +71,7 @@ describe CommentsController do
|
||||
old_comment = FactoryGirl.create(:comment, :post => post)
|
||||
comment = FactoryGirl.create(:comment, :post => post)
|
||||
get :edit, {:id => comment.to_param}
|
||||
assigns(:comments).should eq([old_comment, comment])
|
||||
assigns(:comments).should eq([comment, old_comment])
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -16,7 +16,6 @@ describe CropsController do
|
||||
crop = Crop.create! valid_attributes
|
||||
get :index, {}
|
||||
assigns(:crops).should eq([crop])
|
||||
assigns(:new_crops).should eq([crop])
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -16,7 +16,6 @@ describe PlantingsController do
|
||||
planting = Planting.create! valid_attributes
|
||||
get :index, {}
|
||||
assigns(:plantings).should eq([planting])
|
||||
assigns(:recent_plantings).should eq([planting])
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -13,7 +13,6 @@ describe PostsController do
|
||||
post = Post.create! valid_attributes
|
||||
get :index, {}
|
||||
assigns(:posts).should eq([post])
|
||||
assigns(:recent_posts).should eq([post])
|
||||
end
|
||||
end
|
||||
|
||||
@@ -34,6 +33,16 @@ describe PostsController do
|
||||
end
|
||||
end
|
||||
|
||||
describe "GET RSS feed for individual post" do
|
||||
it "returns an RSS feed" do
|
||||
post = Post.create! valid_attributes
|
||||
get :show, { :format => "rss", :id => post.slug }
|
||||
response.should be_success
|
||||
response.should render_template("posts/show")
|
||||
response.content_type.should eq("application/rss+xml")
|
||||
end
|
||||
end
|
||||
|
||||
describe "GET new" do
|
||||
it "assigns a new post as @post" do
|
||||
get :new, {}
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
require 'haml/filters'
|
||||
require 'haml/filters/escaped_markdown'
|
||||
require 'haml/helpers'
|
||||
|
||||
describe 'Haml::Filters::Escaped_Markdown' do
|
||||
it 'is registered as the handler for :escaped_markdown' do
|
||||
Haml::Filters::defined['escaped_markdown'].should ==
|
||||
Haml::Filters::EscapedMarkdown
|
||||
end
|
||||
|
||||
it 'converts Markdown to escaped HTML' do
|
||||
rendered = Haml::Filters::EscapedMarkdown.render("**foo**")
|
||||
rendered.should == "<p><strong>foo</strong></p>"
|
||||
end
|
||||
|
||||
end
|
||||
+53
-28
@@ -2,40 +2,65 @@ require 'spec_helper'
|
||||
|
||||
describe Comment do
|
||||
|
||||
before(:each) do
|
||||
@comment = FactoryGirl.create(:comment)
|
||||
context "basic" do
|
||||
before(:each) do
|
||||
@comment = FactoryGirl.create(:comment)
|
||||
end
|
||||
|
||||
it "belongs to a post" do
|
||||
@comment.post.should be_an_instance_of Post
|
||||
end
|
||||
|
||||
it "belongs to an author" do
|
||||
@comment.author.should be_an_instance_of Member
|
||||
end
|
||||
end
|
||||
|
||||
it "belongs to a post" do
|
||||
@comment.post.should be_an_instance_of Post
|
||||
context "notifications" do
|
||||
before(:each) do
|
||||
@comment = FactoryGirl.create(:comment)
|
||||
end
|
||||
|
||||
it "sends a notification when a comment is posted" do
|
||||
expect {
|
||||
FactoryGirl.create(:comment)
|
||||
}.to change(Notification, :count).by(1)
|
||||
end
|
||||
|
||||
it "sets the notification fields" do
|
||||
@c = FactoryGirl.create(:comment)
|
||||
@n = Notification.first
|
||||
@n.sender.should eq @c.author
|
||||
@n.recipient.should eq @c.post.author
|
||||
@n.subject.should match /commented on/
|
||||
@n.body.should eq @c.body
|
||||
@n.post.should eq @c.post
|
||||
end
|
||||
|
||||
it "doesn't send notifications to yourself" do
|
||||
@m = FactoryGirl.create(:member)
|
||||
@p = FactoryGirl.create(:post, :author => @m)
|
||||
expect {
|
||||
FactoryGirl.create(:comment, :post => @p, :author => @m)
|
||||
}.to change(Notification, :count).by(0)
|
||||
end
|
||||
end
|
||||
|
||||
it "belongs to an author" do
|
||||
@comment.author.should be_an_instance_of Member
|
||||
end
|
||||
context "ordering" do
|
||||
before(:each) do
|
||||
@m = FactoryGirl.create(:member)
|
||||
@p = FactoryGirl.create(:post, :author => @m)
|
||||
@c1 = FactoryGirl.create(:comment, :post => @p, :author => @m)
|
||||
@c2 = FactoryGirl.create(:comment, :post => @p, :author => @m)
|
||||
end
|
||||
|
||||
it "sends a notification when a comment is posted" do
|
||||
expect {
|
||||
FactoryGirl.create(:comment)
|
||||
}.to change(Notification, :count).by(1)
|
||||
end
|
||||
it 'is in DESC order by default' do
|
||||
Comment.all.should eq [@c2, @c1]
|
||||
end
|
||||
|
||||
it "sets the notification fields" do
|
||||
@c = FactoryGirl.create(:comment)
|
||||
@n = Notification.first
|
||||
@n.sender.should eq @c.author
|
||||
@n.recipient.should eq @c.post.author
|
||||
@n.subject.should match /commented on/
|
||||
@n.body.should eq @c.body
|
||||
@n.post.should eq @c.post
|
||||
end
|
||||
|
||||
it "doesn't send notifications to yourself" do
|
||||
@m = FactoryGirl.create(:member)
|
||||
@p = FactoryGirl.create(:post, :author => @m)
|
||||
expect {
|
||||
FactoryGirl.create(:comment, :post => @p, :author => @m)
|
||||
}.to change(Notification, :count).by(0)
|
||||
it 'has a scope for ASC order for displaying on post page' do
|
||||
Comment.post_order.should eq [@c1, @c2]
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
@@ -3,10 +3,17 @@ require 'spec_helper'
|
||||
describe "comments/index" do
|
||||
before(:each) do
|
||||
controller.stub(:current_user) { nil }
|
||||
assign(:recent_comments, [
|
||||
FactoryGirl.create(:comment),
|
||||
FactoryGirl.create(:comment, :body => 'ROFL')
|
||||
])
|
||||
page = 1
|
||||
per_page = 2
|
||||
total_entries = 2
|
||||
comments = WillPaginate::Collection.create(page, per_page, total_entries) do |pager|
|
||||
pager.replace([
|
||||
FactoryGirl.create(:comment),
|
||||
FactoryGirl.create(:comment, :body => 'ROFL')
|
||||
])
|
||||
end
|
||||
assign(:comments, comments)
|
||||
render
|
||||
end
|
||||
|
||||
it "renders a list of comments" do
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
require 'spec_helper'
|
||||
|
||||
describe 'comments/index.rss.haml' do
|
||||
before(:each) do
|
||||
controller.stub(:current_user) { nil }
|
||||
@author = FactoryGirl.create(:member)
|
||||
@post = FactoryGirl.create(:post)
|
||||
assign(:comments, [
|
||||
FactoryGirl.create(:comment, :author => @author, :post => @post),
|
||||
FactoryGirl.create(:comment, :author => @author, :post => @post)
|
||||
])
|
||||
render
|
||||
end
|
||||
|
||||
it 'shows RSS feed title' do
|
||||
rendered.should contain "Recent comments on all posts"
|
||||
end
|
||||
|
||||
it 'shows item title' do
|
||||
rendered.should contain "Comment by #{@author.login_name}"
|
||||
end
|
||||
|
||||
it 'escapes html for link to post' do
|
||||
# it's then unescaped by 'render' so we don't actually look for <
|
||||
rendered.should contain '<a href='
|
||||
end
|
||||
|
||||
it 'shows content of comments' do
|
||||
rendered.should contain "OMG LOL"
|
||||
end
|
||||
|
||||
end
|
||||
@@ -4,9 +4,9 @@ describe "comments/new" do
|
||||
before(:each) do
|
||||
controller.stub(:current_user) { nil }
|
||||
@post = FactoryGirl.create(:post)
|
||||
@previous_comment = FactoryGirl.create(:comment, :post => @post)
|
||||
assign(:comment, FactoryGirl.create(:comment, :post => @post))
|
||||
assign(:comments, [@previous_comment])
|
||||
@comment = FactoryGirl.create(:comment, :post => @post)
|
||||
assign(:comment, @comment)
|
||||
assign(:comments, [@comment])
|
||||
render
|
||||
end
|
||||
|
||||
@@ -15,7 +15,7 @@ describe "comments/new" do
|
||||
end
|
||||
|
||||
it "shows previous comments" do
|
||||
rendered.should contain @previous_comment.body
|
||||
rendered.should contain @comment.body
|
||||
end
|
||||
|
||||
it "shows the correct comment count" do
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
require 'spec_helper'
|
||||
|
||||
describe 'crops/index.rss.haml' do
|
||||
before(:each) do
|
||||
controller.stub(:current_user) { nil }
|
||||
@author = FactoryGirl.create(:member)
|
||||
assign(:crops, [
|
||||
FactoryGirl.create(:tomato),
|
||||
FactoryGirl.create(:maize)
|
||||
])
|
||||
render
|
||||
end
|
||||
|
||||
it 'shows RSS feed title' do
|
||||
rendered.should contain "Recently added crops"
|
||||
end
|
||||
|
||||
it 'shows names of crops' do
|
||||
rendered.should contain "Tomato"
|
||||
rendered.should contain "Maize"
|
||||
end
|
||||
|
||||
end
|
||||
+8
-2
@@ -1,11 +1,11 @@
|
||||
require 'spec_helper'
|
||||
|
||||
describe 'members/show.rss.builder', :type => "view" do
|
||||
describe 'members/show.rss.haml', :type => "view" do
|
||||
before(:each) do
|
||||
@member = assign(:member, FactoryGirl.create(:member))
|
||||
assign(:posts, [
|
||||
FactoryGirl.build(:post, :id => 1, :author => @member),
|
||||
FactoryGirl.build(:post, :id => 2, :author => @member)
|
||||
FactoryGirl.build(:markdown_post, :id => 2, :author => @member)
|
||||
])
|
||||
render
|
||||
end
|
||||
@@ -18,4 +18,10 @@ describe 'members/show.rss.builder', :type => "view" do
|
||||
rendered.should contain "This is some text."
|
||||
end
|
||||
|
||||
it 'renders post bodies to HTML and XML-escapes them' do
|
||||
# The variable "rendered" has been entity-replaced and tag-stripped
|
||||
# The literal string output contains "<strong>" etc.
|
||||
rendered.should contain "<strong>strong</strong>"
|
||||
end
|
||||
|
||||
end
|
||||
@@ -7,18 +7,24 @@ describe "plantings/index" do
|
||||
@garden = FactoryGirl.create(:garden, :owner => @member)
|
||||
@tomato = FactoryGirl.create(:tomato)
|
||||
@maize = FactoryGirl.create(:maize)
|
||||
assign(:recent_plantings, [
|
||||
FactoryGirl.create(:planting,
|
||||
:garden => @garden,
|
||||
:crop => @tomato
|
||||
),
|
||||
FactoryGirl.create(:planting,
|
||||
:garden => @garden,
|
||||
:crop => @maize,
|
||||
:description => '',
|
||||
:planted_at => Time.local(2013, 1, 13)
|
||||
)
|
||||
])
|
||||
page = 1
|
||||
per_page = 2
|
||||
total_entries = 2
|
||||
plantings = WillPaginate::Collection.create(page, per_page, total_entries) do |pager|
|
||||
pager.replace([
|
||||
FactoryGirl.create(:planting,
|
||||
:garden => @garden,
|
||||
:crop => @tomato
|
||||
),
|
||||
FactoryGirl.create(:planting,
|
||||
:garden => @garden,
|
||||
:crop => @maize,
|
||||
:description => '',
|
||||
:planted_at => Time.local(2013, 1, 13)
|
||||
)
|
||||
])
|
||||
end
|
||||
assign(:plantings, plantings)
|
||||
render
|
||||
end
|
||||
|
||||
|
||||
+4
-4
@@ -1,9 +1,9 @@
|
||||
require 'spec_helper'
|
||||
|
||||
describe 'plantings/index.rss.builder', :type => "view" do
|
||||
describe 'plantings/index.rss.haml' do
|
||||
before(:each) do
|
||||
controller.stub(:current_user) { nil }
|
||||
assign(:recent_plantings, [
|
||||
assign(:plantings, [
|
||||
FactoryGirl.create(:planting)
|
||||
])
|
||||
render
|
||||
@@ -13,8 +13,8 @@ describe 'plantings/index.rss.builder', :type => "view" do
|
||||
rendered.should contain "Recent plantings from all members"
|
||||
end
|
||||
|
||||
it 'shows content of posts' do
|
||||
rendered.should contain "This is a *really* good plant."
|
||||
it 'shows formatted content of posts' do
|
||||
rendered.should contain "This is a <em>really</em> good plant."
|
||||
end
|
||||
|
||||
end
|
||||
+2
-2
@@ -1,10 +1,10 @@
|
||||
require 'spec_helper'
|
||||
|
||||
describe 'posts/index.rss.builder', :type => "view" do
|
||||
describe 'posts/index.rss.haml', :type => "view" do
|
||||
before(:each) do
|
||||
controller.stub(:current_user) { nil }
|
||||
@author = FactoryGirl.create(:member)
|
||||
assign(:recent_posts, [
|
||||
assign(:posts, [
|
||||
FactoryGirl.build(:post, :id => 1, :author => @author),
|
||||
FactoryGirl.build(:post, :id => 2, :author => @author)
|
||||
])
|
||||
@@ -0,0 +1,31 @@
|
||||
require 'spec_helper'
|
||||
|
||||
describe 'posts/show.rss.haml' do
|
||||
before(:each) do
|
||||
controller.stub(:current_user) { nil }
|
||||
@author = FactoryGirl.create(:member)
|
||||
@post = FactoryGirl.create(:post)
|
||||
FactoryGirl.create(:comment, :author => @author, :post => @post)
|
||||
FactoryGirl.create(:comment, :author => @author, :post => @post)
|
||||
assign(:post, @post)
|
||||
render
|
||||
end
|
||||
|
||||
it 'shows RSS feed title' do
|
||||
rendered.should contain "Recent comments on #{@post.subject}"
|
||||
end
|
||||
|
||||
it 'shows item title' do
|
||||
rendered.should contain "Comment by #{@author.login_name}"
|
||||
end
|
||||
|
||||
it 'escapes html for link to post' do
|
||||
# it's then unescaped by 'render' so we don't actually look for <
|
||||
rendered.should contain '<a href='
|
||||
end
|
||||
|
||||
it 'shows content of comments' do
|
||||
rendered.should contain "OMG LOL"
|
||||
end
|
||||
|
||||
end
|
||||
Reference in new issue
Block a user