Sha256: 3b584ff93727647567746c5c5a95295dcce49ec74e5326273c28f26f87e7c0aa

Contents?: true

Size: 1.83 KB

Versions: 2

Compression:

Stored size: 1.83 KB

Contents

RSpec.describe ExpressPigeon::Templates do
  # WARN: This test requires setting up a template to use as the baseline for
  #       copying templates. You can use any existing template or create new
  #       template from scratch.
  #
  #       Once you've selected a template to use check the URL for the template
  #       and extract the TEMPLATE_ID and update the `.env` file TEST_TEMPLATE_ID.
  #
  #       Example:
  #
  #         Given the URL `https://expresspigeon.com/newsletters/compose/26013`
  #         Then the .env file should be set to TEST_TEMPLATE_ID=26013
  #
  #       You will need to clean up templates created by this test manually
  #       as the API doesn't support deleting templates at this time
  #

  let(:auth_key) { ENV['EXPRESS_PIGEON_AUTH_KEY'] }
  let(:client) { ExpressPigeon::Templates.new(auth_key) }

  let(:test_template_id) { Integer(ENV['TEST_TEMPLATE_ID']) }

  it 'copies an existing template' do
    response = client.copy(test_template_id, name: 'TEST copied template', merge_fields: {
                             test_merge_field: 'Hello, World!'
                           })

    # NOTE: Since we can't see the actual merge result you'll need to log in
    #       to your ExpressPigeon account and check the result of the merge.

    expect(response['code']).to eq(200)

    # If this fails then check the response. We're dependant on the behavior
    # of the env for this expectation. If we run the test multiple times then
    # the autoincrement for the TEMPLATE_ID is offset further. Right now just
    # expect it to be an integer greater than the initial template id.
    expect(response['template_id']).to be_a(Integer)
    next_template_id = Integer(response['template_id'])
    expect(next_template_id).to be > test_template_id

    expect(response['message']).to eq('template copied successfully')
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
express_pigeon-2.4.1 spec/lib/express_pigeon/templates_spec.rb
express_pigeon-2.4.0 spec/lib/express_pigeon/templates_spec.rb