forked from publify/publify
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Yannick Francois
committed
Sep 15, 2013
1 parent
871e814
commit 498030b
Showing
1 changed file
with
32 additions
and
245 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,263 +1,50 @@ | ||
require 'spec_helper' | ||
|
||
describe AuthorsController do | ||
describe '#show' do | ||
let!(:blog) { FactoryGirl.create(:blog, :limit_article_display => 1) } | ||
let!(:no_profile_user) { FactoryGirl.create(:user_with_an_empty_profile) } | ||
let!(:article) { FactoryGirl.create(:article, :user => no_profile_user) } | ||
let!(:unpublished_article) { FactoryGirl.create(:unpublished_article, :user => no_profile_user) } | ||
let!(:full_profile_user) { FactoryGirl.create(:user_with_a_full_profile) } | ||
let!(:article2) { FactoryGirl.create(:article, :user => full_profile_user) } | ||
let!(:article3) { FactoryGirl.create(:article, :user => full_profile_user) } | ||
|
||
describe "With an empty profile" do | ||
describe "as html" do | ||
before do | ||
get 'show', :id => no_profile_user.login | ||
end | ||
|
||
it 'renders the :show template' do | ||
response.should render_template(:show) | ||
end | ||
|
||
it 'assigns author' do | ||
assigns(:author).should == no_profile_user | ||
end | ||
|
||
it 'assigns articles as published articles' do | ||
assigns(:articles).should == [article] | ||
end | ||
|
||
describe "when rendered" do | ||
render_views | ||
|
||
it 'has a link to the rss feed' do | ||
response.should have_selector("head>link[href=\"http://test.host/author/#{no_profile_user.login}.rss\"]") | ||
end | ||
|
||
it 'has a link to the atom feed' do | ||
response.should have_selector("head>link[href=\"http://test.host/author/#{no_profile_user.login}.atom\"]") | ||
end | ||
|
||
it 'includes an image to the user avatar when available' do | ||
response.should_not have_selector("img[alt=\"James Bond\"]") | ||
end | ||
|
||
it 'uncompleted profile should not show Web site' do | ||
response.should_not have_selector('li', :content => "Web site:") | ||
end | ||
|
||
it 'uncompleted profile should not show MSN account' do | ||
response.should_not have_selector('li', :content => "MSN:") | ||
end | ||
|
||
it 'uncompleted profile should not show Yahoo account' do | ||
response.should_not have_selector('li', :content => "Yahoo:") | ||
end | ||
|
||
it 'uncompleted profile should not show Jabber account' do | ||
response.should_not have_selector('li', :content => "Jabber:") | ||
end | ||
|
||
it 'uncompleted profile should not show AIM account' do | ||
response.should_not have_selector('li', :content => "AIM:") | ||
end | ||
|
||
it 'uncompleted profile should not show Twitter account' do | ||
response.should_not have_selector('li', :content => "AIM:") | ||
end | ||
let!(:blog) { create(:blog, limit_article_display: 1) } | ||
|
||
it 'uncompleted profile should not show user description' do | ||
response.should_not have_selector('div', :id => "author-description") | ||
end | ||
end | ||
end # end of html | ||
|
||
describe "as an atom feed" do | ||
before do | ||
get 'show', :id => no_profile_user.login, :format => 'atom' | ||
end | ||
|
||
it 'assigns articles as published articles' do | ||
assigns(:articles).should == [article] | ||
end | ||
describe :show do | ||
describe "With an empty profile" do | ||
let(:no_profile_user) { create(:user_with_an_empty_profile) } | ||
let!(:article) { create(:article, user: no_profile_user) } | ||
|
||
it "renders the atom template" do | ||
response.should be_success | ||
response.should render_template("show_atom_feed") | ||
end | ||
describe "html" do | ||
before(:each) { get 'show', id: no_profile_user.login } | ||
|
||
it "does not render layout" do | ||
@layouts.keys.compact.should be_empty | ||
end | ||
end # end of atom feed | ||
|
||
describe "as an rss feed" do | ||
before do | ||
get 'show', :id => no_profile_user.login, :format => 'rss' | ||
end | ||
it { expect(response).to render_template(:show) } | ||
it { expect(assigns(:author)).to eq(no_profile_user) } | ||
it { expect(assigns(:articles)).to eq([article]) } | ||
end | ||
|
||
it 'assigns articles as published articles' do | ||
assigns(:articles).should == [article] | ||
end | ||
describe "atom feed" do | ||
before(:each) { get 'show', id: no_profile_user.login, format: 'atom' } | ||
it { expect(response).to render_template(:show_atom_feed, false) } | ||
end | ||
|
||
it "renders the rss template" do | ||
response.should be_success | ||
response.should render_template("show_rss_feed") | ||
end | ||
describe "rss feed" do | ||
before(:each) { get 'show', id: no_profile_user.login, format: 'rss' } | ||
it { expect(response).to render_template(:show_rss_feed, false) } | ||
end | ||
|
||
it "does not render layout" do | ||
@layouts.keys.compact.should be_empty | ||
end | ||
end # end of rss feed | ||
|
||
describe "with pagination" do | ||
before do | ||
get 'show', :id => no_profile_user.login, :page => 2 | ||
end | ||
|
||
it 'renders a 404' do | ||
response.should render_template(:show) | ||
end | ||
|
||
it 'assigns no articles' do | ||
assigns(:articles).should == [] | ||
end | ||
let!(:article_page_2) { create(:article, user: no_profile_user) } | ||
before(:each) { get 'show', id: no_profile_user.login, page: 2 } | ||
it { expect(assigns(:articles)).to eq([article_page_2]) } | ||
end | ||
end # end of empty profile | ||
end | ||
|
||
describe "With full profile" do | ||
describe "as html" do | ||
before do | ||
get 'show', :id => full_profile_user.login | ||
end | ||
|
||
it 'renders the :show template' do | ||
response.should render_template(:show) | ||
end | ||
|
||
it 'assigns author' do | ||
assigns(:author).should == full_profile_user | ||
end | ||
|
||
it 'assigns articles as published articles' do | ||
assigns(:articles).should == [article3] | ||
end | ||
let!(:full_profile_user) { create(:user_with_a_full_profile) } | ||
let!(:article) { create(:article, user: full_profile_user) } | ||
|
||
describe "when rendered" do | ||
render_views | ||
describe "html" do | ||
before(:each) { get 'show', id: full_profile_user.login } | ||
|
||
it 'has a link to the rss feed' do | ||
response.should have_selector("head>link[href=\"http://test.host/author/#{full_profile_user.login}.rss\"]") | ||
end | ||
|
||
it 'has a link to the atom feed' do | ||
response.should have_selector("head>link[href=\"http://test.host/author/#{full_profile_user.login}.atom\"]") | ||
end | ||
|
||
it 'includes an image to the user avatar when available' do | ||
response.should_not have_selector("img[alt=\"James Bond\"]") | ||
end | ||
|
||
it 'completed profile should not show Web site' do | ||
response.should have_selector('li', :content => "Web site:") | ||
end | ||
|
||
it 'completed profile should not show MSN account' do | ||
response.should have_selector('li', :content => "MSN:") | ||
end | ||
|
||
it 'completed profile should not show Yahoo account' do | ||
response.should have_selector('li', :content => "Yahoo:") | ||
end | ||
|
||
it 'completed profile should not show Jabber account' do | ||
response.should have_selector('li', :content => "Jabber:") | ||
end | ||
|
||
it 'completed profile should not show AIM account' do | ||
response.should have_selector('li', :content => "AIM:") | ||
end | ||
|
||
it 'completed profile should not show Twitter account' do | ||
response.should have_selector('li', :content => "AIM:") | ||
end | ||
|
||
it 'completed profile should not show user description' do | ||
response.should have_selector('div', :id => "author-description") | ||
end | ||
end | ||
end # end of html | ||
|
||
describe "as an atom feed" do | ||
before do | ||
get 'show', :id => full_profile_user.login, :format => 'atom' | ||
end | ||
|
||
it 'assigns articles as published articles' do | ||
assigns(:articles).should == [article3, article2] | ||
end | ||
|
||
it "renders the atom template" do | ||
response.should be_success | ||
response.should render_template("show_atom_feed") | ||
end | ||
|
||
it "does not render layout" do | ||
@layouts.keys.compact.should be_empty | ||
end | ||
end # end of atom feed | ||
|
||
describe "as an rss feed" do | ||
before do | ||
get 'show', :id => full_profile_user.login, :format => 'rss' | ||
end | ||
|
||
it 'assigns articles as published articles' do | ||
assigns(:articles).should == [article3, article2] | ||
end | ||
|
||
it "renders the rss template" do | ||
response.should be_success | ||
response.should render_template("show_rss_feed") | ||
end | ||
|
||
it "does not render layout" do | ||
@layouts.keys.compact.should be_empty | ||
end | ||
end # end of rss feed | ||
|
||
describe "with pagination" do | ||
before do | ||
get 'show', :id => full_profile_user.login, :page => 2 | ||
end | ||
|
||
it 'renders a 404' do | ||
response.should render_template(:show) | ||
end | ||
|
||
it 'assigns 1 article' do | ||
assigns(:articles).should == [article2] | ||
end | ||
end # end of pagination | ||
end # end of full profile | ||
it { expect(response).to render_template(:show) } | ||
it { expect(assigns(:author)).to eq(full_profile_user) } | ||
it { expect(assigns(:articles)).to eq([article]) } | ||
end | ||
end | ||
end | ||
end | ||
|
||
describe AuthorsController, "SEO options" do | ||
render_views | ||
|
||
it 'should never have meta keywords with deactivated option' do | ||
FactoryGirl.create(:blog, :use_meta_keyword => false) | ||
FactoryGirl.create(:user, :login => 'henri') | ||
get 'show', :id => 'henri' | ||
response.should_not have_selector('head>meta[name="keywords"]') | ||
end | ||
|
||
it 'should never have meta keywords with deactivated option' do | ||
FactoryGirl.create(:blog, :use_meta_keyword => true) | ||
FactoryGirl.create(:user, :login => 'alice') | ||
get 'show', :id => 'alice' | ||
response.should_not have_selector('head>meta[name="keywords"]') | ||
end | ||
end |