From 4f2d2c90f7c32a9113ccce440411ec80374ee385 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Sat, 27 Apr 2013 23:50:17 +0300 Subject: Move Gitlab::Git out of gitlab core --- spec/lib/gitlab/git/commit_spec.rb | 40 ----------- spec/lib/gitlab/git/diff_spec.rb | 34 --------- spec/lib/gitlab/git/repository_spec.rb | 123 --------------------------------- spec/lib/gitlab/git/stats_spec.rb | 28 -------- 4 files changed, 225 deletions(-) delete mode 100644 spec/lib/gitlab/git/commit_spec.rb delete mode 100644 spec/lib/gitlab/git/diff_spec.rb delete mode 100644 spec/lib/gitlab/git/repository_spec.rb delete mode 100644 spec/lib/gitlab/git/stats_spec.rb (limited to 'spec/lib') diff --git a/spec/lib/gitlab/git/commit_spec.rb b/spec/lib/gitlab/git/commit_spec.rb deleted file mode 100644 index bf2cd98eba1..00000000000 --- a/spec/lib/gitlab/git/commit_spec.rb +++ /dev/null @@ -1,40 +0,0 @@ -require "spec_helper" - -describe Gitlab::Git::Commit do - let(:commit) { create(:project_with_code).repository.commit } - - describe "Commit info" do - before do - @committer = double( - email: 'mike@smith.com', - name: 'Mike Smith' - ) - - @author = double( - email: 'john@smith.com', - name: 'John Smith' - ) - - @raw_commit = double( - id: "bcf03b5de6abcf03b5de6c", - author: @author, - committer: @committer, - committed_date: Date.yesterday, - authored_date: Date.yesterday, - parents: [], - message: 'Refactoring specs' - ) - - @commit = Gitlab::Git::Commit.new(@raw_commit) - end - - it { @commit.short_id.should == "bcf03b5de6a" } - it { @commit.safe_message.should == @raw_commit.message } - it { @commit.created_at.should == @raw_commit.committed_date } - it { @commit.author_email.should == @author.email } - it { @commit.author_name.should == @author.name } - it { @commit.committer_name.should == @committer.name } - it { @commit.committer_email.should == @committer.email } - it { @commit.different_committer?.should be_true } - end -end diff --git a/spec/lib/gitlab/git/diff_spec.rb b/spec/lib/gitlab/git/diff_spec.rb deleted file mode 100644 index 5191b1190a6..00000000000 --- a/spec/lib/gitlab/git/diff_spec.rb +++ /dev/null @@ -1,34 +0,0 @@ -require "spec_helper" - -describe Gitlab::Git::Diff do - before do - @raw_diff_hash = { - diff: 'Hello world', - new_path: 'temp.rb', - old_path: 'test.rb', - a_mode: '100644', - b_mode: '100644', - new_file: false, - renamed_file: true, - deleted_file: false, - } - - @grit_diff = double('Grit::Diff', @raw_diff_hash) - end - - context 'init from grit' do - before do - @diff = Gitlab::Git::Diff.new(@raw_diff_hash) - end - - it { @diff.to_hash.should == @raw_diff_hash } - end - - context 'init from hash' do - before do - @diff = Gitlab::Git::Diff.new(@grit_diff) - end - - it { @diff.to_hash.should == @raw_diff_hash } - end -end diff --git a/spec/lib/gitlab/git/repository_spec.rb b/spec/lib/gitlab/git/repository_spec.rb deleted file mode 100644 index 2b0550aa72a..00000000000 --- a/spec/lib/gitlab/git/repository_spec.rb +++ /dev/null @@ -1,123 +0,0 @@ -require "spec_helper" - -describe Gitlab::Git::Repository do - let(:repository) { Gitlab::Git::Repository.new('gitlabhq', 'master') } - - describe "Respond to" do - subject { repository } - - it { should respond_to(:repo) } - it { should respond_to(:tree) } - it { should respond_to(:root_ref) } - it { should respond_to(:tags) } - it { should respond_to(:commit) } - it { should respond_to(:commits) } - it { should respond_to(:commits_between) } - it { should respond_to(:commits_with_refs) } - end - - - describe "#discover_default_branch" do - let(:master) { 'master' } - let(:stable) { 'stable' } - - it "returns 'master' when master exists" do - repository.should_receive(:branch_names).at_least(:once).and_return([stable, master]) - repository.discover_default_branch.should == 'master' - end - - it "returns non-master when master exists but default branch is set to something else" do - repository.root_ref = 'stable' - repository.should_receive(:branch_names).at_least(:once).and_return([stable, master]) - repository.discover_default_branch.should == 'stable' - end - - it "returns a non-master branch when only one exists" do - repository.should_receive(:branch_names).at_least(:once).and_return([stable]) - repository.discover_default_branch.should == 'stable' - end - - it "returns nil when no branch exists" do - repository.should_receive(:branch_names).at_least(:once).and_return([]) - repository.discover_default_branch.should be_nil - end - end - - describe :commit do - it "should return first head commit if without params" do - repository.commit.id.should == repository.repo.commits.first.id - end - - it "should return valid commit" do - repository.commit(ValidCommit::ID).should be_valid_commit - end - - it "should return nil" do - repository.commit("+123_4532530XYZ").should be_nil - end - end - - describe :tree do - before do - @commit = repository.commit(ValidCommit::ID) - end - - it "should raise error w/o arguments" do - lambda { repository.tree }.should raise_error - end - - it "should return root tree for commit" do - tree = repository.tree(@commit) - tree.contents.size.should == ValidCommit::FILES_COUNT - tree.contents.map(&:name).should == ValidCommit::FILES - end - - it "should return root tree for commit with correct path" do - tree = repository.tree(@commit, ValidCommit::C_FILE_PATH) - tree.contents.map(&:name).should == ValidCommit::C_FILES - end - - it "should return root tree for commit with incorrect path" do - repository.tree(@commit, "invalid_path").should be_nil - end - end - - describe "commits" do - subject do - commits = repository.commits('master', 'app', 3, 1) - commits.map { |c| c.id } - end - - it { should have(3).elements } - it { should include("8716fc78f3c65bbf7bcf7b574febd583bc5d2812") } - it { should_not include("bcf03b5de6c33f3869ef70d68cf06e679d1d7f9a") } - end - - describe "commits_between" do - subject do - commits = repository.commits_between("3a4b4fb4cde7809f033822a171b9feae19d41fff", - "8470d70da67355c9c009e4401746b1d5410af2e3") - commits.map { |c| c.id } - end - - it { should have(3).elements } - it { should include("f0f14c8eaba69ebddd766498a9d0b0e79becd633") } - it { should_not include("bcf03b5de6c33f3869ef70d68cf06e679d1d7f9a") } - end - - describe "branch names" do - subject { repository.branch_names } - - it { should have(32).elements } - it { should include("master") } - it { should_not include("branch-from-space") } - end - - describe "tag names" do - subject { repository.tag_names } - - it { should have(16).elements } - it { should include("v1.2.0") } - it { should_not include("v5.0.0") } - end -end diff --git a/spec/lib/gitlab/git/stats_spec.rb b/spec/lib/gitlab/git/stats_spec.rb deleted file mode 100644 index 96b04f17e91..00000000000 --- a/spec/lib/gitlab/git/stats_spec.rb +++ /dev/null @@ -1,28 +0,0 @@ -require "spec_helper" - -describe Gitlab::Git::Stats do - let(:repository) { Gitlab::Git::Repository.new('gitlabhq', 'master') } - - before do - @stats = Gitlab::Git::Stats.new(repository.raw, 'master') - end - - describe :authors do - let(:author) { @stats.authors.first } - - it { author.name.should == 'Dmitriy Zaporozhets' } - it { author.email.should == 'dmitriy.zaporozhets@gmail.com' } - it { author.commits.should == 254 } - end - - describe :graph do - let(:graph) { @stats.graph } - - it { graph.labels.should include Date.today.stamp('Aug 23') } - it { graph.commits.should be_kind_of(Array) } - it { graph.weeks.should == 4 } - end - - it { @stats.commits_count.should == 918 } - it { @stats.files_count.should == 550 } -end -- cgit v1.2.3