Sha256: c22ff2b77558eff75148f45c9a66bc5231ed5e76b19e7d6b0674b4c4218aa29b

Contents?: true

Size: 1.9 KB

Versions: 7

Compression:

Stored size: 1.9 KB

Contents

require 'rails_helper'

describe Pulitzer::JustificationStylesController 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(:justification_style) { post_type.justification_styles.create(display_name: 'White', css_class_name: 'white') }

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

    it "creates a new justification_style" do
      post pulitzer.justification_styles_path(
        justification_style: {
          post_type_id: post_type.id,
          css_class_name: 'pretty-class',
          display_name: 'Pretty Class'})
      expect(response.status).to eq 200
      bs = Pulitzer::JustificationStyle.order(id: :desc).first
      expect(bs.css_class_name).to eq 'pretty-class'
      expect(bs.display_name).to eq 'Pretty Class'
    end

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

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

    it "deletes an justification_style" do
      delete pulitzer.justification_style_path id: justification_style.id
      expect(response.status).to eq 200
      expect(Pulitzer::JustificationStyle.find_by(id: justification_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/justification_styles_controller_spec.rb
pulitzer-0.14.4 spec/controllers/pulitzer/justification_styles_controller_spec.rb
pulitzer-0.14.3 spec/controllers/pulitzer/justification_styles_controller_spec.rb
pulitzer-0.14.2 spec/controllers/pulitzer/justification_styles_controller_spec.rb
pulitzer-0.14.1 spec/controllers/pulitzer/justification_styles_controller_spec.rb
pulitzer-0.14.0 spec/controllers/pulitzer/justification_styles_controller_spec.rb
pulitzer-0.13.1 spec/controllers/pulitzer/justification_styles_controller_spec.rb