aboutsummaryrefslogtreecommitdiffstats
path: root/spec/models/api/v1/api_key_spec.rb
blob: 5c5a6bde155476f949a809eef00bbb9ab522f507 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
require 'rails_helper'

RSpec.describe Api::V1::ApiKey, type: :model do
  subject { create(:api_key) }

  it { should validate_presence_of :organisation }


  it 'should have a valid factory' do
    expect(build(:api_key)).to be_valid
  end

  describe '#referential_from_token' do
    it 'should return referential' do
      referential = Api::V1::ApiKey.referential_from_token(subject.token)
      expect(referential).to eq(subject.referential)
    end
  end

  describe '#organisation_from_token' do
    it 'should return organisation' do
      organisation = Api::V1::ApiKey.organisation_from_token(subject.token)
      expect(organisation).to eq(subject.organisation)
    end
  end
end