Welcome to mirror list, hosted at ThFree Co, Russian Federation.

sha_attribute_spec.rb « concerns « models « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 9e37c2b20c4aa50d850728c3dd626f67a38c785c (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
27
require 'spec_helper'

describe ShaAttribute do
  let(:model) { Class.new { include ShaAttribute } }

  before do
    columns = [
      double(:column, name: 'name', type: :text),
      double(:column, name: 'sha1', type: :binary)
    ]

    allow(model).to receive(:columns).and_return(columns)
  end

  describe '#sha_attribute' do
    it 'defines a SHA attribute for a binary column' do
      expect(model).to receive(:attribute)
        .with(:sha1, an_instance_of(Gitlab::Database::ShaAttribute))

      model.sha_attribute(:sha1)
    end

    it 'raises ArgumentError when the column type is not :binary' do
      expect { model.sha_attribute(:name) }.to raise_error(ArgumentError)
    end
  end
end