Sha256: de6b42432ec14915f437cc9c840e3a64ea39bc0b444d1827b1ad1b0a9019334d

Contents?: true

Size: 1.19 KB

Versions: 2

Compression:

Stored size: 1.19 KB

Contents

require 'rails_helper'

RSpec.describe Exposition::TagsController, type: :controller do
  routes { Exposition::Engine.routes }

  describe "GET #show" do
    it "finds the given tag" do
      tag = create(:tag)

      get :show, params: { id: tag }

      expect(assigns(:tag)).to eq(tag)
    end

    it "finds all the published posts ordered by date with the tag" do
      tag = create(:tag)
      tagged_older_post = create(:post, published: true, tags: [tag])
      tagged_newer_post = create(:post, published: true, tags: [tag])
      tagged_unpublished_post = create(:post, published: false, tags: [tag])
      untagged_post = create(:post, published: true)

      tagged_older_post.published_at = Date.today - 2.days
      tagged_newer_post.published_at = Date.today
      tagged_older_post.save!
      tagged_newer_post.save!
      get :show, params: { id: tag }

      expect(assigns(:taggables)).to eq([tagged_newer_post, tagged_older_post])
    end

    it "paginates the results in chunks of 10" do
      tag = create(:tag)
      posts = FactoryGirl.create_list(:post, 11, published: true, tags: [tag])

      get :show, params: { id: tag }

      expect(assigns(:taggables).count).to eq(10)
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
exposition-0.0.5.5.pre.alpha spec/controllers/exposition/tags_controller_spec.rb
exposition-0.0.5.4.pre.alpha spec/controllers/exposition/tags_controller_spec.rb