require 'rails_helper' describe Admin::PostsController, :type => :controller do before(:each) do activate_session(admin: true) end describe '#create_redirect_if_necessary' do before(:each) do @post = FactoryGirl.create(:spud_post) end it 'should create a redirect' do expect{ put :update, :id => @post.id, :spud_post => {:url_name => 'new-url'}, :blog_key => 'blog' }.to change(@post.tb_redirects, :count).by(1) end it 'should not create a redirect' do expect{ put :update, :id => @post.id, :spud_post => {:title => 'Hello World'}, :blog_key => 'blog' }.to_not change(@post.tb_redirects, :count) end end end