controllers with rspec3 syntax

This commit is contained in:
Luciano Sousa
2015-01-09 14:04:02 -03:00
parent c96220ca76
commit bc73238c8f
50 changed files with 955 additions and 955 deletions

View File

@ -14,14 +14,14 @@ describe TopicsController do
end
it "doesn't store an incoming link when there's no referer" do
lambda {
expect {
get :show, id: topic.id
}.should_not change(IncomingLink, :count)
}.not_to change(IncomingLink, :count)
end
it "doesn't raise an error on a very long link" do
set_referer("http://#{'a' * 2000}.com")
lambda { get :show, {id: topic.id} }.should_not raise_error
expect { get :show, {id: topic.id} }.not_to raise_error
end
describe "has_escaped_fragment?" do
@ -34,7 +34,7 @@ describe TopicsController do
it "uses the application layout even with an escaped fragment param" do
get :show, {'topic_id' => topic.id, 'slug' => topic.slug, '_escaped_fragment_' => 'true'}
response.should render_template(layout: 'application')
expect(response).to render_template(layout: 'application')
assert_select "meta[name=fragment]", false, "it doesn't have the meta tag"
end
end
@ -46,13 +46,13 @@ describe TopicsController do
it "uses the application layout when there's no param" do
get :show, topic_id: topic.id, slug: topic.slug
response.should render_template(layout: 'application')
expect(response).to render_template(layout: 'application')
assert_select "meta[name=fragment]", true, "it has the meta tag"
end
it "uses the crawler layout when there's an _escaped_fragment_ param" do
get :show, topic_id: topic.id, slug: topic.slug, _escaped_fragment_: 'true'
response.should render_template(layout: 'crawler')
expect(response).to render_template(layout: 'crawler')
assert_select "meta[name=fragment]", false, "it doesn't have the meta tag"
end
end
@ -67,7 +67,7 @@ describe TopicsController do
end
it "renders with the application layout" do
get :show, topic_id: topic.id, slug: topic.slug
response.should render_template(layout: 'application')
expect(response).to render_template(layout: 'application')
assert_select "meta[name=fragment]", true, "it has the meta tag"
end
end
@ -78,7 +78,7 @@ describe TopicsController do
end
it "renders with the crawler layout" do
get :show, topic_id: topic.id, slug: topic.slug
response.should render_template(layout: 'crawler')
expect(response).to render_template(layout: 'crawler')
assert_select "meta[name=fragment]", false, "it doesn't have the meta tag"
end
end
@ -94,7 +94,7 @@ describe TopicsController do
get :show, {topic_id: topic.id}
I18n.locale.should == :fr
expect(I18n.locale).to eq(:fr)
end
it 'is sets the default locale when the setting not enabled' do
@ -103,7 +103,7 @@ describe TopicsController do
get :show, {topic_id: topic.id}
I18n.locale.should == :en
expect(I18n.locale).to eq(:en)
end
end
@ -135,31 +135,31 @@ describe 'api' do
it 'allows users with api key to bookmark posts' do
PostAction.expects(:act).with(user, post, PostActionType.types[:bookmark]).once
put :bookmark, bookmarked: "true", post_id: post.id, api_key: api_key.key, format: :json
response.should be_success
expect(response).to be_success
end
it 'raises an error with a user key that does not match an optionally specified username' do
PostAction.expects(:act).with(user, post, PostActionType.types[:bookmark]).never
put :bookmark, bookmarked: "true", post_id: post.id, api_key: api_key.key, api_username: 'made_up', format: :json
response.should_not be_success
expect(response).not_to be_success
end
it 'allows users with a master api key to bookmark posts' do
PostAction.expects(:act).with(user, post, PostActionType.types[:bookmark]).once
put :bookmark, bookmarked: "true", post_id: post.id, api_key: master_key.key, api_username: user.username, format: :json
response.should be_success
expect(response).to be_success
end
it 'disallows phonies to bookmark posts' do
PostAction.expects(:act).with(user, post, PostActionType.types[:bookmark]).never
put :bookmark, bookmarked: "true", post_id: post.id, api_key: SecureRandom.hex(32), api_username: user.username, format: :json
response.code.to_i.should == 403
expect(response.code.to_i).to eq(403)
end
it 'disallows blank api' do
PostAction.expects(:act).with(user, post, PostActionType.types[:bookmark]).never
put :bookmark, bookmarked: "true", post_id: post.id, api_key: "", api_username: user.username, format: :json
response.code.to_i.should == 403
expect(response.code.to_i).to eq(403)
end
end
end