Commit ef5b36eaaf92db19ae90cc599c3f64b865bdc4d5

Authored by Dmitriy Zaporozhets
1 parent afbdbb0c

Fixed protected branches and file edit

app/controllers/admin/users_controller.rb
... ... @@ -19,9 +19,9 @@ class Admin::UsersController < AdminController
19 19 def team_update
20 20 @admin_user = User.find(params[:id])
21 21  
22   - UsersProject.user_bulk_import(
23   - @admin_user,
  22 + UsersProject.add_users_into_projects(
24 23 params[:project_ids],
  24 + [@admin_user.id],
25 25 params[:project_access]
26 26 )
27 27  
... ...
app/controllers/tree_controller.rb
... ... @@ -22,7 +22,7 @@ class TreeController < ProjectResourceController
22 22 end
23 23  
24 24 def edit
25   - @last_commit = @project.last_commit_for(@ref, @path).sha
  25 + @last_commit = @project.repository.last_commit_for(@ref, @path).sha
26 26 end
27 27  
28 28 def update
... ...
app/models/users_project.rb
... ... @@ -128,16 +128,6 @@ class UsersProject < ActiveRecord::Base
128 128 end
129 129 end
130 130  
131   - # TODO: depreceate in future in favor of add_users_into_projects
132   - def bulk_import(project, user_ids, project_access)
133   - add_users_into_projects([project.id], user_ids, project_access)
134   - end
135   -
136   - # TODO: depreceate in future in favor of add_users_into_projects
137   - def user_bulk_import(user, project_ids, project_access)
138   - add_users_into_projects(project_ids, [user.id], project_access)
139   - end
140   -
141 131 def roles_hash
142 132 {
143 133 guest: GUEST,
... ...
app/views/protected_branches/index.html.haml
... ... @@ -36,7 +36,7 @@
36 36 %td
37 37 = link_to project_commits_path(@project, branch.name) do
38 38 %strong= branch.name
39   - - if branch.name == @project.root_ref
  39 + - if @project.root_ref?(branch.name)
40 40 %span.label default
41 41 %td
42 42 - if branch.commit
... ...
app/views/repositories/_feed.html.haml
... ... @@ -5,7 +5,7 @@
5 5 = link_to project_commits_path(@project, commit.head.name) do
6 6 %strong
7 7 = commit.head.name
8   - - if commit.head.name == @project.root_ref
  8 + - if @project.root_ref?(commit.head.name)
9 9 %span.label default
10 10  
11 11 %td
... ...
features/steps/project/create_project.rb
... ... @@ -3,13 +3,13 @@ class CreateProject < Spinach::FeatureSteps
3 3 include SharedPaths
4 4  
5 5 And 'fill project form with valid data' do
6   - fill_in 'project_name', :with => 'NewProject'
  6 + fill_in 'project_name', with: 'Empty'
7 7 click_button "Create project"
8 8 end
9 9  
10 10 Then 'I should see project page' do
11 11 current_path.should == project_path(Project.last)
12   - page.should have_content "NewProject"
  12 + page.should have_content "Empty"
13 13 end
14 14  
15 15 And 'I should see empty project instuctions' do
... ...
features/steps/project/project_browse_commits.rb
... ... @@ -48,7 +48,7 @@ class ProjectBrowseCommits < Spinach::FeatureSteps
48 48 page.should have_selector('ul.breadcrumb span.divider', count: 3)
49 49 page.should have_selector('ul.breadcrumb a', count: 4)
50 50  
51   - find('ul.breadcrumb li:first a')['href'].should match(/#{@project.path}\/commits\/master\z/)
  51 + find('ul.breadcrumb li:first a')['href'].should match(/#{@project.path_with_namespace}\/commits\/master\z/)
52 52 find('ul.breadcrumb li:last a')['href'].should match(%r{master/app/models/project\.rb\z})
53 53 end
54 54  
... ...
spec/models/commit_spec.rb
1 1 require 'spec_helper'
2 2  
3 3 describe Commit do
4   - let(:commit) { create(:project).commit }
  4 + let(:commit) { create(:project).repository.commit }
5 5  
6 6 describe CommitDecorator do
7 7 let(:decorator) { CommitDecorator.new(commit) }
... ...
spec/support/stubbed_repository.rb
  1 +require "repository"
  2 +require "project"
  3 +
1 4 # Stubs out all Git repository access done by models so that specs can run
2 5 # against fake repositories without Grit complaining that they don't exist.
3 6 class Project
  7 + def repository
  8 + if path == "empty" || !path
  9 + nil
  10 + else
  11 + GitLabTestRepo.new(path_with_namespace)
  12 + end
  13 + end
  14 +
4 15 def satellite
5 16 FakeSatellite.new
6 17 end
... ... @@ -16,7 +27,7 @@ class Project
16 27 end
17 28 end
18 29  
19   -class Repository
  30 +class GitLabTestRepo < Repository
20 31 def repo
21 32 @repo ||= Grit::Repo.new(Rails.root.join('tmp', 'repositories', 'gitlabhq'))
22 33 end
... ...