Sha256: c596a0eb99cbe4104b5aafdb9fcf028c27b9e2962f4d7c00e223f5c8313a2600

Contents?: true

Size: 1.64 KB

Versions: 3

Compression:

Stored size: 1.64 KB

Contents

require 'rails_helper'

describe SubPostsController do
  
  it "is a subclass of Blogit::PostsController" do
    expect(SubPostsController.superclass).to eq(Blogit::PostsController)
  end
  
  before do
    reset_configuration
  end

  let(:blog_post) { build :post }

  describe "GET 'index'" do
    
    before do
      Post.expects(:for_index).with(nil).returns(posts)
    end
    
    let(:posts) { [] }

    def do_get(page=nil)
      get :index, page: page 
    end
    
    context "when super is called with a block" do
  
      it 'yields the block with posts' do
        Timecop.freeze do
          posts.expects(:update_all).with(updated_at: Time.now).returns([])
          do_get
        end
      end
      
    end  
  
  end
  
  describe "GET 'tagged'" do
    
    before do
      Post.expects(:for_index).with(nil).returns(posts)
      posts.expects(:tagged_with).returns(posts)
    end
    
    let(:posts) { [] }

    def do_get(page=nil)
      get :tagged, page: page, tag: "one"
    end
    
    context "when super is called with a block" do
  
      it 'yields the block with posts' do
        Timecop.freeze do
          posts.expects(:update_all).with(updated_at: Time.now).returns([])
          do_get
        end
      end
      
    end  
  
  end
  
  describe "GET 'show'" do
    
    before do
      Post.expects(:active_with_id).with("1").returns(post)
    end
    
    let(:post) { [] }

    def do_get(id="1")
      get :show, id: "1"
    end
    
    context "when super is called with a block" do
  
      it 'yields the block with posts' do
        post.expects(:touch).with(:updated_at)
        do_get
      end
      
    end  
  
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
blogit-1.1.2 spec/dummy/spec/controllers/sub_posts_controller_spec.rb
blogit-1.1.1 spec/dummy/spec/controllers/sub_posts_controller_spec.rb
blogit-1.1.0 spec/dummy/spec/controllers/sub_posts_controller_spec.rb