Sha256: 75f7b762b06ee54f4ebe796e3c9feaedf95003aa3a845eadb67922908b16cb4e

Contents?: true

Size: 1.4 KB

Versions: 21

Compression:

Stored size: 1.4 KB

Contents

require 'rails_helper'
require 'helpers/graph_api_helpers'

RSpec.describe Bobot::Event::AccountLinking do
  let :payload do
    {
      'sender' => {
        'id' => '3'
      },
      'recipient' => {
        'id' => '3'
      },
      'timestamp' => 145_776_419_762_7,
      'account_linking' => {
        'status' => 'linked',
        'authorization_code' => 'PASS_THROUGH_AUTHORIZATION_CODE'
      }
    }
  end

  subject { Bobot::Event::AccountLinking.new(payload) }

  describe '.messaging' do
    it 'returns the original payload' do
      expect(subject.messaging).to eq(payload)
    end
  end

  describe '.sender' do
    it 'returns the sender' do
      expect(subject.sender).to eq(payload['sender'])
    end
  end

  describe '.recipient' do
    it 'returns the recipient' do
      expect(subject.recipient).to eq(payload['recipient'])
    end
  end

  describe '.sent_at' do
    it 'returns when the postback was sent' do
      expect(subject.sent_at).to eq(Time.zone.at(payload['timestamp'] / 1000))
    end
  end

  describe '.status' do
    it 'returns linking status defined with the entry point' do
      expect(subject.status).to eq(payload['account_linking']['status'])
    end
  end

  describe '.authorization_code' do
    it 'returns authorization code defined with the entry point' do
      expect(subject.authorization_code)
        .to eq(payload['account_linking']['authorization_code'])
    end
  end
end

Version data entries

21 entries across 21 versions & 1 rubygems

Version Path
bobot-3.7.3 spec/bobot/event/account_linking_spec.rb
bobot-3.7.2 spec/bobot/event/account_linking_spec.rb
bobot-3.6.3 spec/bobot/event/account_linking_spec.rb
bobot-3.6.0 spec/bobot/event/account_linking_spec.rb
bobot-3.5.2 spec/bobot/event/account_linking_spec.rb
bobot-3.5.1 spec/bobot/event/account_linking_spec.rb
bobot-3.5.0 spec/bobot/event/account_linking_spec.rb
bobot-3.0.7 spec/bobot/event/account_linking_spec.rb
bobot-3.0.6 spec/bobot/event/account_linking_spec.rb
bobot-3.0.5 spec/bobot/event/account_linking_spec.rb
bobot-3.0.3 spec/bobot/event/account_linking_spec.rb
bobot-3.0.2 spec/bobot/event/account_linking_spec.rb
bobot-3.0.1 spec/bobot/event/account_linking_spec.rb
bobot-2.6.2 spec/bobot/event/account_linking_spec.rb
bobot-2.6.1 spec/bobot/event/account_linking_spec.rb
bobot-2.6.0 spec/bobot/event/account_linking_spec.rb
bobot-2.5.0 spec/bobot/event/account_linking_spec.rb
bobot-2.3.0 spec/bobot/event/account_linking_spec.rb
bobot-2.1.0 spec/bobot/event/account_linking_spec.rb
bobot-1.0.53 spec/bobot/event/account_linking_spec.rb