Sha256: af719e8aa31c552e64e4b9fba6707465c609c96a344cc6c630efa82805f937c9

Contents?: true

Size: 1023 Bytes

Versions: 26

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

26 entries across 26 versions & 2 rubygems

Version Path
mailgun-ruby-1.2.15 spec/unit/lists/opt_in_handler_spec.rb
mailgun-ruby-1.2.14 spec/unit/lists/opt_in_handler_spec.rb
mailgun-ruby-1.2.13 spec/unit/lists/opt_in_handler_spec.rb
mailgun-ruby-1.2.12 spec/unit/lists/opt_in_handler_spec.rb
mailgun-ruby-1.2.11 spec/unit/lists/opt_in_handler_spec.rb
mailgun-ruby-1.2.10 spec/unit/lists/opt_in_handler_spec.rb
mailgun-ruby-1.2.9 spec/unit/lists/opt_in_handler_spec.rb
mailgun-ruby-1.2.8 spec/unit/lists/opt_in_handler_spec.rb
mailgun-ruby-1.2.7 spec/unit/lists/opt_in_handler_spec.rb
mailgun-ruby-1.2.6 spec/unit/lists/opt_in_handler_spec.rb
mailgun-ruby-1.2.5 spec/unit/lists/opt_in_handler_spec.rb
mailgun-ruby-1.2.4 spec/unit/lists/opt_in_handler_spec.rb
mailgun-ruby-1.2.3 spec/unit/lists/opt_in_handler_spec.rb
mailgun-ruby-1.2.0 spec/unit/lists/opt_in_handler_spec.rb
mailgun-ruby-1.1.11 spec/unit/lists/opt_in_handler_spec.rb
mailgun-ruby-1.1.10 spec/unit/lists/opt_in_handler_spec.rb
mailgun-ruby-1.1.9 spec/unit/lists/opt_in_handler_spec.rb
wj-mailgun-ruby-1.1.7 spec/unit/lists/opt_in_handler_spec.rb
mailgun-ruby-1.1.8 spec/unit/lists/opt_in_handler_spec.rb
mailgun-ruby-1.1.6 spec/unit/lists/opt_in_handler_spec.rb