Sha256: 7f5a4241bfedbb76b127d309648d915f0dbc71f9fd029a17d096b5c1c85d4d29

Contents?: true

Size: 1.19 KB

Versions: 3

Compression:

Stored size: 1.19 KB

Contents

require 'spec_helper'

module Writefully
  describe PostsController, type: :controller do 
    routes { Writefully::Engine.routes }

    fixtures :"writefully/sites"
    fixtures :"writefully/posts"
    fixtures :"writefully/authorships"

    let(:owner)  { writefully_authorships(:wf_owner_1) }
    let(:site)   { writefully_sites(:codemy_net) }
    let(:post_1) {  writefully_posts(:hash_selector_pattern) }

    let(:some_post) { writefully_posts(:blah_post) }

    before do 
      session[:wf_authorship_id] = owner.id
    end

    describe "#index" do 
      it "should be success" do 
        get :index, site_id: site.slug
        expect(response).to be_success
      end

      it "should assign correct posts" do 
        get :index, site_id: site.slug
        expect(assigns[:posts]).to include post_1
        expect(assigns[:posts]).to_not include some_post
      end
    end

    describe "#show" do 
      it "should be success" do 
        get :show, site_id: site.slug, id: post_1.id
        expect(response).to be_success
      end

      it "should assign the correct post" do 
        get :show, site_id: site.slug, id: post_1.id
        expect(assigns[:post]).to eq post_1
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
writefully-0.8.2 spec/controllers/writefully/posts_controller_spec.rb
writefully-0.8.1 spec/controllers/writefully/posts_controller_spec.rb
writefully-0.8.0 spec/controllers/writefully/posts_controller_spec.rb