Sha256: d4032c23999cf092d183e9569d9ccddb0edfe00e6af42ca6f0e8f14207180d32

Contents?: true

Size: 1.63 KB

Versions: 3

Compression:

Stored size: 1.63 KB

Contents

# frozen_string_literal: true
require 'spec_helper'

describe 'help_center/sections' do
  let(:client) { create_client }
  let!(:category) do
    client.help_center_categories.create!(
      name: mock_uuid,
      locale: 'en-us'
    )
  end

  include_examples 'zendesk#resource',
                   collection: -> { client.help_center_sections },
                   create_params: -> { { name: mock_uuid, locale: 'en-us', category: category } },
                   update_params: -> { { name: mock_uuid } },
                   search: false

  context 'with a category, sections, and articles' do
    let!(:section)  { category.sections.create!(name: mock_uuid, locale: 'en-us') }
    let!(:articles) do
      Array.new(2) { section.articles.create(title: mock_uuid, locale: 'en-us', permission_group_id: 0) }
    end

    before do
      client.help_center_categories.create!(name: mock_uuid, locale: 'en-us')
            .sections.create!(name: mock_uuid, locale: 'en-us')
            .articles.create!(title: mock_uuid, locale: 'en-us', permission_group_id: 0)
    end

    it 'lists articles within a section' do
      expect(section.articles.all).to match_array(articles)
    end

    it 'shows the access policy for the section' do
      expect(section.access_policy.viewable_by).to eq('everyone')
    end

    it 'updates the section access policy' do
      policy = section.access_policy
      old_viewable_by = policy.viewable_by
      new_viewable_by = 'staff'

      expect do
        policy.update!(viewable_by: new_viewable_by)
      end.to change { section.reload.access_policy.viewable_by }.from(old_viewable_by).to(new_viewable_by)
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
zendesk2-1.15.0 spec/help_center/sections_spec.rb
zendesk2-1.13.1 spec/help_center/sections_spec.rb
zendesk2-1.13.0 spec/help_center/sections_spec.rb