Commit 3676838dc96bbe1c8c7eec7e6ca545c462dfc12d

Authored by Dmitriy Zaporozhets
1 parent 781f5aa6

Rspec test repo replaced.\nMerge Requests improved

app/assets/stylesheets/common.scss
... ... @@ -531,7 +531,7 @@ table a code {
531 531  
532 532 /** FLASH message **/
533 533 #flash_container {
534   - height:45px;
  534 + height:50px;
535 535 position:fixed;
536 536 z-index:10001;
537 537 top:0px;
... ... @@ -540,7 +540,7 @@ table a code {
540 540 overflow:hidden;
541 541 background:white;
542 542 cursor:pointer;
543   - border-bottom:1px solid #777;
  543 + border-bottom:1px solid #ccc;
544 544  
545 545 h4 {
546 546 color:#444;
... ... @@ -901,3 +901,23 @@ p.time {
901 901 margin:2px;
902 902 }
903 903 }
  904 +
  905 +.mr_source_commit ,
  906 +.mr_target_commit {
  907 + .commit {
  908 + list-style:none;
  909 + margin-top:10px;
  910 + &:hover {
  911 + background:none;
  912 + }
  913 + }
  914 +}
  915 +
  916 +.prettyprint {
  917 + background-color: #fefbf3;
  918 + padding: 9px;
  919 + border: 1px solid rgba(0,0,0,.2);
  920 + -webkit-box-shadow: 0 1px 2px rgba(0,0,0,.1);
  921 + -moz-box-shadow: 0 1px 2px rgba(0,0,0,.1);
  922 + box-shadow: 0 1px 2px rgba(0,0,0,.1);
  923 +}
... ...
app/controllers/merge_requests_controller.rb
... ... @@ -106,6 +106,14 @@ class MergeRequestsController < ApplicationController
106 106 end
107 107 end
108 108  
  109 + def branch_from
  110 + @commit = project.commit(params[:ref])
  111 + end
  112 +
  113 + def branch_to
  114 + @commit = project.commit(params[:ref])
  115 + end
  116 +
109 117 protected
110 118  
111 119 def merge_request
... ...
app/models/merge_request.rb
... ... @@ -12,6 +12,7 @@ class MergeRequest < ActiveRecord::Base
12 12 validates_presence_of :author_id
13 13 validates_presence_of :source_branch
14 14 validates_presence_of :target_branch
  15 + validate :validate_branches
15 16  
16 17 delegate :name,
17 18 :email,
... ... @@ -31,6 +32,13 @@ class MergeRequest < ActiveRecord::Base
31 32 scope :closed, where(:closed => true)
32 33 scope :assigned, lambda { |u| where(:assignee_id => u.id)}
33 34  
  35 +
  36 + def validate_branches
  37 + if target_branch == source_branch
  38 + errors.add :base, "You can not use same branch for source and target branches"
  39 + end
  40 + end
  41 +
34 42 def new?
35 43 today? && created_at == updated_at
36 44 end
... ...
app/views/merge_requests/_form.html.haml
... ... @@ -10,10 +10,14 @@
10 10 .input= f.text_area :title, :class => "xxlarge", :maxlength => 255, :rows => 5
11 11 .clearfix
12 12 = f.label :source_branch, "From"
13   - .input= f.select(:source_branch, @project.heads.map(&:name), { :include_blank => "Select branch" }, :style => "width:250px")
  13 + .input
  14 + = f.select(:source_branch, @project.heads.map(&:name), { :include_blank => "Select branch" }, :style => "width:250px")
  15 + .mr_source_commit
14 16 .clearfix
15 17 = f.label :target_branch, "To"
16   - .input= f.select(:target_branch, @project.heads.map(&:name), { :include_blank => "Select branch" }, :style => "width:250px")
  18 + .input
  19 + = f.select(:target_branch, @project.heads.map(&:name), { :include_blank => "Select branch" }, :style => "width:250px")
  20 + .mr_target_commit
17 21 .clearfix
18 22 = f.label :assignee_id, "Assign to"
19 23 .input= f.select(:assignee_id, @project.users.all.collect {|p| [ p.name, p.id ] }, { :include_blank => "Select user" }, :style => "width:250px")
... ... @@ -34,5 +38,15 @@
34 38 $('select#merge_request_assignee_id').chosen();
35 39 $('select#merge_request_source_branch').chosen();
36 40 $('select#merge_request_target_branch').chosen();
  41 +
  42 +
  43 +
  44 + $("#merge_request_source_branch").live("change", function() {
  45 + $.get("#{branch_from_project_merge_requests_path(@project)}", {ref: $(this).val() });
  46 + });
  47 +
  48 + $("#merge_request_target_branch").live("change", function() {
  49 + $.get("#{branch_to_project_merge_requests_path(@project)}", {ref: $(this).val() });
  50 + });
37 51 });
38 52  
... ...
app/views/merge_requests/branch_from.js.haml 0 → 100644
... ... @@ -0,0 +1,2 @@
  1 +:plain
  2 + $(".mr_source_commit").html("#{escape_javascript(render 'commits/commit', :commit => @commit)}");
