Sha256: 17f11a64f1084b136ea53599485ad7b231cf2bcd2363ba6113d99cd08f1f2dbf

Contents?: true

Size: 1.88 KB

Versions: 7

Compression:

Stored size: 1.88 KB

Contents

require 'rails_helper'

describe Pulitzer::ArrangementStylesController do
  routes { Pulitzer::Engine.routes }
  render_views

  let(:post_type) { Pulitzer::PostType.create(name: 'partial with various layout styles', kind: Pulitzer::PostType.kinds[:partial], plural: false) }
  let(:arrangement_style) { post_type.arrangement_styles.create(display_name: 'White', view_file_name: 'white') }

  describe "arrangement_styles", type: :request do
    it "renders the new form" do
      get pulitzer.new_arrangement_style_path(arrangement_style: {post_type_id: post_type.id})
      expect(response.status).to eq 200
      expect(response.body).to match /arrangement_style\[display_name\]/
    end

    it "creates a new arrangement_style" do
      post pulitzer.arrangement_styles_path(
        arrangement_style: {
          post_type_id: post_type.id,
          view_file_name: 'pretty-arrangement',
          display_name: 'Pretty Arrangement'})
      expect(response.status).to eq 200
      bs = Pulitzer::ArrangementStyle.order(id: :desc).first
      expect(bs.view_file_name).to eq 'pretty-arrangement'
      expect(bs.display_name).to eq 'Pretty Arrangement'
    end

    it "edits an arrangement_style" do
      get pulitzer.edit_arrangement_style_path id: arrangement_style.id
      expect(response.status).to eq 200
      
      expect(response.body).to match 'White'
    end

    it "updates an arrangement_style" do
      patch pulitzer.arrangement_style_path id: arrangement_style.id, arrangement_style: {display_name: 'edited name'}
      expect(response.status).to eq 200
      expect(arrangement_style.reload.display_name).to eq 'edited name'
    end

    it "deletes an arrangement_style" do
      delete pulitzer.arrangement_style_path id: arrangement_style.id
      expect(response.status).to eq 200
      expect(Pulitzer::ArrangementStyle.find_by(id: arrangement_style.id)).to be nil
    end

  end # /search
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
pulitzer-0.15.0 spec/controllers/pulitzer/arrangement_styles_controller_spec.rb
pulitzer-0.14.4 spec/controllers/pulitzer/arrangement_styles_controller_spec.rb
pulitzer-0.14.3 spec/controllers/pulitzer/arrangement_styles_controller_spec.rb
pulitzer-0.14.2 spec/controllers/pulitzer/arrangement_styles_controller_spec.rb
pulitzer-0.14.1 spec/controllers/pulitzer/arrangement_styles_controller_spec.rb
pulitzer-0.14.0 spec/controllers/pulitzer/arrangement_styles_controller_spec.rb
pulitzer-0.13.1 spec/controllers/pulitzer/arrangement_styles_controller_spec.rb