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

@ -6,12 +6,12 @@ describe ClicksController do
context 'missing params' do
it 'raises an error without the url param' do
lambda { xhr :get, :track, post_id: 123 }.should raise_error(ActionController::ParameterMissing)
expect { xhr :get, :track, post_id: 123 }.to raise_error(ActionController::ParameterMissing)
end
it "redirects to the url even without the topic_id or post_id params" do
xhr :get, :track, url: 'http://google.com'
response.should_not be_redirect
expect(response).not_to be_redirect
end
end
@ -26,7 +26,7 @@ describe ClicksController do
it "doesn't redirect" do
TopicLinkClick.expects(:create_from).returns(nil)
xhr :get, :track, url: 'http://discourse.org', post_id: 123
response.should_not be_redirect
expect(response).not_to be_redirect
end
end
@ -42,25 +42,25 @@ describe ClicksController do
it 'calls create_from' do
TopicLinkClick.expects(:create_from).with('url' => url, 'post_id' => '123', 'ip' => '192.168.0.1').returns(url)
xhr :get, :track, url: url, post_id: 123
response.should redirect_to(url)
expect(response).to redirect_to(url)
end
it 'redirects to the url' do
TopicLinkClick.stubs(:create_from).returns(url)
xhr :get, :track, url: url, post_id: 123
response.should redirect_to(url)
expect(response).to redirect_to(url)
end
it 'will pass the user_id to create_from' do
TopicLinkClick.expects(:create_from).with('url' => url, 'post_id' => '123', 'ip' => '192.168.0.1').returns(url)
xhr :get, :track, url: url, post_id: 123
response.should redirect_to(url)
expect(response).to redirect_to(url)
end
it "doesn't redirect with the redirect=false param" do
TopicLinkClick.expects(:create_from).with('url' => url, 'post_id' => '123', 'ip' => '192.168.0.1', 'redirect' => 'false').returns(url)
xhr :get, :track, url: url, post_id: 123, redirect: 'false'
response.should_not be_redirect
expect(response).not_to be_redirect
end
end
@ -69,7 +69,7 @@ describe ClicksController do
it 'calls create_from' do
TopicLinkClick.expects(:create_from).with('url' => url, 'topic_id' => '789', 'ip' => '192.168.0.1').returns(url)
xhr :get, :track, url: url, topic_id: 789
response.should redirect_to(url)
expect(response).to redirect_to(url)
end
end