... ...
app/views/merge_requests/branch_to.js.haml 0 → 100644
... ... @@ -0,0 +1,3 @@
  1 +:plain
  2 + $(".mr_target_commit").html("#{escape_javascript(render 'commits/commit', :commit => @commit)}");
  3 +
... ...
config/routes.rb
... ... @@ -101,6 +101,11 @@ Gitlab::Application.routes.draw do
101 101 member do
102 102 get :diffs
103 103 end
  104 +
  105 + collection do
  106 + get :branch_from
  107 + get :branch_to
  108 + end
104 109 end
105 110  
106 111 resources :snippets
... ...
db/fixtures/test/001_repo.rb
... ... @@ -10,6 +10,6 @@ Dir.mkdir(repo_dir) unless File.exists?(repo_dir)
10 10 Dir.chdir(repo_dir)
11 11 `tar -xf seed_project.tar.gz`
12 12 3.times do |i|
13   -`cp -r legit/ legit_#{i}/`
14   -puts "Unpacked seed repo - tmp/tests/legit_#{i}"
  13 +`cp -r gitlabhq/ gitlabhq_#{i}/`
  14 +puts "Unpacked seed repo - tmp/tests/gitlabhq_#{i}"
15 15 end
... ...
spec/factories.rb
... ... @@ -2,14 +2,14 @@ require File.join(Rails.root, 'spec', 'factory')
2 2  
3 3 Factory.add(:project, Project) do |obj|
4 4 obj.name = Faker::Internet.user_name
5   - obj.path = 'legit'
  5 + obj.path = 'gitlabhq'
6 6 obj.owner = Factory(:user)
7 7 obj.code = 'LGT'
8 8 end
9 9  
10 10 Factory.add(:public_project, Project) do |obj|
11 11 obj.name = Faker::Internet.user_name
12   - obj.path = 'legit'
  12 + obj.path = 'gitlabhq'
13 13 obj.private_flag = false
14 14 obj.owner = Factory(:user)
15 15 obj.code = 'LGT'
... ... @@ -41,7 +41,7 @@ Factory.add(:merge_request, MergeRequest) do |obj|
41 41 obj.author = Factory :user
42 42 obj.assignee = Factory :user
43 43 obj.source_branch = "master"
44   - obj.target_branch = "master"
  44 + obj.target_branch = "stable"
45 45 obj.closed = false
46 46 end
47 47  
... ...
spec/models/note_spec.rb
... ... @@ -54,7 +54,7 @@ describe Note do
54 54 describe :authorization do
55 55 before do
56 56 @p1 = project
57   - @p2 = Factory :project, :code => "alien", :path => "legit_1"
  57 + @p2 = Factory :project, :code => "alien", :path => "gitlabhq_1"
58 58 @u1 = Factory :user
59 59 @u2 = Factory :user
60 60 @u3 = Factory :user
... ...
spec/models/project_spec.rb
... ... @@ -86,23 +86,22 @@ describe Project do
86 86 let(:project) { Factory :project }
87 87  
88 88 it { project.fresh_commits(3).count.should == 3 }
89   - it { project.fresh_commits.first.id.should == "2fb376f61875b58bceee0492e270e9c805294b1a" }
90   - it { project.fresh_commits.last.id.should == "0dac878dbfe0b9c6104a87d65fe999149a8d862c" }
  89 + it { project.fresh_commits.first.id.should == "bcf03b5de6c33f3869ef70d68cf06e679d1d7f9a" }
  90 + it { project.fresh_commits.last.id.should == "f403da73f5e62794a0447aca879360494b08f678" }
91 91 end
92 92  
93 93 describe "commits_between" do
94 94 let(:project) { Factory :project }
95 95  
96 96 subject do
97   - commits = project.commits_between("a6d1d4aca0c85816ddfd27d93773f43a31395033",
98   - "2fb376f61875b58bceee0492e270e9c805294b1a")
  97 + commits = project.commits_between("3a4b4fb4cde7809f033822a171b9feae19d41fff",
  98 + "8470d70da67355c9c009e4401746b1d5410af2e3")
99 99 commits.map { |c| c.id }
100 100 end
101 101  
102   - it { should have(2).elements }
103   - it { should include("2fb376f61875b58bceee0492e270e9c805294b1a") }
104   - it { should include("4571e226fbcd7be1af16e9fa1e13b7ac003bebdf") }
105   - it { should_not include("a6d1d4aca0c85816ddfd27d93773f43a31395033") }
  102 + it { should have(3).elements }
  103 + it { should include("f0f14c8eaba69ebddd766498a9d0b0e79becd633") }
  104 + it { should_not include("bcf03b5de6c33f3869ef70d68cf06e679d1d7f9a") }
106 105 end
107 106  
108 107 describe "Git methods" do
... ...
spec/requests/admin/admin_projects_spec.rb
... ... @@ -87,7 +87,7 @@ describe "Admin::Projects" do
87 87 visit new_admin_project_path
88 88 fill_in 'Name', :with => 'NewProject'
89 89 fill_in 'Code', :with => 'NPR'
90   - fill_in 'Path', :with => 'legit_1'
  90 + fill_in 'Path', :with => 'gitlabhq_1'
