summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2013-01-04 21:45:30 +0200
committerDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2013-01-04 21:45:30 +0200
commitef5b36eaaf92db19ae90cc599c3f64b865bdc4d5 (patch)
tree4dd03fbf865b82a93cdec1f5d9d44c6b1d211d02
parentafbdbb0c959affbdb8725eafb8169025a8aede1e (diff)
downloadgitlab-ce-ef5b36eaaf92db19ae90cc599c3f64b865bdc4d5.tar.gz
Fixed protected branches and file edit
-rw-r--r--app/controllers/admin/users_controller.rb4
-rw-r--r--app/controllers/tree_controller.rb2
-rw-r--r--app/models/users_project.rb10
-rw-r--r--app/views/protected_branches/index.html.haml2
-rw-r--r--app/views/repositories/_feed.html.haml2
-rw-r--r--features/steps/project/create_project.rb4
-rw-r--r--features/steps/project/project_browse_commits.rb2
-rw-r--r--spec/models/commit_spec.rb2
-rw-r--r--spec/support/stubbed_repository.rb13
9 files changed, 21 insertions, 20 deletions
diff --git a/app/controllers/admin/users_controller.rb b/app/controllers/admin/users_controller.rb
index b255c73a21f..8669f5d1d38 100644
--- a/app/controllers/admin/users_controller.rb
+++ b/app/controllers/admin/users_controller.rb
@@ -19,9 +19,9 @@ class Admin::UsersController < AdminController
def team_update
@admin_user = User.find(params[:id])
- UsersProject.user_bulk_import(
- @admin_user,
+ UsersProject.add_users_into_projects(
params[:project_ids],
+ [@admin_user.id],
params[:project_access]
)
diff --git a/app/controllers/tree_controller.rb b/app/controllers/tree_controller.rb
index 725f48fa014..2151bd7cbbd 100644
--- a/app/controllers/tree_controller.rb
+++ b/app/controllers/tree_controller.rb
@@ -22,7 +22,7 @@ class TreeController < ProjectResourceController
end
def edit
- @last_commit = @project.last_commit_for(@ref, @path).sha
+ @last_commit = @project.repository.last_commit_for(@ref, @path).sha
end
def update
diff --git a/app/models/users_project.rb b/app/models/users_project.rb
index 450eb3d59fd..362b1a5d8e5 100644
--- a/app/models/users_project.rb
+++ b/app/models/users_project.rb
@@ -128,16 +128,6 @@ class UsersProject < ActiveRecord::Base
end
end
- # TODO: depreceate in future in favor of add_users_into_projects
- def bulk_import(project, user_ids, project_access)
- add_users_into_projects([project.id], user_ids, project_access)
- end
-
- # TODO: depreceate in future in favor of add_users_into_projects
- def user_bulk_import(user, project_ids, project_access)
- add_users_into_projects(project_ids, [user.id], project_access)
- end
-
def roles_hash
{
guest: GUEST,
diff --git a/app/views/protected_branches/index.html.haml b/app/views/protected_branches/index.html.haml
index f408fd16c2c..098f8d55bb3 100644
--- a/app/views/protected_branches/index.html.haml
+++ b/app/views/protected_branches/index.html.haml
@@ -36,7 +36,7 @@
%td
= link_to project_commits_path(@project, branch.name) do
%strong= branch.name
- - if branch.name == @project.root_ref
+ - if @project.root_ref?(branch.name)
%span.label default
%td
- if branch.commit
diff --git a/app/views/repositories/_feed.html.haml b/app/views/repositories/_feed.html.haml
index 496328baca5..44380133718 100644
--- a/app/views/repositories/_feed.html.haml
+++ b/app/views/repositories/_feed.html.haml
@@ -5,7 +5,7 @@
= link_to project_commits_path(@project, commit.head.name) do
%strong
= commit.head.name
- - if commit.head.name == @project.root_ref
+ - if @project.root_ref?(commit.head.name)
%span.label default
%td
diff --git a/features/steps/project/create_project.rb b/features/steps/project/create_project.rb
index b9b4534ed68..0d9727732c7 100644
--- a/features/steps/project/create_project.rb
+++ b/features/steps/project/create_project.rb
@@ -3,13 +3,13 @@ class CreateProject < Spinach::FeatureSteps
include SharedPaths
And 'fill project form with valid data' do
- fill_in 'project_name', :with => 'NewProject'
+ fill_in 'project_name', with: 'Empty'
click_button "Create project"
end
Then 'I should see project page' do
current_path.should == project_path(Project.last)
- page.should have_content "NewProject"
+ page.should have_content "Empty"
end
And 'I should see empty project instuctions' do
diff --git a/features/steps/project/project_browse_commits.rb b/features/steps/project/project_browse_commits.rb
index aef1d048349..3433c2ba5f6 100644
--- a/features/steps/project/project_browse_commits.rb
+++ b/features/steps/project/project_browse_commits.rb
@@ -48,7 +48,7 @@ class ProjectBrowseCommits < Spinach::FeatureSteps
page.should have_selector('ul.breadcrumb span.divider', count: 3)
page.should have_selector('ul.breadcrumb a', count: 4)
- find('ul.breadcrumb li:first a')['href'].should match(/#{@project.path}\/commits\/master\z/)
+ find('ul.breadcrumb li:first a')['href'].should match(/#{@project.path_with_namespace}\/commits\/master\z/)
find('ul.breadcrumb li:last a')['href'].should match(%r{master/app/models/project\.rb\z})
end
diff --git a/spec/models/commit_spec.rb b/spec/models/commit_spec.rb
index e760c501bd7..91301029e89 100644
--- a/spec/models/commit_spec.rb
+++ b/spec/models/commit_spec.rb
@@ -1,7 +1,7 @@
require 'spec_helper'
describe Commit do
- let(:commit) { create(:project).commit }
+ let(:commit) { create(:project).repository.commit }
describe CommitDecorator do
let(:decorator) { CommitDecorator.new(commit) }
diff --git a/spec/support/stubbed_repository.rb b/spec/support/stubbed_repository.rb
index 0e5628d05ff..e6e194d70f5 100644
--- a/spec/support/stubbed_repository.rb
+++ b/spec/support/stubbed_repository.rb
@@ -1,6 +1,17 @@
+require "repository"
+require "project"
+
# Stubs out all Git repository access done by models so that specs can run
# against fake repositories without Grit complaining that they don't exist.
class Project
+ def repository
+ if path == "empty" || !path
+ nil
+ else
+ GitLabTestRepo.new(path_with_namespace)
+ end
+ end
+
def satellite
FakeSatellite.new
end
@@ -16,7 +27,7 @@ class Project
end
end
-class Repository
+class GitLabTestRepo < Repository
def repo
@repo ||= Grit::Repo.new(Rails.root.join('tmp', 'repositories', 'gitlabhq'))
end