Commit afbdbb0c959affbdb8725eafb8169025a8aede1e
1 parent
dccd8b6e
Exists in
master
and in
4 other branches
Rspec fixes
Showing
22 changed files
with
149 additions
and
199 deletions
Show diff stats
app/views/compare/_form.html.haml
| @@ -28,7 +28,7 @@ | @@ -28,7 +28,7 @@ | ||
| 28 | 28 | ||
| 29 | :javascript | 29 | :javascript |
| 30 | $(function() { | 30 | $(function() { |
| 31 | - var availableTags = #{@project.ref_names.to_json}; | 31 | + var availableTags = #{@project.repository.ref_names.to_json}; |
| 32 | 32 | ||
| 33 | $("#from, #to").autocomplete({ | 33 | $("#from, #to").autocomplete({ |
| 34 | source: availableTags, | 34 | source: availableTags, |
features/steps/project/project_browse_commits.rb
| @@ -4,7 +4,7 @@ class ProjectBrowseCommits < Spinach::FeatureSteps | @@ -4,7 +4,7 @@ class ProjectBrowseCommits < Spinach::FeatureSteps | ||
| 4 | include SharedPaths | 4 | include SharedPaths |
| 5 | 5 | ||
| 6 | Then 'I see project commits' do | 6 | Then 'I see project commits' do |
| 7 | - commit = @project.commit | 7 | + commit = @project.repository.commit |
| 8 | page.should have_content(@project.name) | 8 | page.should have_content(@project.name) |
| 9 | page.should have_content(commit.message) | 9 | page.should have_content(commit.message) |
| 10 | page.should have_content(commit.id.to_s[0..5]) | 10 | page.should have_content(commit.id.to_s[0..5]) |
| @@ -15,7 +15,7 @@ class ProjectBrowseCommits < Spinach::FeatureSteps | @@ -15,7 +15,7 @@ class ProjectBrowseCommits < Spinach::FeatureSteps | ||
| 15 | end | 15 | end |
| 16 | 16 | ||
| 17 | Then 'I see commits atom feed' do | 17 | Then 'I see commits atom feed' do |
| 18 | - commit = CommitDecorator.decorate(@project.commit) | 18 | + commit = CommitDecorator.decorate(@project.repository.commit) |
| 19 | page.response_headers['Content-Type'].should have_content("application/atom+xml") | 19 | page.response_headers['Content-Type'].should have_content("application/atom+xml") |
| 20 | page.body.should have_selector("title", :text => "Recent commits to #{@project.name}") | 20 | page.body.should have_selector("title", :text => "Recent commits to #{@project.name}") |
| 21 | page.body.should have_selector("author email", :text => commit.author_email) | 21 | page.body.should have_selector("author email", :text => commit.author_email) |
lib/api/notes.rb
| @@ -13,7 +13,7 @@ module Gitlab | @@ -13,7 +13,7 @@ module Gitlab | ||
| 13 | # Example Request: | 13 | # Example Request: |
| 14 | # GET /projects/:id/notes | 14 | # GET /projects/:id/notes |
| 15 | get ":id/notes" do | 15 | get ":id/notes" do |
| 16 | - @notes = user_project.common_notes | 16 | + @notes = user_project.notes.common |
| 17 | present paginate(@notes), with: Entities::Note | 17 | present paginate(@notes), with: Entities::Note |
| 18 | end | 18 | end |
| 19 | 19 | ||
| @@ -25,7 +25,7 @@ module Gitlab | @@ -25,7 +25,7 @@ module Gitlab | ||
| 25 | # Example Request: | 25 | # Example Request: |
| 26 | # GET /projects/:id/notes/:note_id | 26 | # GET /projects/:id/notes/:note_id |
| 27 | get ":id/notes/:note_id" do | 27 | get ":id/notes/:note_id" do |
| 28 | - @note = user_project.common_notes.find(params[:note_id]) | 28 | + @note = user_project.notes.common.find(params[:note_id]) |
| 29 | present @note, with: Entities::Note | 29 | present @note, with: Entities::Note |
| 30 | end | 30 | end |
| 31 | 31 |
lib/api/projects.rb
| @@ -257,7 +257,7 @@ module Gitlab | @@ -257,7 +257,7 @@ module Gitlab | ||
| 257 | per_page = params[:per_page] || 20 | 257 | per_page = params[:per_page] || 20 |
| 258 | ref = params[:ref_name] || user_project.try(:default_branch) || 'master' | 258 | ref = params[:ref_name] || user_project.try(:default_branch) || 'master' |
| 259 | 259 | ||
| 260 | - commits = user_project.commits(ref, nil, per_page, page * per_page) | 260 | + commits = user_project.repository.commits(ref, nil, per_page, page * per_page) |
| 261 | present CommitDecorator.decorate(commits), with: Entities::RepoCommit | 261 | present CommitDecorator.decorate(commits), with: Entities::RepoCommit |
| 262 | end | 262 | end |
| 263 | 263 | ||
| @@ -375,10 +375,10 @@ module Gitlab | @@ -375,10 +375,10 @@ module Gitlab | ||
| 375 | 375 | ||
| 376 | ref = params[:sha] | 376 | ref = params[:sha] |
| 377 | 377 | ||
| 378 | - commit = user_project.commit ref | 378 | + commit = user_project.repository.commit ref |
| 379 | not_found! "Commit" unless commit | 379 | not_found! "Commit" unless commit |
| 380 | 380 | ||
| 381 | - tree = Tree.new commit.tree, user_project, ref, params[:filepath] | 381 | + tree = Tree.new commit.tree, ref, params[:filepath] |
| 382 | not_found! "File" unless tree.try(:tree) | 382 | not_found! "File" unless tree.try(:tree) |
| 383 | 383 | ||
| 384 | content_type tree.mime_type | 384 | content_type tree.mime_type |
spec/controllers/commit_controller_spec.rb
| @@ -3,12 +3,12 @@ require 'spec_helper' | @@ -3,12 +3,12 @@ require 'spec_helper' | ||
| 3 | describe CommitController do | 3 | describe CommitController do |
| 4 | let(:project) { create(:project) } | 4 | let(:project) { create(:project) } |
| 5 | let(:user) { create(:user) } | 5 | let(:user) { create(:user) } |
| 6 | - let(:commit) { project.last_commit_for("master") } | 6 | + let(:commit) { project.repository.last_commit_for("master") } |
| 7 | 7 | ||
| 8 | before do | 8 | before do |
| 9 | sign_in(user) | 9 | sign_in(user) |
| 10 | 10 | ||
| 11 | - project.add_access(user, :read, :admin) | 11 | + project.team << [user, :master] |
| 12 | end | 12 | end |
| 13 | 13 | ||
| 14 | describe "#show" do | 14 | describe "#show" do |
spec/controllers/commits_controller_spec.rb
| @@ -7,7 +7,7 @@ describe CommitsController do | @@ -7,7 +7,7 @@ describe CommitsController do | ||
| 7 | before do | 7 | before do |
| 8 | sign_in(user) | 8 | sign_in(user) |
| 9 | 9 | ||
| 10 | - project.add_access(user, :read, :admin) | 10 | + project.team << [user, :master] |
| 11 | end | 11 | end |
| 12 | 12 | ||
| 13 | describe "GET show" do | 13 | describe "GET show" do |
spec/controllers/merge_requests_controller_spec.rb
| @@ -7,7 +7,7 @@ describe MergeRequestsController do | @@ -7,7 +7,7 @@ describe MergeRequestsController do | ||
| 7 | 7 | ||
| 8 | before do | 8 | before do |
| 9 | sign_in(user) | 9 | sign_in(user) |
| 10 | - project.add_access(user, :read, :admin) | 10 | + project.team << [user, :master] |
| 11 | MergeRequestsController.any_instance.stub(validates_merge_request: true) | 11 | MergeRequestsController.any_instance.stub(validates_merge_request: true) |
| 12 | end | 12 | end |
| 13 | 13 |
spec/controllers/tree_controller_spec.rb
| @@ -7,7 +7,7 @@ describe TreeController do | @@ -7,7 +7,7 @@ describe TreeController do | ||
| 7 | before do | 7 | before do |
| 8 | sign_in(user) | 8 | sign_in(user) |
| 9 | 9 | ||
| 10 | - project.add_access(user, :read, :admin) | 10 | + project.team << [user, :master] |
| 11 | 11 | ||
| 12 | project.stub(:branches).and_return(['master', 'foo/bar/baz']) | 12 | project.stub(:branches).and_return(['master', 'foo/bar/baz']) |
| 13 | project.stub(:tags).and_return(['v1.0.0', 'v2.0.0']) | 13 | project.stub(:tags).and_return(['v1.0.0', 'v2.0.0']) |
spec/helpers/gitlab_markdown_helper_spec.rb
| @@ -4,7 +4,7 @@ describe GitlabMarkdownHelper do | @@ -4,7 +4,7 @@ describe GitlabMarkdownHelper do | ||
| 4 | let!(:project) { create(:project) } | 4 | let!(:project) { create(:project) } |
| 5 | 5 | ||
| 6 | let(:user) { create(:user, username: 'gfm') } | 6 | let(:user) { create(:user, username: 'gfm') } |
| 7 | - let(:commit) { CommitDecorator.decorate(project.commit) } | 7 | + let(:commit) { CommitDecorator.decorate(project.repository.commit) } |
| 8 | let(:issue) { create(:issue, project: project) } | 8 | let(:issue) { create(:issue, project: project) } |
| 9 | let(:merge_request) { create(:merge_request, project: project) } | 9 | let(:merge_request) { create(:merge_request, project: project) } |
| 10 | let(:snippet) { create(:snippet, project: project) } | 10 | let(:snippet) { create(:snippet, project: project) } |
| @@ -85,7 +85,7 @@ describe GitlabMarkdownHelper do | @@ -85,7 +85,7 @@ describe GitlabMarkdownHelper do | ||
| 85 | let(:expected) { project_team_member_path(project, member) } | 85 | let(:expected) { project_team_member_path(project, member) } |
| 86 | 86 | ||
| 87 | before do | 87 | before do |
| 88 | - project.add_access(user, :admin) | 88 | + project.team << [user, :master] |
| 89 | end | 89 | end |
| 90 | 90 | ||
| 91 | it "should link using a simple name" do | 91 | it "should link using a simple name" do |
| @@ -314,7 +314,7 @@ describe GitlabMarkdownHelper do | @@ -314,7 +314,7 @@ describe GitlabMarkdownHelper do | ||
| 314 | end | 314 | end |
| 315 | 315 | ||
| 316 | it "should handle references in lists" do | 316 | it "should handle references in lists" do |
| 317 | - project.add_access(user, :admin) | 317 | + project.team << [user, :master] |
| 318 | 318 | ||
| 319 | actual = "\n* dark: ##{issue.id}\n* light by @#{member.user.username}" | 319 | actual = "\n* dark: ##{issue.id}\n* light by @#{member.user.username}" |
| 320 | 320 |
spec/models/project_repository_spec.rb
| @@ -1,159 +0,0 @@ | @@ -1,159 +0,0 @@ | ||
| 1 | -require 'spec_helper' | ||
| 2 | - | ||
| 3 | -describe Project, "Repository" do | ||
| 4 | - let(:project) { create(:project) } | ||
| 5 | - | ||
| 6 | - describe "#empty_repo?" do | ||
| 7 | - it "should return true if the repo doesn't exist" do | ||
| 8 | - project.stub(repo_exists?: false, has_commits?: true) | ||
| 9 | - project.should be_empty_repo | ||
| 10 | - end | ||
| 11 | - | ||
| 12 | - it "should return true if the repo has commits" do | ||
| 13 | - project.stub(repo_exists?: true, has_commits?: false) | ||
| 14 | - project.should be_empty_repo | ||
| 15 | - end | ||
| 16 | - | ||
| 17 | - it "should return false if the repo exists and has commits" do | ||
| 18 | - project.stub(repo_exists?: true, has_commits?: true) | ||
| 19 | - project.should_not be_empty_repo | ||
| 20 | - end | ||
| 21 | - end | ||
| 22 | - | ||
| 23 | - describe "#discover_default_branch" do | ||
| 24 | - let(:master) { 'master' } | ||
| 25 | - let(:stable) { 'stable' } | ||
| 26 | - | ||
| 27 | - it "returns 'master' when master exists" do | ||
| 28 | - project.should_receive(:branch_names).at_least(:once).and_return([stable, master]) | ||
| 29 | - project.discover_default_branch.should == 'master' | ||
| 30 | - end | ||
| 31 | - | ||
| 32 | - it "returns non-master when master exists but default branch is set to something else" do | ||
| 33 | - project.default_branch = 'stable' | ||
| 34 | - project.should_receive(:branch_names).at_least(:once).and_return([stable, master]) | ||
| 35 | - project.discover_default_branch.should == 'stable' | ||
| 36 | - end | ||
| 37 | - | ||
| 38 | - it "returns a non-master branch when only one exists" do | ||
| 39 | - project.should_receive(:branch_names).at_least(:once).and_return([stable]) | ||
| 40 | - project.discover_default_branch.should == 'stable' | ||
| 41 | - end | ||
| 42 | - | ||
| 43 | - it "returns nil when no branch exists" do | ||
| 44 | - project.should_receive(:branch_names).at_least(:once).and_return([]) | ||
| 45 | - project.discover_default_branch.should be_nil | ||
| 46 | - end | ||
| 47 | - end | ||
| 48 | - | ||
| 49 | - describe "#root_ref" do | ||
| 50 | - it "returns default_branch when set" do | ||
| 51 | - project.default_branch = 'stable' | ||
| 52 | - project.root_ref.should == 'stable' | ||
| 53 | - end | ||
| 54 | - | ||
| 55 | - it "returns 'master' when default_branch is nil" do | ||
| 56 | - project.default_branch = nil | ||
| 57 | - project.root_ref.should == 'master' | ||
| 58 | - end | ||
| 59 | - end | ||
| 60 | - | ||
| 61 | - describe "#root_ref?" do | ||
| 62 | - it "returns true when branch is root_ref" do | ||
| 63 | - project.default_branch = 'stable' | ||
| 64 | - project.root_ref?('stable').should be_true | ||
| 65 | - end | ||
| 66 | - | ||
| 67 | - it "returns false when branch is not root_ref" do | ||
| 68 | - project.default_branch = nil | ||
| 69 | - project.root_ref?('stable').should be_false | ||
| 70 | - end | ||
| 71 | - end | ||
| 72 | - | ||
| 73 | - describe :repo do | ||
| 74 | - it "should return valid repo" do | ||
| 75 | - project.repo.should be_kind_of(Grit::Repo) | ||
| 76 | - end | ||
| 77 | - | ||
| 78 | - it "should return nil" do | ||
| 79 | - lambda { Project.new(path: "invalid").repo }.should raise_error(Grit::NoSuchPathError) | ||
| 80 | - end | ||
| 81 | - | ||
| 82 | - it "should return nil" do | ||
| 83 | - lambda { Project.new.repo }.should raise_error(TypeError) | ||
| 84 | - end | ||
| 85 | - end | ||
| 86 | - | ||
| 87 | - describe :commit do | ||
| 88 | - it "should return first head commit if without params" do | ||
| 89 | - project.commit.id.should == project.repo.commits.first.id | ||
| 90 | - end | ||
| 91 | - | ||
| 92 | - it "should return valid commit" do | ||
| 93 | - project.commit(ValidCommit::ID).should be_valid_commit | ||
| 94 | - end | ||
| 95 | - | ||
| 96 | - it "should return nil" do | ||
| 97 | - project.commit("+123_4532530XYZ").should be_nil | ||
| 98 | - end | ||
| 99 | - end | ||
| 100 | - | ||
| 101 | - describe :tree do | ||
| 102 | - before do | ||
| 103 | - @commit = project.commit(ValidCommit::ID) | ||
| 104 | - end | ||
| 105 | - | ||
| 106 | - it "should raise error w/o arguments" do | ||
| 107 | - lambda { project.tree }.should raise_error | ||
| 108 | - end | ||
| 109 | - | ||
| 110 | - it "should return root tree for commit" do | ||
| 111 | - tree = project.tree(@commit) | ||
| 112 | - tree.contents.size.should == ValidCommit::FILES_COUNT | ||
| 113 | - tree.contents.map(&:name).should == ValidCommit::FILES | ||
| 114 | - end | ||
| 115 | - | ||
| 116 | - it "should return root tree for commit with correct path" do | ||
| 117 | - tree = project.tree(@commit, ValidCommit::C_FILE_PATH) | ||
| 118 | - tree.contents.map(&:name).should == ValidCommit::C_FILES | ||
| 119 | - end | ||
| 120 | - | ||
| 121 | - it "should return root tree for commit with incorrect path" do | ||
| 122 | - project.tree(@commit, "invalid_path").should be_nil | ||
| 123 | - end | ||
| 124 | - end | ||
| 125 | - | ||
| 126 | - describe "fresh commits" do | ||
| 127 | - let(:project) { create(:project) } | ||
| 128 | - | ||
| 129 | - it { project.fresh_commits(3).count.should == 3 } | ||
| 130 | - it { project.fresh_commits.first.id.should == "bcf03b5de6c33f3869ef70d68cf06e679d1d7f9a" } | ||
| 131 | - it { project.fresh_commits.last.id.should == "f403da73f5e62794a0447aca879360494b08f678" } | ||
| 132 | - end | ||
| 133 | - | ||
| 134 | - describe "commits_between" do | ||
| 135 | - let(:project) { create(:project) } | ||
| 136 | - | ||
| 137 | - subject do | ||
| 138 | - commits = project.commits_between("3a4b4fb4cde7809f033822a171b9feae19d41fff", | ||
| 139 | - "8470d70da67355c9c009e4401746b1d5410af2e3") | ||
| 140 | - commits.map { |c| c.id } | ||
| 141 | - end | ||
| 142 | - | ||
| 143 | - it { should have(3).elements } | ||
| 144 | - it { should include("f0f14c8eaba69ebddd766498a9d0b0e79becd633") } | ||
| 145 | - it { should_not include("bcf03b5de6c33f3869ef70d68cf06e679d1d7f9a") } | ||
| 146 | - end | ||
| 147 | - | ||
| 148 | - describe :valid_repo? do | ||
| 149 | - it "should be valid repo" do | ||
| 150 | - project = create(:project) | ||
| 151 | - project.valid_repo?.should be_true | ||
| 152 | - end | ||
| 153 | - | ||
| 154 | - it "should be invalid repo" do | ||
| 155 | - project = Project.new(name: "ok_name", path: "/INVALID_PATH/", path: "NEOK") | ||
| 156 | - project.valid_repo?.should be_false | ||
| 157 | - end | ||
| 158 | - end | ||
| 159 | -end |
spec/models/project_spec.rb
| @@ -84,7 +84,6 @@ describe Project do | @@ -84,7 +84,6 @@ describe Project do | ||
| 84 | it { should respond_to(:satellite) } | 84 | it { should respond_to(:satellite) } |
| 85 | it { should respond_to(:update_repository) } | 85 | it { should respond_to(:update_repository) } |
| 86 | it { should respond_to(:destroy_repository) } | 86 | it { should respond_to(:destroy_repository) } |
| 87 | - it { should respond_to(:archive_repo) } | ||
| 88 | 87 | ||
| 89 | # Authority Role | 88 | # Authority Role |
| 90 | it { should respond_to(:reset_access) } | 89 | it { should respond_to(:reset_access) } |
| @@ -94,14 +93,6 @@ describe Project do | @@ -94,14 +93,6 @@ describe Project do | ||
| 94 | it { should respond_to(:dev_access_for?) } | 93 | it { should respond_to(:dev_access_for?) } |
| 95 | it { should respond_to(:master_access_for?) } | 94 | it { should respond_to(:master_access_for?) } |
| 96 | 95 | ||
| 97 | - # Team Role | ||
| 98 | - it { should respond_to(:team_member_by_name_or_email) } | ||
| 99 | - it { should respond_to(:team_member_by_id) } | ||
| 100 | - it { should respond_to(:add_user_to_team) } | ||
| 101 | - it { should respond_to(:add_users_to_team) } | ||
| 102 | - it { should respond_to(:add_user_id_to_team) } | ||
| 103 | - it { should respond_to(:add_users_ids_to_team) } | ||
| 104 | - | ||
| 105 | # Project Push Role | 96 | # Project Push Role |
| 106 | it { should respond_to(:observe_push) } | 97 | it { should respond_to(:observe_push) } |
| 107 | it { should respond_to(:update_merge_requests) } | 98 | it { should respond_to(:update_merge_requests) } |
| @@ -253,4 +244,33 @@ describe Project do | @@ -253,4 +244,33 @@ describe Project do | ||
| 253 | it { @project.to_param.should == "gitlab-ci" } | 244 | it { @project.to_param.should == "gitlab-ci" } |
| 254 | end | 245 | end |
| 255 | end | 246 | end |
| 247 | + | ||
| 248 | + describe "#empty_repo?" do | ||
| 249 | + let(:project) { create(:project) } | ||
| 250 | + | ||
| 251 | + it "should return true if the repo doesn't exist" do | ||
| 252 | + project.stub(repo_exists?: false, has_commits?: true) | ||
| 253 | + project.should be_empty_repo | ||
| 254 | + end | ||
| 255 | + | ||
| 256 | + it "should return true if the repo has commits" do | ||
| 257 | + project.stub(repo_exists?: true, has_commits?: false) | ||
| 258 | + project.should be_empty_repo | ||
| 259 | + end | ||
| 260 | + | ||
| 261 | + it "should return false if the repo exists and has commits" do | ||
| 262 | + project.stub(repo_exists?: true, has_commits?: true) | ||
| 263 | + project.should_not be_empty_repo | ||
| 264 | + end | ||
| 265 | + end | ||
| 266 | + | ||
| 267 | + describe :repository do | ||
| 268 | + it "should return valid repo" do | ||
| 269 | + project.repository.should be_kind_of(Repository) | ||
| 270 | + end | ||
| 271 | + | ||
| 272 | + it "should return nil" do | ||
| 273 | + Project.new(path: "invalid").repository.should be_nil | ||
| 274 | + end | ||
| 275 | + end | ||
| 256 | end | 276 | end |
spec/models/repository_spec.rb
| 1 | describe Repository do | 1 | describe Repository do |
| 2 | + let(:project) { create(:project) } | ||
| 3 | + let(:repository) { project.repository } | ||
| 4 | + | ||
| 2 | describe "Respond to" do | 5 | describe "Respond to" do |
| 6 | + subject { repository } | ||
| 7 | + | ||
| 3 | it { should respond_to(:repo) } | 8 | it { should respond_to(:repo) } |
| 4 | it { should respond_to(:tree) } | 9 | it { should respond_to(:tree) } |
| 5 | it { should respond_to(:root_ref) } | 10 | it { should respond_to(:root_ref) } |
| @@ -11,4 +16,88 @@ describe Repository do | @@ -11,4 +16,88 @@ describe Repository do | ||
| 11 | it { should respond_to(:commits_since) } | 16 | it { should respond_to(:commits_since) } |
| 12 | it { should respond_to(:commits_between) } | 17 | it { should respond_to(:commits_between) } |
| 13 | end | 18 | end |
| 19 | + | ||
| 20 | + | ||
| 21 | + describe "#discover_default_branch" do | ||
| 22 | + let(:master) { 'master' } | ||
| 23 | + let(:stable) { 'stable' } | ||
| 24 | + | ||
| 25 | + it "returns 'master' when master exists" do | ||
| 26 | + repository.should_receive(:branch_names).at_least(:once).and_return([stable, master]) | ||
| 27 | + repository.discover_default_branch.should == 'master' | ||
| 28 | + end | ||
| 29 | + | ||
| 30 | + it "returns non-master when master exists but default branch is set to something else" do | ||
| 31 | + repository.default_branch = 'stable' | ||
| 32 | + repository.should_receive(:branch_names).at_least(:once).and_return([stable, master]) | ||
| 33 | + repository.discover_default_branch.should == 'stable' | ||
| 34 | + end | ||
| 35 | + | ||
| 36 | + it "returns a non-master branch when only one exists" do | ||
| 37 | + repository.should_receive(:branch_names).at_least(:once).and_return([stable]) | ||
| 38 | + repository.discover_default_branch.should == 'stable' | ||
| 39 | + end | ||
| 40 | + | ||
| 41 | + it "returns nil when no branch exists" do | ||
| 42 | + repository.should_receive(:branch_names).at_least(:once).and_return([]) | ||
| 43 | + repository.discover_default_branch.should be_nil | ||
| 44 | + end | ||
| 45 | + end | ||
| 46 | + | ||
| 47 | + describe :commit do | ||
| 48 | + it "should return first head commit if without params" do | ||
| 49 | + repository.commit.id.should == repository.repo.commits.first.id | ||
| 50 | + end | ||
| 51 | + | ||
| 52 | + it "should return valid commit" do | ||
| 53 | + repository.commit(ValidCommit::ID).should be_valid_commit | ||
| 54 | + end | ||
| 55 | + | ||
| 56 | + it "should return nil" do | ||
| 57 | + repository.commit("+123_4532530XYZ").should be_nil | ||
| 58 | + end | ||
| 59 | + end | ||
| 60 | + | ||
| 61 | + describe :tree do | ||
| 62 | + before do | ||
| 63 | + @commit = repository.commit(ValidCommit::ID) | ||
| 64 | + end | ||
| 65 | + | ||
| 66 | + it "should raise error w/o arguments" do | ||
| 67 | + lambda { repository.tree }.should raise_error | ||
| 68 | + end | ||
| 69 | + | ||
| 70 | + it "should return root tree for commit" do | ||
| 71 | + tree = repository.tree(@commit) | ||
| 72 | + tree.contents.size.should == ValidCommit::FILES_COUNT | ||
| 73 | + tree.contents.map(&:name).should == ValidCommit::FILES | ||
| 74 | + end | ||
| 75 | + | ||
| 76 | + it "should return root tree for commit with correct path" do | ||
| 77 | + tree = repository.tree(@commit, ValidCommit::C_FILE_PATH) | ||
| 78 | + tree.contents.map(&:name).should == ValidCommit::C_FILES | ||
| 79 | + end | ||
| 80 | + | ||
| 81 | + it "should return root tree for commit with incorrect path" do | ||
| 82 | + repository.tree(@commit, "invalid_path").should be_nil | ||
| 83 | + end | ||
| 84 | + end | ||
| 85 | + | ||
| 86 | + describe "fresh commits" do | ||
| 87 | + it { repository.fresh_commits(3).count.should == 3 } | ||
| 88 | + it { repository.fresh_commits.first.id.should == "bcf03b5de6c33f3869ef70d68cf06e679d1d7f9a" } | ||
| 89 | + it { repository.fresh_commits.last.id.should == "f403da73f5e62794a0447aca879360494b08f678" } | ||
| 90 | + end | ||
| 91 | + | ||
| 92 | + describe "commits_between" do | ||
| 93 | + subject do | ||
| 94 | + commits = repository.commits_between("3a4b4fb4cde7809f033822a171b9feae19d41fff", | ||
| 95 | + "8470d70da67355c9c009e4401746b1d5410af2e3") | ||
| 96 | + commits.map { |c| c.id } | ||
| 97 | + end | ||
| 98 | + | ||
| 99 | + it { should have(3).elements } | ||
| 100 | + it { should include("f0f14c8eaba69ebddd766498a9d0b0e79becd633") } | ||
| 101 | + it { should_not include("bcf03b5de6c33f3869ef70d68cf06e679d1d7f9a") } | ||
| 102 | + end | ||
| 14 | end | 103 | end |
spec/requests/api/issues_spec.rb
| @@ -6,7 +6,7 @@ describe Gitlab::API do | @@ -6,7 +6,7 @@ describe Gitlab::API do | ||
| 6 | let(:user) { create(:user) } | 6 | let(:user) { create(:user) } |
| 7 | let!(:project) { create(:project, namespace: user.namespace ) } | 7 | let!(:project) { create(:project, namespace: user.namespace ) } |
| 8 | let!(:issue) { create(:issue, author: user, assignee: user, project: project) } | 8 | let!(:issue) { create(:issue, author: user, assignee: user, project: project) } |
| 9 | - before { project.add_access(user, :read) } | 9 | + before { project.team << [user, :reporter] } |
| 10 | 10 | ||
| 11 | describe "GET /issues" do | 11 | describe "GET /issues" do |
| 12 | context "when unauthenticated" do | 12 | context "when unauthenticated" do |
spec/requests/api/merge_requests_spec.rb
| @@ -6,7 +6,7 @@ describe Gitlab::API do | @@ -6,7 +6,7 @@ describe Gitlab::API do | ||
| 6 | let(:user) { create(:user ) } | 6 | let(:user) { create(:user ) } |
| 7 | let!(:project) { create(:project, namespace: user.namespace ) } | 7 | let!(:project) { create(:project, namespace: user.namespace ) } |
| 8 | let!(:merge_request) { create(:merge_request, author: user, assignee: user, project: project, title: "Test") } | 8 | let!(:merge_request) { create(:merge_request, author: user, assignee: user, project: project, title: "Test") } |
| 9 | - before { project.add_access(user, :read) } | 9 | + before { project.team << [user, :reporters] } |
| 10 | 10 | ||
| 11 | describe "GET /projects/:id/merge_requests" do | 11 | describe "GET /projects/:id/merge_requests" do |
| 12 | context "when unauthenticated" do | 12 | context "when unauthenticated" do |
spec/requests/api/milestones_spec.rb
| @@ -7,7 +7,7 @@ describe Gitlab::API do | @@ -7,7 +7,7 @@ describe Gitlab::API do | ||
| 7 | let!(:project) { create(:project, namespace: user.namespace ) } | 7 | let!(:project) { create(:project, namespace: user.namespace ) } |
| 8 | let!(:milestone) { create(:milestone, project: project) } | 8 | let!(:milestone) { create(:milestone, project: project) } |
| 9 | 9 | ||
| 10 | - before { project.add_access(user, :read) } | 10 | + before { project.team << [user, :developer] } |
| 11 | 11 | ||
| 12 | describe "GET /projects/:id/milestones" do | 12 | describe "GET /projects/:id/milestones" do |
| 13 | it "should return project milestones" do | 13 | it "should return project milestones" do |
spec/requests/api/notes_spec.rb
| @@ -10,7 +10,7 @@ describe Gitlab::API do | @@ -10,7 +10,7 @@ describe Gitlab::API do | ||
| 10 | let!(:issue_note) { create(:note, noteable: issue, project: project, author: user) } | 10 | let!(:issue_note) { create(:note, noteable: issue, project: project, author: user) } |
| 11 | let!(:snippet_note) { create(:note, noteable: snippet, project: project, author: user) } | 11 | let!(:snippet_note) { create(:note, noteable: snippet, project: project, author: user) } |
| 12 | let!(:wall_note) { create(:note, project: project, author: user) } | 12 | let!(:wall_note) { create(:note, project: project, author: user) } |
| 13 | - before { project.add_access(user, :read) } | 13 | + before { project.team << [user, :reporter] } |
| 14 | 14 | ||
| 15 | describe "GET /projects/:id/notes" do | 15 | describe "GET /projects/:id/notes" do |
| 16 | context "when unauthenticated" do | 16 | context "when unauthenticated" do |
spec/requests/api/projects_spec.rb
| @@ -11,7 +11,7 @@ describe Gitlab::API do | @@ -11,7 +11,7 @@ describe Gitlab::API do | ||
| 11 | let!(:snippet) { create(:snippet, author: user, project: project, title: 'example') } | 11 | let!(:snippet) { create(:snippet, author: user, project: project, title: 'example') } |
| 12 | let!(:users_project) { create(:users_project, user: user, project: project, project_access: UsersProject::MASTER) } | 12 | let!(:users_project) { create(:users_project, user: user, project: project, project_access: UsersProject::MASTER) } |
| 13 | let!(:users_project2) { create(:users_project, user: user3, project: project, project_access: UsersProject::DEVELOPER) } | 13 | let!(:users_project2) { create(:users_project, user: user3, project: project, project_access: UsersProject::DEVELOPER) } |
| 14 | - before { project.add_access(user, :read) } | 14 | + before { project.team << [user, :reporter] } |
| 15 | 15 | ||
| 16 | describe "GET /projects" do | 16 | describe "GET /projects" do |
| 17 | context "when unauthenticated" do | 17 | context "when unauthenticated" do |
| @@ -226,14 +226,14 @@ describe Gitlab::API do | @@ -226,14 +226,14 @@ describe Gitlab::API do | ||
| 226 | 226 | ||
| 227 | describe "GET /projects/:id/repository/commits" do | 227 | describe "GET /projects/:id/repository/commits" do |
| 228 | context "authorized user" do | 228 | context "authorized user" do |
| 229 | - before { project.add_access(user2, :read) } | 229 | + before { project.team << [user2, :reporter] } |
| 230 | 230 | ||
| 231 | it "should return project commits" do | 231 | it "should return project commits" do |
| 232 | get api("/projects/#{project.id}/repository/commits", user) | 232 | get api("/projects/#{project.id}/repository/commits", user) |
| 233 | response.status.should == 200 | 233 | response.status.should == 200 |
| 234 | 234 | ||
| 235 | json_response.should be_an Array | 235 | json_response.should be_an Array |
| 236 | - json_response.first['id'].should == project.commit.id | 236 | + json_response.first['id'].should == project.repository.commit.id |
| 237 | end | 237 | end |
| 238 | end | 238 | end |
| 239 | 239 |
spec/requests/atom/issues_spec.rb
| @@ -6,7 +6,7 @@ describe "Issues Feed" do | @@ -6,7 +6,7 @@ describe "Issues Feed" do | ||
| 6 | let!(:project) { create(:project, namespace: user.namespace) } | 6 | let!(:project) { create(:project, namespace: user.namespace) } |
| 7 | let!(:issue) { create(:issue, author: user, project: project) } | 7 | let!(:issue) { create(:issue, author: user, project: project) } |
| 8 | 8 | ||
| 9 | - before { project.add_access(user, :read, :write) } | 9 | + before { project.team << [user, :developer] } |
| 10 | 10 | ||
| 11 | context "when authenticated" do | 11 | context "when authenticated" do |
| 12 | it "should render atom feed" do | 12 | it "should render atom feed" do |
spec/requests/gitlab_flavored_markdown_spec.rb
| @@ -6,7 +6,7 @@ describe "Gitlab Flavored Markdown" do | @@ -6,7 +6,7 @@ describe "Gitlab Flavored Markdown" do | ||
| 6 | let(:merge_request) { create(:merge_request, project: project) } | 6 | let(:merge_request) { create(:merge_request, project: project) } |
| 7 | let(:fred) do | 7 | let(:fred) do |
| 8 | u = create(:user, name: "fred") | 8 | u = create(:user, name: "fred") |
| 9 | - project.add_access(u, :admin) | 9 | + project.team << [u, :master] |
| 10 | u | 10 | u |
| 11 | end | 11 | end |
| 12 | 12 | ||
| @@ -33,11 +33,11 @@ describe "Gitlab Flavored Markdown" do | @@ -33,11 +33,11 @@ describe "Gitlab Flavored Markdown" do | ||
| 33 | project.repo.gc_auto | 33 | project.repo.gc_auto |
| 34 | end | 34 | end |
| 35 | 35 | ||
| 36 | - let(:commit) { project.commits(@branch_name).first } | 36 | + let(:commit) { project.repository.commits(@branch_name).first } |
| 37 | 37 | ||
| 38 | before do | 38 | before do |
| 39 | login_as :user | 39 | login_as :user |
| 40 | - project.add_access(@user, :read, :write) | 40 | + project.team << [@user, :developer] |
| 41 | end | 41 | end |
| 42 | 42 | ||
| 43 | describe "for commits" do | 43 | describe "for commits" do |
spec/requests/projects_deploy_keys_spec.rb
| @@ -5,7 +5,7 @@ describe "Projects", "DeployKeys" do | @@ -5,7 +5,7 @@ describe "Projects", "DeployKeys" do | ||
| 5 | 5 | ||
| 6 | before do | 6 | before do |
| 7 | login_as :user | 7 | login_as :user |
| 8 | - project.add_access(@user, :read, :write, :admin) | 8 | + project.team << [@user, :master] |
| 9 | end | 9 | end |
| 10 | 10 | ||
| 11 | describe "GET /keys" do | 11 | describe "GET /keys" do |
spec/requests/search_spec.rb
| @@ -4,7 +4,7 @@ describe "Search" do | @@ -4,7 +4,7 @@ describe "Search" do | ||
| 4 | before do | 4 | before do |
| 5 | login_as :user | 5 | login_as :user |
| 6 | @project = create(:project) | 6 | @project = create(:project) |
| 7 | - @project.add_access(@user, :read) | 7 | + @project.team << [@user, :reporter] |
| 8 | visit search_path | 8 | visit search_path |
| 9 | fill_in "search", with: @project.name[0..3] | 9 | fill_in "search", with: @project.name[0..3] |
| 10 | click_button "Search" | 10 | click_button "Search" |
spec/requests/snippets_spec.rb
| @@ -5,7 +5,7 @@ describe "Snippets" do | @@ -5,7 +5,7 @@ describe "Snippets" do | ||
| 5 | 5 | ||
| 6 | before do | 6 | before do |
| 7 | login_as :user | 7 | login_as :user |
| 8 | - project.add_access(@user, :read, :write) | 8 | + project.team << [@user, :developer] |
| 9 | end | 9 | end |
| 10 | 10 | ||
| 11 | describe "GET /snippets" do | 11 | describe "GET /snippets" do |
| @@ -26,7 +26,7 @@ describe "Snippets" do | @@ -26,7 +26,7 @@ describe "Snippets" do | ||
| 26 | before do | 26 | before do |
| 27 | # admin access to remove snippet | 27 | # admin access to remove snippet |
| 28 | @user.users_projects.destroy_all | 28 | @user.users_projects.destroy_all |
| 29 | - project.add_access(@user, :read, :write, :admin) | 29 | + project.team << [@user, :master] |
| 30 | visit edit_project_snippet_path(project, @snippet) | 30 | visit edit_project_snippet_path(project, @snippet) |
| 31 | end | 31 | end |
| 32 | 32 |