OSDN Git Service

Fixed protected branches and file edit
authorDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
Fri, 4 Jan 2013 19:45:30 +0000 (21:45 +0200)
committerDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
Fri, 4 Jan 2013 19:45:30 +0000 (21:45 +0200)
app/controllers/admin/users_controller.rb
app/controllers/tree_controller.rb
app/models/users_project.rb
app/views/protected_branches/index.html.haml
app/views/repositories/_feed.html.haml
features/steps/project/create_project.rb
features/steps/project/project_browse_commits.rb
spec/models/commit_spec.rb
spec/support/stubbed_repository.rb

index b255c73..8669f5d 100644 (file)
@@ -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]
     )
 
index 725f48f..2151bd7 100644 (file)
@@ -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
index 450eb3d..362b1a5 100644 (file)
@@ -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,
index f408fd1..098f8d5 100644 (file)
@@ -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
index 496328b..4438013 100644 (file)
@@ -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
index b9b4534..0d97277 100644 (file)
@@ -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
index aef1d04..3433c2b 100644 (file)
@@ -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
 
index e760c50..9130102 100644 (file)
@@ -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) }
index 0e5628d..e6e194d 100644 (file)
@@ -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