Sha256: ca6296f665261ff7060202a5e55860d34a3c4d9eb85880f64f605efefe5419e1

Contents?: true

Size: 1.32 KB

Versions: 2

Compression:

Stored size: 1.32 KB

Contents

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 do
        put :update, id: @post.id, spud_post: { url_name: 'new-url' }, blog_key: 'blog'
      end.to change(@post.tb_redirects, :count).by(1)
    end

    it 'should not create a redirect' do
      expect do
        put :update, id: @post.id, spud_post: { title: 'Hello World' }, blog_key: 'blog'
      end.to_not change(@post.tb_redirects, :count)
    end
  end

  describe '#preview' do
    context 'with a new post' do
      it 'should set the attributes without saving' do
        expect do
          post :preview, blog_key: 'blog', post_id: nil, spud_post: { title: 'Hello World' }
        end.to_not change(SpudPost, :count)
      end
    end
    context 'with an existing post' do
      it 'should set the attributes without saving' do
        @post = FactoryGirl.create(:spud_post)
        expect do
          post :preview,
            blog_key: @post.blog_key,
            post_id: @post.id,
            spud_post: { title: 'Hello World' }
          @post.reload
        end.to_not change(@post, :title)
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
tb_blog-1.3.5 spec/controllers/admin/posts_controller_spec.rb
tb_blog-1.3.4 spec/controllers/admin/posts_controller_spec.rb