require 'spec_helper' describe IncomingLink do it { should belong_to :topic } it { should validate_presence_of :url } let :post do Fabricate(:post) end let :topic do post.topic end let :incoming_link do IncomingLink.create(url: "/t/slug/#{topic.id}/#{post.post_number}", referer: "http://twitter.com") end describe 'local topic link' do it 'should validate properly' do Fabricate.build(:incoming_link).should be_valid end describe 'tracking link counts' do it "increases the incoming link counts" do incoming_link lambda { post.reload }.should change(post, :incoming_link_count).by(1) lambda { topic.reload }.should change(topic, :incoming_link_count).by(1) end end describe 'saving local link' do it 'has correct info set' do incoming_link.domain.should == "twitter.com" incoming_link.topic_id.should == topic.id incoming_link.post_number.should == post.post_number end end end describe 'add' do class TestRequest