Commit ca52f848 authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Update chosen, improve ui, fix MR fork tests

parent f4978bc0
...@@ -129,7 +129,7 @@ group :assets do ...@@ -129,7 +129,7 @@ group :assets do
gem 'turbolinks' gem 'turbolinks'
gem 'jquery-turbolinks' gem 'jquery-turbolinks'
gem 'chosen-rails', "0.9.8" gem 'chosen-rails', "1.0.0"
gem 'select2-rails' gem 'select2-rails'
gem 'jquery-atwho-rails', "0.3.0" gem 'jquery-atwho-rails', "0.3.0"
gem "jquery-rails", "2.1.3" gem "jquery-rails", "2.1.3"
......
...@@ -72,9 +72,12 @@ GEM ...@@ -72,9 +72,12 @@ GEM
charlock_holmes (0.6.9.4) charlock_holmes (0.6.9.4)
childprocess (0.3.9) childprocess (0.3.9)
ffi (~> 1.0, >= 1.0.11) ffi (~> 1.0, >= 1.0.11)
chosen-rails (0.9.8) chosen-rails (1.0.0)
railties (~> 3.0) coffee-rails (>= 3.2)
thor (~> 0.14) compass-rails (>= 1.0)
railties (>= 3.0)
sass-rails (>= 3.2)
chunky_png (1.2.8)
code_analyzer (0.3.2) code_analyzer (0.3.2)
sexp_processor sexp_processor
coderay (1.0.9) coderay (1.0.9)
...@@ -87,6 +90,12 @@ GEM ...@@ -87,6 +90,12 @@ GEM
coffee-script-source (1.6.2) coffee-script-source (1.6.2)
colored (1.2) colored (1.2)
colorize (0.5.8) colorize (0.5.8)
compass (0.12.2)
chunky_png (~> 1.2)
fssm (>= 0.2.7)
sass (~> 3.1)
compass-rails (1.0.3)
compass (>= 0.12.2, < 0.14)
connection_pool (1.1.0) connection_pool (1.1.0)
coveralls (0.6.7) coveralls (0.6.7)
colorize colorize
...@@ -149,6 +158,7 @@ GEM ...@@ -149,6 +158,7 @@ GEM
dotenv (>= 0.7) dotenv (>= 0.7)
thor (>= 0.13.6) thor (>= 0.13.6)
formatador (0.2.4) formatador (0.2.4)
fssm (0.2.10)
gemoji (1.2.1) gemoji (1.2.1)
gherkin-ruby (0.3.0) gherkin-ruby (0.3.0)
github-linguist (2.3.4) github-linguist (2.3.4)
...@@ -548,7 +558,7 @@ DEPENDENCIES ...@@ -548,7 +558,7 @@ DEPENDENCIES
bootstrap-sass bootstrap-sass
capybara capybara
carrierwave carrierwave
chosen-rails (= 0.9.8) chosen-rails (= 1.0.0)
coffee-rails coffee-rails
colored colored
coveralls coveralls
......
/* CHZN reset few styles */ /* CHZN reset few styles */
.chzn-container-single .chzn-single { .chosen-container-single .chosen-single {
background: #FFF; background: #FFF;
border: 1px solid #bbb; border: 1px solid #bbb;
box-shadow: none; box-shadow: none;
} }
.chzn-container-active .chzn-single { .chosen-container-active .chosen-single {
background: #fff; background: #fff;
} }
...@@ -41,38 +41,38 @@ ...@@ -41,38 +41,38 @@
width: 120px; width: 120px;
} }
.project-refs-form .chzn-container { .project-refs-form .chosen-container {
position: relative; position: relative;
top: 0; top: 0;
left: 0; left: 0;
margin-right: 10px; margin-right: 10px;
.chzn-drop { .chosen-drop {
min-width: 400px; min-width: 400px;
.chzn-results { .chosen-results {
max-height: 300px; max-height: 300px;
} }
.chzn-search input { .chosen-search input {
min-width: 365px; min-width: 365px;
} }
} }
} }
/** Fix for Search Dropdown Border **/ /** Fix for Search Dropdown Border **/
.chzn-container { .chosen-container {
.chzn-search { .chosen-search {
input:focus { input:focus {
@include box-shadow(none); @include box-shadow(none);
} }
} }
.chzn-drop { .chosen-drop {
margin: 7px 0; margin: 7px 0;
min-width: 200px; min-width: 200px;
border: 1px solid #bbb; border: 1px solid #bbb;
@include border-radius(0); @include border-radius(0);
.chzn-results { .chosen-results {
margin-top: 5px; margin-top: 5px;
max-height: 300px; max-height: 300px;
...@@ -95,7 +95,7 @@ ...@@ -95,7 +95,7 @@
} }
} }
.chzn-search { .chosen-search {
@include bg-gray-gradient; @include bg-gray-gradient;
input { input {
min-width: 165px; min-width: 165px;
...@@ -104,7 +104,7 @@ ...@@ -104,7 +104,7 @@
} }
} }
.chzn-single { .chosen-single {
@include bg-light-gray-gradient; @include bg-light-gray-gradient;
div { div {
......
...@@ -101,12 +101,12 @@ class Projects::MergeRequestsController < Projects::ApplicationController ...@@ -101,12 +101,12 @@ class Projects::MergeRequestsController < Projects::ApplicationController
def branch_from def branch_from
#This is always source #This is always source
@source_project = @merge_request.nil? ? @project : @merge_request.source_project @source_project = @merge_request.nil? ? @project : @merge_request.source_project
@commit = @repository.commit(params[:ref]) @commit = @repository.commit(params[:ref]) if params[:ref].present?
end end
def branch_to def branch_to
@target_project = selected_target_project @target_project = selected_target_project
@commit = @target_project.repository.commit(params[:ref]) @commit = @target_project.repository.commit(params[:ref]) if params[:ref].present?
end end
def update_branches def update_branches
......
...@@ -13,8 +13,12 @@ ...@@ -13,8 +13,12 @@
.span5 .span5
.light-well .light-well
%h5.cgray From %h5.cgray From
.padded= f.select(:source_project_id,[[@merge_request.source_project.path_with_namespace,@merge_request.source_project.id]] , {}, {class: 'source_project chosen span4'}) .padded
.padded= f.select(:source_branch, @merge_request.source_project.repository.branch_names, { include_blank: "Select branch" }, {class: 'source_branch chosen span4'}) = f.select(:source_project_id,[[@merge_request.source_project.path_with_namespace,@merge_request.source_project.id]] , {}, {class: 'source_project chosen span4'})
.prepend-top-10
%i.icon-code-fork
&nbsp;
= f.select(:source_branch, @merge_request.source_project.repository.branch_names, { include_blank: "Select branch" }, {class: 'source_branch chosen span3'})
.mr_source_commit.prepend-top-10 .mr_source_commit.prepend-top-10
.span2 .span2
%h1.merge-request-angle %h1.merge-request-angle
...@@ -23,9 +27,13 @@ ...@@ -23,9 +27,13 @@
.light-well .light-well
%h5.cgray To %h5.cgray To
- projects = @project.forked_from_project.nil? ? [@project] : [ @project,@project.forked_from_project] - projects = @project.forked_from_project.nil? ? [@project] : [ @project,@project.forked_from_project]
.padded= f.select(:target_project_id, projects.map { |proj| [proj.path_with_namespace,proj.id] }, {include_blank: "Select Target Project" }, {class: 'target_project chosen span4'}) .padded
.padded= f.select(:target_branch, @target_branches, { include_blank: "Select branch" }, {class: 'target_branch chosen span4'}) = f.select(:target_project_id, projects.map { |proj| [proj.path_with_namespace,proj.id] }, {include_blank: "Select Target Project" }, {class: 'target_project chosen span4'})
.mr_target_commit.prepend-top-10 .prepend-top-10
%i.icon-code-fork
&nbsp;
= f.select(:target_branch, @target_branches, { include_blank: "Select branch" }, {class: 'target_branch chosen span3'})
.mr_target_commit.prepend-top-10
%hr %hr
......
...@@ -20,14 +20,6 @@ Feature: Project Forked Merge Requests ...@@ -20,14 +20,6 @@ Feature: Project Forked Merge Requests
And I submit the merge request And I submit the merge request
Then I should see merge request "Merge Request On Forked Project" Then I should see merge request "Merge Request On Forked Project"
@javascript
Scenario: I should see a push widget for forked merge requests
Given project "Forked Shop" has push event
And I visit dashboard page
Then I should see last push widget
And I click "Create Merge Request on fork" link
Then I see prefilled new Merge Request page for the forked project
@javascript @javascript
Scenario: I can edit a forked merge request Scenario: I can edit a forked merge request
Given I visit project "Forked Shop" merge requests page Given I visit project "Forked Shop" merge requests page
...@@ -47,4 +39,4 @@ Feature: Project Forked Merge Requests ...@@ -47,4 +39,4 @@ Feature: Project Forked Merge Requests
And I click link "New Merge Request" And I click link "New Merge Request"
And I fill out an invalid "Merge Request On Forked Project" merge request And I fill out an invalid "Merge Request On Forked Project" merge request
And I submit the merge request And I submit the merge request
Then I should see validation errors Then I should see validation errors
\ No newline at end of file
...@@ -3,30 +3,31 @@ class ProjectForkedMergeRequests < Spinach::FeatureSteps ...@@ -3,30 +3,31 @@ class ProjectForkedMergeRequests < Spinach::FeatureSteps
include SharedProject include SharedProject
include SharedNote include SharedNote
include SharedPaths include SharedPaths
include ChosenHelper
Given 'I am a member of project "Shop"' do step 'I am a member of project "Shop"' do
@project = Project.find_by_name "Shop" @project = Project.find_by_name "Shop"
@project ||= create(:project_with_code, name: "Shop") @project ||= create(:project_with_code, name: "Shop")
@project.team << [@user, :reporter] @project.team << [@user, :reporter]
end end
And 'I have a project forked off of "Shop" called "Forked Shop"' do step 'I have a project forked off of "Shop" called "Forked Shop"' do
@forking_user = @user @forking_user = @user
forked_project_link = build(:forked_project_link) forked_project_link = build(:forked_project_link)
@forked_project = Project.find_by_name "Forked Shop" @forked_project = Project.find_by_name "Forked Shop"
@forked_project ||= create(:source_project_with_code, name: "Forked Shop", forked_project_link: forked_project_link, creator_id: @forking_user.id , namespace: @forking_user.namespace) @forked_project ||= create(:source_project_with_code, name: "Forked Shop", forked_project_link: forked_project_link, creator_id: @forking_user.id , namespace: @forking_user.namespace)
forked_project_link.forked_from_project = @project forked_project_link.forked_from_project = @project
forked_project_link.forked_to_project = @forked_project forked_project_link.forked_to_project = @forked_project
@forked_project.team << [@forking_user , :master] @forked_project.team << [@forking_user , :master]
forked_project_link.save! forked_project_link.save!
end end
Given 'I click link "New Merge Request"' do step 'I click link "New Merge Request"' do
click_link "New Merge Request" click_link "New Merge Request"
end end
Then 'I should see merge request "Merge Request On Forked Project"' do step 'I should see merge request "Merge Request On Forked Project"' do
page.should have_content "Merge Request On Forked Project"
@project.merge_requests.size.should >= 1 @project.merge_requests.size.should >= 1
@merge_request = @project.merge_requests.last @merge_request = @project.merge_requests.last
current_path.should == project_merge_request_path(@project, @merge_request) current_path.should == project_merge_request_path(@project, @merge_request)
...@@ -40,56 +41,41 @@ class ProjectForkedMergeRequests < Spinach::FeatureSteps ...@@ -40,56 +41,41 @@ class ProjectForkedMergeRequests < Spinach::FeatureSteps
page.should have_content @merge_request.target_branch page.should have_content @merge_request.target_branch
end end
And 'I fill out a "Merge Request On Forked Project" merge request' do step 'I fill out a "Merge Request On Forked Project" merge request' do
#The ordering here is a bit whacky on purpose: chosen @forked_project.id, from: "#merge_request_source_project_id"
#Select the target right away, to give update_branches time to run and clean up the target_branches chosen @project.id, from: "#merge_request_target_project_id"
find(:select, "merge_request_target_project_id", {}).value.should == @forked_project.id.to_s
select @project.path_with_namespace, from: "merge_request_target_project_id"
fill_in "merge_request_title", with: "Merge Request On Forked Project"
find(:select, "merge_request_source_project_id", {}).value.should == @forked_project.id.to_s find(:select, "merge_request_source_project_id", {}).value.should == @forked_project.id.to_s
find(:select, "merge_request_target_project_id", {}).value.should == @project.id.to_s find(:select, "merge_request_target_project_id", {}).value.should == @project.id.to_s
#Ensure the option exists in the select chosen "master", from: "#merge_request_source_branch"
find(:select, "merge_request_source_branch", {}).should have_content "master" chosen "stable", from: "#merge_request_target_branch"
select "master", from: "merge_request_source_branch"
#Ensure the option is selected
find(:select, "merge_request_source_branch", {}).value.should have_content "master"
verify_commit_link(".mr_source_commit",@forked_project)
#This could fail if the javascript hasn't run yet, there is a timing issue here -- this is why we do the select at the top find(:select, "merge_request_source_branch", {}).value.should == 'master'
#Ensure the option exists in the select find(:select, "merge_request_target_branch", {}).value.should == 'stable'
find(:select, "merge_request_target_branch", {}).should have_content "stable"
#We must give apparently lots of time for update branches to finish
(find(:select, "merge_request_target_branch", {}).find(:option, "stable",{}).select_option).should be_true fill_in "merge_request_title", with: "Merge Request On Forked Project"
#Ensure the option is selected
find(:select, "merge_request_target_branch", {}).value.should have_content "stable"
verify_commit_link(".mr_target_commit",@project)
end end
And 'I submit the merge request' do step 'I submit the merge request' do
click_button "Submit merge request" click_button "Submit merge request"
end end
And 'I follow the target commit link' do step 'I follow the target commit link' do
commit = @project.repository.commit commit = @project.repository.commit
click_link commit.short_id(8) click_link commit.short_id(8)
end end
Then 'I should see the commit under the forked from project' do step 'I should see the commit under the forked from project' do
commit = @project.repository.commit commit = @project.repository.commit
page.should have_content(commit.message) page.should have_content(commit.message)
end end
And 'I click "Create Merge Request on fork" link' do step 'I click "Create Merge Request on fork" link' do
click_link "Create Merge Request on fork" click_link "Create Merge Request on fork"
end end
Then 'I see prefilled new Merge Request page for the forked project' do step 'I see prefilled new Merge Request page for the forked project' do
current_path.should == new_project_merge_request_path(@forked_project) current_path.should == new_project_merge_request_path(@forked_project)
find("#merge_request_source_project_id").value.should == @forked_project.id.to_s find("#merge_request_source_project_id").value.should == @forked_project.id.to_s
find("#merge_request_target_project_id").value.should == @project.id.to_s find("#merge_request_target_project_id").value.should == @project.id.to_s
...@@ -100,15 +86,15 @@ class ProjectForkedMergeRequests < Spinach::FeatureSteps ...@@ -100,15 +86,15 @@ class ProjectForkedMergeRequests < Spinach::FeatureSteps
verify_commit_link(".mr_source_commit",@forked_project) verify_commit_link(".mr_source_commit",@forked_project)
end end
And 'I update the merge request title' do step 'I update the merge request title' do
fill_in "merge_request_title", with: "An Edited Forked Merge Request" fill_in "merge_request_title", with: "An Edited Forked Merge Request"
end end
And 'I save the merge request' do step 'I save the merge request' do
click_button "Save changes" click_button "Save changes"
end end
Then 'I should see the edited merge request' do step 'I should see the edited merge request' do
page.should have_content "An Edited Forked Merge Request" page.should have_content "An Edited Forked Merge Request"
@project.merge_requests.size.should >= 1 @project.merge_requests.size.should >= 1
@merge_request = @project.merge_requests.last @merge_request = @project.merge_requests.last
...@@ -122,12 +108,12 @@ class ProjectForkedMergeRequests < Spinach::FeatureSteps ...@@ -122,12 +108,12 @@ class ProjectForkedMergeRequests < Spinach::FeatureSteps
page.should have_content @merge_request.target_branch page.should have_content @merge_request.target_branch
end end
Then 'I should see last push widget' do step 'I should see last push widget' do
page.should have_content "You pushed to new_design" page.should have_content "You pushed to new_design"
page.should have_link "Create Merge Request" page.should have_link "Create Merge Request"
end end
Given 'project "Forked Shop" has push event' do step 'project "Forked Shop" has push event' do
@forked_project = Project.find_by_name("Forked Shop") @forked_project = Project.find_by_name("Forked Shop")
data = { data = {
...@@ -154,13 +140,13 @@ class ProjectForkedMergeRequests < Spinach::FeatureSteps ...@@ -154,13 +140,13 @@ class ProjectForkedMergeRequests < Spinach::FeatureSteps
end end
Then 'I click link edit "Merge Request On Forked Project"' do step 'I click link edit "Merge Request On Forked Project"' do
find("#edit_merge_request").click find("#edit_merge_request").click
end end
Then 'I see the edit page prefilled for "Merge Request On Forked Project"' do step 'I see the edit page prefilled for "Merge Request On Forked Project"' do
current_path.should == edit_project_merge_request_path(@project, @merge_request) current_path.should == edit_project_merge_request_path(@project, @merge_request)
page.should have_content "Edit merge request #{@merge_request.id}" page.should have_content "Edit merge request ##{@merge_request.id}"
find("#merge_request_title").value.should == "Merge Request On Forked Project" find("#merge_request_title").value.should == "Merge Request On Forked Project"
find("#merge_request_source_project_id").value.should == @forked_project.id.to_s find("#merge_request_source_project_id").value.should == @forked_project.id.to_s
find("#merge_request_target_project_id").value.should == @project.id.to_s find("#merge_request_target_project_id").value.should == @project.id.to_s
...@@ -170,7 +156,7 @@ class ProjectForkedMergeRequests < Spinach::FeatureSteps ...@@ -170,7 +156,7 @@ class ProjectForkedMergeRequests < Spinach::FeatureSteps
verify_commit_link(".mr_target_commit",@project) verify_commit_link(".mr_target_commit",@project)
end end
And 'I fill out an invalid "Merge Request On Forked Project" merge request' do step 'I fill out an invalid "Merge Request On Forked Project" merge request' do
#If this isn't filled in the rest of the validations won't be triggered #If this isn't filled in the rest of the validations won't be triggered
fill_in "merge_request_title", with: "Merge Request On Forked Project" fill_in "merge_request_title", with: "Merge Request On Forked Project"
find(:select, "merge_request_source_project_id", {}).value.should == @forked_project.id.to_s find(:select, "merge_request_source_project_id", {}).value.should == @forked_project.id.to_s
...@@ -179,7 +165,7 @@ class ProjectForkedMergeRequests < Spinach::FeatureSteps ...@@ -179,7 +165,7 @@ class ProjectForkedMergeRequests < Spinach::FeatureSteps
find(:select, "merge_request_target_branch", {}).value.should == "" find(:select, "merge_request_target_branch", {}).value.should == ""
end end
Then 'I should see validation errors' do step 'I should see validation errors' do
page.should have_content "Source branch can't be blank" page.should have_content "Source branch can't be blank"
page.should have_content "Target branch can't be blank" page.should have_content "Target branch can't be blank"
page.should have_content "Branch conflict You can not use same project/branch for source and target" page.should have_content "Branch conflict You can not use same project/branch for source and target"
......
...@@ -14,7 +14,7 @@ require 'spinach/capybara' ...@@ -14,7 +14,7 @@ require 'spinach/capybara'
require 'sidekiq/testing/inline' require 'sidekiq/testing/inline'
%w(valid_commit select2_helper test_env).each do |f| %w(valid_commit select2_helper chosen_helper test_env).each do |f|
require Rails.root.join('spec', 'support', f) require Rails.root.join('spec', 'support', f)
end end
......
# Chosen programmatic helper
# It allows you to select value from chosen select
#
# Params
# value - real value of selected item
# opts - options containing css selector
#
# Usage:
#
# chosen(2, from: '#user_ids')
#
module ChosenHelper
def chosen(value, options={})
raise "Must pass a hash containing 'from'" if not options.is_a?(Hash) or not options.has_key?(:from)
selector = options[:from]
page.execute_script("$('#{selector}').val('#{value}').trigger('chosen:updated');")
end
end
...@@ -88,11 +88,11 @@ module TestEnv ...@@ -88,11 +88,11 @@ module TestEnv
def clear_repo_dir(namespace, name) def clear_repo_dir(namespace, name)
setup_stubs setup_stubs
#Clean any .wiki.git that may have been created # Clean any .wiki.git that may have been created
FileUtils.rm_rf File.join(testing_path(), "#{name}.wiki.git") FileUtils.rm_rf File.join(testing_path(), "#{name}.wiki.git")
end end
#Create a repo and it's satellite # Create a repo and it's satellite
def create_repo(namespace, name) def create_repo(namespace, name)
setup_stubs setup_stubs
repo = repo(namespace, name) repo = repo(namespace, name)
...@@ -152,7 +152,7 @@ module TestEnv ...@@ -152,7 +152,7 @@ module TestEnv
# Recreate tmp/test-git-base-path # Recreate tmp/test-git-base-path
FileUtils.mkdir_p Gitlab.config.gitlab_shell.repos_path FileUtils.mkdir_p Gitlab.config.gitlab_shell.repos_path
#Since much more is happening in satellites # Since much more is happening in satellites
FileUtils.mkdir_p Gitlab.config.satellites.path FileUtils.mkdir_p Gitlab.config.satellites.path
end end
...@@ -161,8 +161,8 @@ module TestEnv ...@@ -161,8 +161,8 @@ module TestEnv
satellite_repo = satellite(namespace, satellite_name) satellite_repo = satellite(namespace, satellite_name)
# Symlink tmp/satellite/gitlabhq to tmp/test-git-base-path/satellite/gitlabhq, create the directory if it doesn't exist already # Symlink tmp/satellite/gitlabhq to tmp/test-git-base-path/satellite/gitlabhq, create the directory if it doesn't exist already
satellite_dir = File.dirname(satellite_repo) satellite_dir = File.dirname(satellite_repo)
FileUtils.mkdir_p satellite_dir unless File.exists?(satellite_dir) FileUtils.mkdir_p(satellite_dir) unless File.exists?(satellite_dir)
system("ln -s -f #{seed_satellite_path()} #{satellite_repo}") system("ln -s -f #{seed_satellite_path} #{satellite_repo}")
end end
def create_temp_repo(path) def create_temp_repo(path)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment