Commit d2362e2e authored by Phil Hughes's avatar Phil Hughes

Tests fix for ref switcher

parent deca5ef2
...@@ -9,6 +9,10 @@ ...@@ -9,6 +9,10 @@
margin-top: -2px; margin-top: -2px;
float: right; float: right;
} }
.dropdown-menu-toggle {
line-height: 20px;
}
} }
.panel-body { .panel-body {
......
...@@ -261,7 +261,7 @@ class ProjectsController < Projects::ApplicationController ...@@ -261,7 +261,7 @@ class ProjectsController < Projects::ApplicationController
# If reference is commit id - we should add it to branch/tag selectbox # If reference is commit id - we should add it to branch/tag selectbox
if @ref && !options.flatten.include?(@ref) && @ref =~ /\A[0-9a-zA-Z]{6,52}\z/ if @ref && !options.flatten.include?(@ref) && @ref =~ /\A[0-9a-zA-Z]{6,52}\z/
options << {'Commits' => @ref} options << { 'Commits' => @ref }
end end
render json: options.to_json render json: options.to_json
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
%b Builds badge &middot; %b Builds badge &middot;
= @build_badge.to_html = @build_badge.to_html
.pull-right .pull-right
= render 'shared/ref_switcher', destination: 'badges' = render 'shared/ref_switcher', destination: 'badges', align_right: true
.panel-body .panel-body
.row .row
.col-md-2.text-center .col-md-2.text-center
......
...@@ -6,9 +6,8 @@ ...@@ -6,9 +6,8 @@
= hidden_field_tag key, value, id: nil = hidden_field_tag key, value, id: nil
.dropdown .dropdown
= dropdown_toggle @ref || @project.default_branch, { toggle: "dropdown", selected: @ref || @project.default_branch, refs_url: refs_namespace_project_path(@project.namespace, @project) }, { toggle_class: "js-project-refs-dropdown" } = dropdown_toggle @ref || @project.default_branch, { toggle: "dropdown", selected: @ref || @project.default_branch, refs_url: refs_namespace_project_path(@project.namespace, @project) }, { toggle_class: "js-project-refs-dropdown" }
.dropdown-menu.dropdown-menu-selectable .dropdown-menu.dropdown-menu-selectable{ class: ("dropdown-menu-align-right" if local_assigns[:align_right]) }
= dropdown_title "Switch branch/tag" = dropdown_title "Switch branch/tag"
= dropdown_filter "Search branches and tags" = dropdown_filter "Search branches and tags"
= dropdown_content = dropdown_content
= dropdown_loading = dropdown_loading
-# = select_tag "ref", grouped_options_refs, class: "project-refs-select select2 select2-sm"
...@@ -20,11 +20,11 @@ class Spinach::Features::ProjectNetworkGraph < Spinach::FeatureSteps ...@@ -20,11 +20,11 @@ class Spinach::Features::ProjectNetworkGraph < Spinach::FeatureSteps
end end
step 'page should select "master" in select box' do step 'page should select "master" in select box' do
expect(page).to have_selector '.select2-chosen', text: "master" expect(page).to have_selector '.dropdown-menu-toggle', text: "master"
end end
step 'page should select "v1.0.0" in select box' do step 'page should select "v1.0.0" in select box' do
expect(page).to have_selector '.select2-chosen', text: "v1.0.0" expect(page).to have_selector '.dropdown-menu-toggle', text: "v1.0.0"
end end
step 'page should have "master" on graph' do step 'page should have "master" on graph' do
...@@ -40,11 +40,19 @@ class Spinach::Features::ProjectNetworkGraph < Spinach::FeatureSteps ...@@ -40,11 +40,19 @@ class Spinach::Features::ProjectNetworkGraph < Spinach::FeatureSteps
end end
When 'I switch ref to "feature"' do When 'I switch ref to "feature"' do
select 'feature', from: 'ref' first('.js-project-refs-dropdown').click
page.within '.project-refs-form' do
click_link 'feature'
end
end end
When 'I switch ref to "v1.0.0"' do When 'I switch ref to "v1.0.0"' do
select 'v1.0.0', from: 'ref' first('.js-project-refs-dropdown').click
page.within '.project-refs-form' do
click_link 'v1.0.0'
end
end end
When 'click "Show only selected branch" checkbox' do When 'click "Show only selected branch" checkbox' do
...@@ -68,11 +76,11 @@ class Spinach::Features::ProjectNetworkGraph < Spinach::FeatureSteps ...@@ -68,11 +76,11 @@ class Spinach::Features::ProjectNetworkGraph < Spinach::FeatureSteps
end end
step 'page should select "feature" in select box' do step 'page should select "feature" in select box' do
expect(page).to have_selector '.select2-chosen', text: "feature" expect(page).to have_selector '.dropdown-menu-toggle', text: "feature"
end end
step 'page should select "v1.0.0" in select box' do step 'page should select "v1.0.0" in select box' do
expect(page).to have_selector '.select2-chosen', text: "v1.0.0" expect(page).to have_selector '.dropdown-menu-toggle', text: "v1.0.0"
end end
step 'page should have "feature" on graph' do step 'page should have "feature" on graph' do
......
...@@ -290,15 +290,23 @@ class Spinach::Features::ProjectSourceBrowseFiles < Spinach::FeatureSteps ...@@ -290,15 +290,23 @@ class Spinach::Features::ProjectSourceBrowseFiles < Spinach::FeatureSteps
end end
step "I switch ref to 'test'" do step "I switch ref to 'test'" do
select "'test'", from: 'ref' first('.js-project-refs-dropdown').click
page.within '.project-refs-form' do
click_link 'test'
end
end end
step "I switch ref to fix" do step "I switch ref to fix" do
select "fix", from: 'ref' first('.js-project-refs-dropdown').click
page.within '.project-refs-form' do
click_link 'fix'
end
end end
step "I see the ref 'test' has been selected" do step "I see the ref 'test' has been selected" do
expect(page).to have_selector '.select2-chosen', text: "'test'" expect(page).to have_selector '.dropdown-toggle', text: "'test'"
end end
step "I visit the 'test' tree" do step "I visit the 'test' tree" do
......
require 'spec_helper' require 'spec_helper'
feature 'list of badges' do feature 'list of badges' do
include Select2Helper
background do background do
user = create(:user) user = create(:user)
project = create(:project) project = create(:project)
...@@ -24,7 +22,11 @@ feature 'list of badges' do ...@@ -24,7 +22,11 @@ feature 'list of badges' do
end end
scenario 'user changes current ref on badges list page', js: true do scenario 'user changes current ref on badges list page', js: true do
select2('improve/awesome', from: '#ref') first('.js-project-refs-dropdown').click
page.within '.project-refs-form' do
click_link 'improve/awesome'
end
expect(page).to have_content 'badges/improve/awesome/build.svg' expect(page).to have_content 'badges/improve/awesome/build.svg'
end end
......
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