Sha256: f263d5ca89fccd0c4fa6534387a862ff020402960b8c4529bfb5430ad75fbaac

Contents?: true

Size: 1.62 KB

Versions: 19

Compression:

Stored size: 1.62 KB

Contents

require 'rails_helper'

describe Pulitzer::PostTypesController do
  routes { Pulitzer::Engine.routes }
  render_views
  let(:post_type){Pulitzer::PostType.first}

  describe "#create", type: :request do
    it "Creates a plural post type without an intial post" do
      post pulitzer.post_types_path post_type: { name: 'Flock of birds', kind: 'template', plural: '1' }
      expect(response.status).to eq 200
      expect(response.body).to match /Flock of birds/
      post_type = Pulitzer::PostType.find_by(name: 'Flock of birds')
      post_type_version = post_type.post_type_versions.first
      expect(post_type_version.posts.any?).to be false
    end

    it "Creates a single post type with an intial post" do
      post pulitzer.post_types_path post_type: { name: 'Crow', kind: 'template', plural: '0' }
      post_type = Pulitzer::PostType.find_by(name: 'Crow')
      post_type_version = post_type.post_type_versions.first
      expect(response.status).to eq 200
      expect(response.body).to match post_type_version.name
      expect(post_type_version.posts.count).to eq 1
      expect(post_type_version.posts.first.title).to eq post_type_version.name
    end

    it "exports a post type" do
      get pulitzer.export_post_type_path id: post_type.id
      expect(response.status).to eq 200
      response_json = JSON.parse(response.body)
      expect(response_json['name']).to eq post_type.name
      expect(response_json['plural']).to eq post_type.plural
      expect(response_json['kind']).to eq post_type.kind
      expect(response_json["post_type_versions_attributes"].length).to eq post_type.post_type_versions.length
    end

  end
end

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
pulitzer-0.15.31 spec/controllers/pulitzer/post_types_controller_spec.rb
pulitzer-0.15.30 spec/controllers/pulitzer/post_types_controller_spec.rb
pulitzer-0.15.29 spec/controllers/pulitzer/post_types_controller_spec.rb
pulitzer-0.15.28 spec/controllers/pulitzer/post_types_controller_spec.rb
pulitzer-0.15.27 spec/controllers/pulitzer/post_types_controller_spec.rb
pulitzer-0.15.26 spec/controllers/pulitzer/post_types_controller_spec.rb
pulitzer-0.15.25 spec/controllers/pulitzer/post_types_controller_spec.rb
pulitzer-0.15.24 spec/controllers/pulitzer/post_types_controller_spec.rb
pulitzer-0.15.23 spec/controllers/pulitzer/post_types_controller_spec.rb
pulitzer-0.15.22 spec/controllers/pulitzer/post_types_controller_spec.rb
pulitzer-0.15.21 spec/controllers/pulitzer/post_types_controller_spec.rb
pulitzer-0.15.20 spec/controllers/pulitzer/post_types_controller_spec.rb
pulitzer-0.15.19 spec/controllers/pulitzer/post_types_controller_spec.rb
pulitzer-0.15.18 spec/controllers/pulitzer/post_types_controller_spec.rb
pulitzer-0.15.17 spec/controllers/pulitzer/post_types_controller_spec.rb
pulitzer-0.15.16 spec/controllers/pulitzer/post_types_controller_spec.rb
pulitzer-0.15.15 spec/controllers/pulitzer/post_types_controller_spec.rb
pulitzer-0.15.14 spec/controllers/pulitzer/post_types_controller_spec.rb
pulitzer-0.15.13 spec/controllers/pulitzer/post_types_controller_spec.rb