Commit 31386adf53e0a029167de3b73f3ebda93b0e86a2

Authored by Dmitriy Zaporozhets
1 parent 6c660698

Fixed 500 error on branch and tag creation via UI

Also fixes issue with branch/tag removing via UI

Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
app/models/event.rb
@@ -56,11 +56,13 @@ class Event &lt; ActiveRecord::Base @@ -56,11 +56,13 @@ class Event &lt; ActiveRecord::Base
56 end 56 end
57 57
58 def create_ref_event(project, user, ref, action = 'add', prefix = 'refs/heads') 58 def create_ref_event(project, user, ref, action = 'add', prefix = 'refs/heads')
  59 + commit = project.repository.commit(ref.target)
  60 +
59 if action.to_s == 'add' 61 if action.to_s == 'add'
60 before = '00000000' 62 before = '00000000'
61 - after = ref.commit.id 63 + after = commit.id
62 else 64 else
63 - before = ref.commit.id 65 + before = commit.id
64 after = '00000000' 66 after = '00000000'
65 end 67 end
66 68
app/views/projects/branches/index.html.haml
@@ -4,7 +4,7 @@ @@ -4,7 +4,7 @@
4 = render "filter" 4 = render "filter"
5 .col-md-9 5 .col-md-9
6 - unless @branches.empty? 6 - unless @branches.empty?
7 - %ul.bordered-list.top-list 7 + %ul.bordered-list.top-list.all-branches
8 - @branches.each do |branch| 8 - @branches.each do |branch|
9 = render "projects/branches/branch", branch: branch 9 = render "projects/branches/branch", branch: branch
10 = paginate @branches, theme: 'gitlab' 10 = paginate @branches, theme: 'gitlab'
features/project/commits/branches.feature
@@ -16,11 +16,7 @@ Feature: Project Browse branches @@ -16,11 +16,7 @@ Feature: Project Browse branches
16 Given I click link "Protected" 16 Given I click link "Protected"
17 Then I should see "Shop" protected branches list 17 Then I should see "Shop" protected branches list
18 18
19 - # @wip  
20 - # Scenario: I can download project by branch  
21 -  
22 - # @wip  
23 - # Scenario: I can view protected branches  
24 -  
25 - # @wip  
26 - # Scenario: I can manage protected branches 19 + Scenario: I create a branch
  20 + Given I click new branch link
  21 + When I submit new branch form
  22 + Then I should see new branch created
features/steps/project/project_browse_branches.rb
@@ -3,33 +3,49 @@ class ProjectBrowseBranches &lt; Spinach::FeatureSteps @@ -3,33 +3,49 @@ class ProjectBrowseBranches &lt; Spinach::FeatureSteps
3 include SharedProject 3 include SharedProject
4 include SharedPaths 4 include SharedPaths
5 5
6 - Then 'I should see "Shop" recent branches list' do 6 + step 'I should see "Shop" recent branches list' do
7 page.should have_content "Branches" 7 page.should have_content "Branches"
8 page.should have_content "master" 8 page.should have_content "master"
9 end 9 end
10 10
11 - Given 'I click link "All"' do 11 + step 'I click link "All"' do
12 click_link "All" 12 click_link "All"
13 end 13 end
14 14
15 - Then 'I should see "Shop" all branches list' do 15 + step 'I should see "Shop" all branches list' do
16 page.should have_content "Branches" 16 page.should have_content "Branches"
17 page.should have_content "master" 17 page.should have_content "master"
18 end 18 end
19 19
20 - Given 'I click link "Protected"' do 20 + step 'I click link "Protected"' do
21 click_link "Protected" 21 click_link "Protected"
22 end 22 end
23 23
24 - Then 'I should see "Shop" protected branches list' do 24 + step 'I should see "Shop" protected branches list' do
25 within ".protected-branches-list" do 25 within ".protected-branches-list" do
26 page.should have_content "stable" 26 page.should have_content "stable"
27 page.should_not have_content "master" 27 page.should_not have_content "master"
28 end 28 end
29 end 29 end
30 30
31 - And 'project "Shop" has protected branches' do 31 + step 'project "Shop" has protected branches' do
32 project = Project.find_by(name: "Shop") 32 project = Project.find_by(name: "Shop")
33 project.protected_branches.create(name: "stable") 33 project.protected_branches.create(name: "stable")
34 end 34 end
  35 +
  36 + step 'I click new branch link' do
  37 + click_link "New branch"
  38 + end
  39 +
  40 + step 'I submit new branch form' do
  41 + fill_in 'branch_name', with: 'deploy_keys'
  42 + fill_in 'ref', with: 'master'
  43 + click_button 'Create branch'
  44 + end
  45 +
  46 + step 'I should see new branch created' do
  47 + within '.all-branches' do
  48 + page.should have_content 'deploy_keys'
  49 + end
  50 + end
35 end 51 end