diff options
author | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2012-12-15 12:32:09 +0200 |
---|---|---|
committer | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2012-12-15 12:32:09 +0200 |
commit | 0f7d3f591cea40d922250260326892ed49275968 (patch) | |
tree | 5002d91673073d27c9814eea3336565d6947201e /spec | |
parent | 120f50cff42dfb133bdf066061ebf305e872d55e (diff) | |
download | gitlab-ce-0f7d3f591cea40d922250260326892ed49275968.tar.gz |
Moving repositories spec to roles. Added missing spec for project
Diffstat (limited to 'spec')
-rw-r--r-- | spec/models/project_spec.rb | 99 | ||||
-rw-r--r-- | spec/roles/repository_spec.rb | 89 |
2 files changed, 96 insertions, 92 deletions
diff --git a/spec/models/project_spec.rb b/spec/models/project_spec.rb index db0d30727b4..b9eafc7fa1e 100644 --- a/spec/models/project_spec.rb +++ b/spec/models/project_spec.rb @@ -129,6 +129,13 @@ describe Project do it { should respond_to(:execute_hooks) } it { should respond_to(:post_receive_data) } it { should respond_to(:trigger_post_receive) } + + # Namespaced Project Role + it { should respond_to(:transfer) } + it { should respond_to(:name_with_namespace) } + it { should respond_to(:namespace_owner) } + it { should respond_to(:chief) } + it { should respond_to(:path_with_namespace) } end describe 'modules' do @@ -136,6 +143,7 @@ describe Project do it { should include_module(PushObserver) } it { should include_module(Authority) } it { should include_module(Team) } + it { should include_module(NamespacedProject) } end it "should return valid url to repo" do @@ -153,18 +161,6 @@ describe Project do project.web_url.should == "#{Gitlab.config.url}/somewhere" end - describe :valid_repo? do - it "should be valid repo" do - project = create(:project) - project.valid_repo?.should be_true - end - - it "should be invalid repo" do - project = Project.new(name: "ok_name", path: "/INVALID_PATH/", path: "NEOK") - project.valid_repo?.should be_false - end - end - describe "last_activity methods" do let(:project) { create(:project) } let(:last_event) { double(created_at: Time.now) } @@ -188,85 +184,6 @@ describe Project do end end - describe "fresh commits" do - let(:project) { create(:project) } - - it { project.fresh_commits(3).count.should == 3 } - it { project.fresh_commits.first.id.should == "bcf03b5de6c33f3869ef70d68cf06e679d1d7f9a" } - it { project.fresh_commits.last.id.should == "f403da73f5e62794a0447aca879360494b08f678" } - end - - describe "commits_between" do - let(:project) { create(:project) } - - subject do - commits = project.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 "Git methods" do - let(:project) { create(:project) } - - describe :repo do - it "should return valid repo" do - project.repo.should be_kind_of(Grit::Repo) - end - - it "should return nil" do - lambda { Project.new(path: "invalid").repo }.should raise_error(Grit::NoSuchPathError) - end - - it "should return nil" do - lambda { Project.new.repo }.should raise_error(TypeError) - end - end - - describe :commit do - it "should return first head commit if without params" do - project.commit.id.should == project.repo.commits.first.id - end - - it "should return valid commit" do - project.commit(ValidCommit::ID).should be_valid_commit - end - - it "should return nil" do - project.commit("+123_4532530XYZ").should be_nil - end - end - - describe :tree do - before do - @commit = project.commit(ValidCommit::ID) - end - - it "should raise error w/o arguments" do - lambda { project.tree }.should raise_error - end - - it "should return root tree for commit" do - tree = project.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 = project.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 - project.tree(@commit, "invalid_path").should be_nil - end - end - end - describe :update_merge_requests do let(:project) { create(:project) } diff --git a/spec/roles/repository_spec.rb b/spec/roles/repository_spec.rb index 3507585aa8d..e1d01cbfeaf 100644 --- a/spec/roles/repository_spec.rb +++ b/spec/roles/repository_spec.rb @@ -1,7 +1,7 @@ require 'spec_helper' describe Project, "Repository" do - let(:project) { build(:project) } + let(:project) { create(:project) } describe "#empty_repo?" do it "should return true if the repo doesn't exist" do @@ -69,4 +69,91 @@ describe Project, "Repository" do project.root_ref?('stable').should be_false end end + + describe :repo do + it "should return valid repo" do + project.repo.should be_kind_of(Grit::Repo) + end + + it "should return nil" do + lambda { Project.new(path: "invalid").repo }.should raise_error(Grit::NoSuchPathError) + end + + it "should return nil" do + lambda { Project.new.repo }.should raise_error(TypeError) + end + end + + describe :commit do + it "should return first head commit if without params" do + project.commit.id.should == project.repo.commits.first.id + end + + it "should return valid commit" do + project.commit(ValidCommit::ID).should be_valid_commit + end + + it "should return nil" do + project.commit("+123_4532530XYZ").should be_nil + end + end + + describe :tree do + before do + @commit = project.commit(ValidCommit::ID) + end + + it "should raise error w/o arguments" do + lambda { project.tree }.should raise_error + end + + it "should return root tree for commit" do + tree = project.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 = project.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 + project.tree(@commit, "invalid_path").should be_nil + end + end + + describe "fresh commits" do + let(:project) { create(:project) } + + it { project.fresh_commits(3).count.should == 3 } + it { project.fresh_commits.first.id.should == "bcf03b5de6c33f3869ef70d68cf06e679d1d7f9a" } + it { project.fresh_commits.last.id.should == "f403da73f5e62794a0447aca879360494b08f678" } + end + + describe "commits_between" do + let(:project) { create(:project) } + + subject do + commits = project.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 :valid_repo? do + it "should be valid repo" do + project = create(:project) + project.valid_repo?.should be_true + end + + it "should be invalid repo" do + project = Project.new(name: "ok_name", path: "/INVALID_PATH/", path: "NEOK") + project.valid_repo?.should be_false + end + end end |