91 91 expect { click_button "Save" }.to change { Project.count }.by(1)
92 92 @project = Project.last
93 93 end
... ...
spec/requests/merge_requests_spec.rb
... ... @@ -52,7 +52,7 @@ describe "MergeRequests" do
52 52 visit new_project_merge_request_path(project)
53 53 fill_in "merge_request_title", :with => "Merge Request Title"
54 54 select "master", :from => "merge_request_source_branch"
55   - select "master", :from => "merge_request_target_branch"
  55 + select "stable", :from => "merge_request_target_branch"
56 56 select @user.name, :from => "merge_request_assignee_id"
57 57 click_button "Save"
58 58 end
... ...
spec/requests/projects_spec.rb
... ... @@ -134,7 +134,7 @@ describe "Projects" do
134 134 visit edit_project_path(@project)
135 135  
136 136 fill_in 'Name', :with => 'Awesome'
137   - fill_in 'Path', :with => 'legit'
  137 + fill_in 'Path', :with => 'gitlabhq'
138 138 fill_in 'Description', :with => 'Awesome project'
139 139 click_button "Save"
140 140 @project = @project.reload
... ...
spec/requests/projects_tree_spec.rb
... ... @@ -57,7 +57,7 @@ describe "Projects" do
57 57 @project = Factory :project
58 58 @project.add_access(@user, :read)
59 59  
60   - visit tree_project_ref_path(@project, @project.root_ref, :path => ".rvmrc")
  60 + visit tree_project_ref_path(@project, @project.root_ref, :path => "Gemfile")
61 61 end
62 62  
63 63 it "should be correct path" do
... ... @@ -65,7 +65,7 @@ describe "Projects" do
65 65 end
66 66  
67 67 it "should contain file view" do
68   - page.should have_content("rvm use 1.9.2@legit")
  68 + page.should have_content("rubygems.org")
69 69 end
70 70 end
71 71 end
... ...
spec/requests/repositories_spec.rb
... ... @@ -42,7 +42,7 @@ describe "Repository" do
42 42  
43 43 it "should have link to repo activities" do
44 44 page.should have_content("Tags")
45   - page.should have_content("No tags")
  45 + page.should have_content("v1.2.1")
46 46 end
47 47 end
48 48 end
... ...
spec/seed_project.tar.gz
No preview for this file type
spec/support/valid_commit.rb
1 1 module ValidCommit
2   - ID = "eaffbe556ec3a8dc84ef15892a9f12d84dde7e1d"
3   - MESSAGE = "style"
  2 + ID = "8470d70da67355c9c009e4401746b1d5410af2e3"
  3 + MESSAGE = "notes controller refactored"
4 4 AUTHOR_FULL_NAME = "Dmitriy Zaporozhets"
5 5  
6   - FILES = [".gitignore", ".rspec", ".rvmrc", "Gemfile", "Gemfile.lock", "LICENSE", "README.rdoc", "Rakefile", "app", "config.ru", "config", "db", "doc", "lib", "log", "public", "script", "spec", "vendor"]
7   - FILES_COUNT = 19
  6 + FILES = [".foreman", ".gitignore", ".rails_footnotes", ".rspec", ".travis.yml", "CHANGELOG", "Gemfile", "Gemfile.lock", "LICENSE", "Procfile", "Procfile.production", "README.md", "Rakefile", "VERSION", "app", "config.ru", "config", "db", "doc", "lib", "log", "public", "resque.sh", "script", "spec", "vendor"]
  7 + FILES_COUNT = 26
8 8  
9 9 C_FILE_PATH = "app/models"
10   - C_FILES = [".gitkeep", "project.rb", "user.rb"]
  10 + C_FILES = [".gitkeep", "ability.rb", "commit.rb", "issue.rb", "key.rb", "mailer_observer.rb", "merge_request.rb", "note.rb", "project.rb", "protected_branch.rb", "repository.rb", "snippet.rb", "tree.rb", "user.rb", "users_project.rb", "web_hook.rb", "wiki.rb"]
11 11  
12   - BLOB_FILE = <<-blob
13   -<div class="span-14 colborder">
14   - <h2>Tree / <%= link_to "Commits", project_commits_path(@project) %></h2>
15   - <%= render :partial => "tree", :locals => {:repo => @repo, :commit => @commit, :tree => @commit.tree} %>
16   -</div>
17   -
18   -<div class="span-8 right">
19   - <%= render "side_panel" %>
20   -</div>
21   -blob
22   -
23   - BLOB_FILE_PATH = "app/views/projects/show.html.erb"
  12 + BLOB_FILE = %{%h3= @key.title\n%hr\n%pre= @key.key\n.actions\n = link_to 'Remove', @key, :confirm => 'Are you sure?', :method => :delete, :class => \"btn danger delete-key\"\n\n\n}
  13 + BLOB_FILE_PATH = "app/views/keys/show.html.haml"
24 14 end
25 15  
... ...