Skip to content

Commit

Permalink
Add specs for token base model
Browse files Browse the repository at this point in the history
  • Loading branch information
krauselukas authored and Dany Marcoux committed Apr 26, 2021
1 parent 8579cc1 commit 397808d
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 6 deletions.
6 changes: 0 additions & 6 deletions src/api/spec/models/token/service_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,4 @@
it { expect(token).not_to be_valid_signature(nil, body) }
end
end

describe '.token_type' do
it { expect(described_class.token_type('release')).to eq(Token::Release) }
it { expect(described_class.token_type('rebuild')).to eq(Token::Rebuild) }
it { expect(described_class.token_type('everythingelse')).to eq(Token::Service) }
end
end
23 changes: 23 additions & 0 deletions src/api/spec/models/token_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
require 'rails_helper'

RSpec.describe Token, type: :model do
describe 'validations' do
let(:release_token) { create(:release_token) }

it { expect(release_token).to validate_uniqueness_of(:string) }
it { is_expected.to have_secure_token(:string) }
it { is_expected.to validate_presence_of(:user) }
end

describe '.token_type' do
it { expect(described_class.token_type('release')).to eq(Token::Release) }
it { expect(described_class.token_type('rebuild')).to eq(Token::Rebuild) }
it { expect(described_class.token_type('everythingelse')).to eq(Token::Service) }
end

describe '#call' do
it 'raises an exception' do
expect { described_class.new.call({}) }.to raise_error(AbstractMethodCalled, 'AbstractMethodCalled')
end
end
end

0 comments on commit 397808d

Please sign in to comment.