Sha256: f90ffa3ac3e658d522d07a6343133872dc7cc0b12f26eb77f881d0d432b2c59c

Contents?: true

Size: 1.37 KB

Versions: 14

Compression:

Stored size: 1.37 KB

Contents

require 'rails_helper'

describe Pulitzer::UpdatePostTypeContentElements do
  let(:version)     { post.preview_version }
  let(:post)        { post_type.posts.first }
  let(:post_type)   { Pulitzer::PostType.named('Welcome') }
  let(:content_element_type) { Pulitzer::ContentElementType.find_by name: 'Text'}
  let(:ptcet)       { post_type.post_type_content_element_types.create(content_element_type_id: content_element_type.id, label: 'A New Field for this Post Type')}

  describe "#call" do

    it "updates a content element in a preview version" do
      ptcet
      Pulitzer::CreatePostContentElements.new(post).call
      preview = post.preview_version
      expect(preview.content_elements.map(&:post_type_content_element_type_id)).to include(ptcet.id)
      ptcet.update label: 'A changed label'
      Pulitzer::UpdatePostTypeContentElements.new(ptcet, 'A New Field for this Post Type').call
      content_element = preview.reload.content_elements.detect{|ce| ce.post_type_content_element_type_id == ptcet.id}
      expect(content_element.label).to eq('A changed label')
    end

    it "doesn't blow up if a post has no preview version" do
      version.update_columns status: 'archived'
      expect(post.reload.preview_version).to be_nil
      # There is no preview version for the post, but we don't blow up
      Pulitzer::UpdatePostTypeContentElements.new(ptcet).call
    end

  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
pulitzer-0.15.0 spec/interactions/update_post_type_content_elements_spec.rb
pulitzer-0.14.4 spec/interactions/update_post_type_content_elements_spec.rb
pulitzer-0.14.3 spec/interactions/update_post_type_content_elements_spec.rb
pulitzer-0.14.2 spec/interactions/update_post_type_content_elements_spec.rb
pulitzer-0.14.1 spec/interactions/update_post_type_content_elements_spec.rb
pulitzer-0.14.0 spec/interactions/update_post_type_content_elements_spec.rb
pulitzer-0.13.1 spec/interactions/update_post_type_content_elements_spec.rb
pulitzer-0.12.5 spec/interactions/update_post_type_content_elements_spec.rb
pulitzer-0.13.0 spec/interactions/update_post_type_content_elements_spec.rb
pulitzer-0.12.4 spec/interactions/update_post_type_content_elements_spec.rb
pulitzer-0.12.3 spec/interactions/update_post_type_content_elements_spec.rb
pulitzer-0.12.2 spec/interactions/update_post_type_content_elements_spec.rb
pulitzer-0.12.1 spec/interactions/update_post_type_content_elements_spec.rb
pulitzer-0.12.0 spec/interactions/update_post_type_content_elements_spec.rb