remove problem spec that does not work properly in rails 4 mode into application controller and correct it

This commit is contained in:
Sam 2013-11-11 10:50:48 +11:00
parent 20f06f3efc
commit a9c5d843f7
2 changed files with 46 additions and 39 deletions

View File

@ -1,5 +1,51 @@
require 'spec_helper' require 'spec_helper'
describe TopicsController do
before do
TopicUser.stubs(:track_visit!)
end
let :topic do
Fabricate(:post).topic
end
def set_referer(ref)
request.env['HTTP_REFERER'] = ref
end
it "doesn't store an incoming link when there's no referer" do
lambda {
get :show, id: topic.id
}.should_not 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
end
it "stores an incoming link when there is an off-site referer" do
lambda {
set_referer("http://google.com/search")
get :show, {id: topic.id}
}.should change(IncomingLink, :count).by(1)
end
describe 'after inserting an incoming link' do
it 'sets last link correctly' do
set_referer("http://google.com/search")
get :show, {topic_id: topic.id}
last_link = IncomingLink.last
last_link.topic_id.should == topic.id
last_link.post_number.should == 1
end
end
end
describe 'api' do describe 'api' do
describe PostsController do describe PostsController do
let(:user) do let(:user) do

View File

@ -1,39 +0,0 @@
require "spec_helper"
describe "Stores incoming links" do
before do
TopicUser.stubs(:track_visit!)
end
let :topic do
Fabricate(:post).topic
end
it "doesn't store an incoming link when there's no referer" do
lambda {
get topic.relative_url
}.should_not change(IncomingLink, :count)
end
it "doesn't raise an error on a very long link" do
lambda { get topic.relative_url, nil, {'HTTP_REFERER' => "http://#{'a' * 2000}.com"} }.should_not raise_error
end
it "stores an incoming link when there is an off-site referer" do
lambda {
get topic.relative_url, nil, {'HTTP_REFERER' => "http://google.com/search"}
}.should change(IncomingLink, :count).by(1)
end
describe 'after inserting an incoming link' do
before do
get topic.relative_url + "/1", nil, {'HTTP_REFERER' => "http://google.com/search"}
@last_link = IncomingLink.last
@last_link.topic_id.should == topic.id
@last_link.post_number.should == 1
end
end
end