Moving repositories spec to roles. Added missing spec for project

This commit is contained in:
Dmitriy Zaporozhets 2012-12-15 12:32:09 +02:00
parent 120f50cff4
commit 0f7d3f591c
4 changed files with 101 additions and 98 deletions

View file

@ -1,7 +1,11 @@
.main_box
.top_box_content
%h4.box-title
- if @merge_request.closed
- if @merge_request.merged
.error.status_info
%i.icon-ok
Merged
- elsif @merge_request.closed
.error.status_info Closed
= gfm escape_once(@merge_request.title)

View file

@ -6,11 +6,6 @@
%span.label_branch= @merge_request.target_branch
%span.right
- if @merge_request.merged?
%span.btn.small.disabled.grouped.success
%strong
%i.icon-ok
= "MERGED"
- if can?(current_user, :modify_merge_request, @merge_request)
- if @merge_request.open?
.left.btn-group

View file

@ -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) }

View file

@ -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