Files
growstuff/spec/controllers/member_controller_spec.rb
milesgould bb6e9e32e6 De-deprecate controller and view specs
We deprecated controller and view specs on the grounds that they were
brittle, and were a poorer measure of user experience than feature
specs. However, feature specs have their own problems: they're much
slower to run, and flakier (see #901). We also ran into a few cases
where feature specs erroneously passed because they were checking for
the presence of a string that occurred in the error page!

Hence, we're cautiously un-deprecating controller and view specs.

Fixes #1132
2017-11-24 19:02:54 +13:00

65 lines
1.8 KiB
Ruby

require 'rails_helper'
describe MembersController do
before :each do
@member = FactoryBot.create(:member)
@posts = [FactoryBot.create(:post, author: @member)]
@twitter_auth = FactoryBot.create(:authentication, member: @member)
@flickr_auth = FactoryBot.create(:flickr_authentication, member: @member)
end
describe "GET index" do
it "assigns only confirmed members as @members" do
get :index, {}
assigns(:members).should eq([@member])
end
end
describe "GET JSON index" do
it "provides JSON for members" do
get :index, format: 'json'
response.should be_success
end
end
describe "GET show" do
it "provides JSON for member profile" do
get :show, id: @member.id, format: 'json'
response.should be_success
end
it "assigns @posts with the member's posts" do
get :show, id: @member.id
assigns(:posts).should eq(@posts)
end
it "assigns @twitter_auth" do
get :show, id: @member.id
assigns(:twitter_auth).should eq(@twitter_auth)
end
it "assigns @flickr_auth" do
get :show, id: @member.id
assigns(:flickr_auth).should eq(@flickr_auth)
end
it "doesn't show completely nonsense members" do
lambda { get :show, id: 9999 }.should raise_error(ActiveRecord::RecordNotFound)
end
it "doesn't show unconfirmed members" do
@member2 = FactoryBot.create(:unconfirmed_member)
lambda { get :show, id: @member2.id }.should raise_error(ActiveRecord::RecordNotFound)
end
end
describe "GET member's RSS feed" do
it "returns an RSS feed" do
get :show, id: @member.to_param, format: "rss"
response.should be_success
response.should render_template("members/show")
response.content_type.should eq("application/rss+xml")
end
end
end