diff options
author | Hiroyuki Sato <h-sato@ruby-dev.jp> | 2016-12-16 14:02:00 +0900 |
---|---|---|
committer | Hiroyuki Sato <h-sato@ruby-dev.jp> | 2016-12-20 18:24:24 +0900 |
commit | 1da8bd8f049d0803ce8552f22ddf7a08206c9fb6 (patch) | |
tree | 22565c6b88d714937eae9318c7d03f983005eb1f /spec | |
parent | 1f1927571990ab44c7a45fbc436438756189d783 (diff) | |
download | gitlab-ce-1da8bd8f049d0803ce8552f22ddf7a08206c9fb6.tar.gz |
Add specs.
Diffstat (limited to 'spec')
-rw-r--r-- | spec/models/repository_spec.rb | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/spec/models/repository_spec.rb b/spec/models/repository_spec.rb index b5a42edd192..9c4ce13e223 100644 --- a/spec/models/repository_spec.rb +++ b/spec/models/repository_spec.rb @@ -139,6 +139,27 @@ describe Repository, models: true do it { is_expected.to eq('c1acaa58bbcbc3eafe538cb8274ba387047b69f8') } end + describe '#last_commit_id_for_path' do + subject { repository.last_commit_id_for_path(sample_commit.id, '.gitignore') } + + it { is_expected.to eq('c1acaa58bbcbc3eafe538cb8274ba387047b69f8') } + end + + describe '#cache_last_commit_id_for_path' do + subject { repository.cache_last_commit_id_for_path(sample_commit.id, '.gitignore') } + let(:cache) { repository.send(:cache) } + let(:key) { "last_commit_id_for_path:#{sample_commit.id}:#{Digest::SHA1.digest('.gitignore')}" } + before { cache.expire(key) } + after { cache.expire(key) } + + it "caches #last_commit_id_for_path" do + expect(repository).to receive(:last_commit_id_for_path).once.and_return('c1acaa58bbcbc3eafe538cb8274ba387047b69f8') + 2.times do + is_expected.to eq('c1acaa58bbcbc3eafe538cb8274ba387047b69f8') + end + end + end + describe '#find_commits_by_message' do it 'returns commits with messages containing a given string' do commit_ids = repository.find_commits_by_message('submodule').map(&:id) |