Sha256: af719e8aa31c552e64e4b9fba6707465c609c96a344cc6c630efa82805f937c9

Contents?: true

Size: 1023 Bytes

Versions: 27

Compression:

Stored size: 1023 Bytes

Contents

require 'spec_helper'

describe 'The method generate_hash' do
  before(:each) do
    @mailing_list = "mylist@example.com"
    @secret_app_id = "mysupersecretpassword"
    @recipient_address = "bob@example.com"
    @precalculated_hash = "eyJoIjoiMmY3ZmY1MzFlOGJmMjA0OWNhMTI3ZmU4ZTQyNjZkOTljYzhkMTdk%0AMiIsInAiOiJleUpzSWpvaWJYbHNhWE4wUUdWNFlXMXdiR1V1WTI5dElpd2lj%0AaUk2SW1KdllrQmxlR0Z0Y0d4bExtTnZcbmJTSjlcbiJ9%0A"
  end

  it 'generates a web safe hash for the recipient wishing to subscribe' do
    my_hash = Mailgun::OptInHandler.generate_hash(@mailing_list, @secret_app_id, @recipient_address)
    
    expect(my_hash).to eq(@precalculated_hash)
  end

  it 'generates a web safe hash for the recipient wishing to subscribe' do
    validate_result = Mailgun::OptInHandler.validate_hash(@secret_app_id, @precalculated_hash)
    
    expect(validate_result.length).to eq(2)
    expect(validate_result['recipient_address']).to eq(@recipient_address)
    expect(validate_result['mailing_list']).to eq(@mailing_list)
  end
end

Version data entries

27 entries across 27 versions & 2 rubygems

Version Path
mailgun-ruby-1.1.6 spec/unit/lists/opt_in_handler_spec.rb
mailgun-ruby-1.1.5 spec/unit/lists/opt_in_handler_spec.rb
mailgun-ruby-1.1.4 spec/unit/lists/opt_in_handler_spec.rb
mailgun-ruby-1.1.3 spec/unit/lists/opt_in_handler_spec.rb
mailgun-ruby-1.1.2 spec/unit/lists/opt_in_handler_spec.rb
mailgun-ruby-1.1.1 spec/unit/lists/opt_in_handler_spec.rb
mailgun-ruby-1.1.0 spec/unit/lists/opt_in_handler_spec.rb