Skip to content

Commit

Permalink
Merge pull request #6502 from hennevogel/bugfix/bootstrap-spec
Browse files Browse the repository at this point in the history
Enable Bootstrap project show to all beta users
  • Loading branch information
hennevogel committed Dec 10, 2018
2 parents b75436b + 3ad61f1 commit a73bbbd
Show file tree
Hide file tree
Showing 18 changed files with 1,633 additions and 22 deletions.
4 changes: 0 additions & 4 deletions src/api/app/controllers/webui/project_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -206,10 +206,6 @@ def show
@comment = Comment.new
render :show, status: params[:nextstatus] if params[:nextstatus]

# TODO: Remove the `return unless` and the flash once this should be available to all beta users on all environments
return unless User.current && User.current.in_beta? && (Rails.env.development? || Rails.env.test?)
flash[:notice] = "We are currently migrating the project pages to Bootstrap. It's active only on the development and test environments while this is work-in-progress."

switch_to_webui2
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
List of projects you are watching
.dropdown-divider
- if params[:project]
%a.dropdown-item{ href: project_toggle_watch_path(params[:project]) }
%a.dropdown-item#toggle-watch{ href: project_toggle_watch_path(params[:project]) }
- if User.current.watches? params[:project]
%p.mb-0
Remove this project from Watchlist
Expand All @@ -18,7 +18,7 @@
Watch this project
.dropdown-divider
- User.current.watched_project_names.each_with_index do |project, index|
= link_to project_show_path(project), class: "dropdown-item text-wrap text-word-break-all #{'border-top' unless index.zero?}" do
= link_to project_show_path(project), class: "dropdown-item project-link text-wrap text-word-break-all #{'border-top' unless index.zero?}" do
%i.fa.fa-cubes.fa.text-secondary.pt-2
%span.small
= project
2 changes: 1 addition & 1 deletion src/api/app/views/webui/project/edit.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,5 @@
<label for="project_url"><strong>URL:</strong></label><br/>
<%= f.text_field :url, :size => 80 %>
</p>
<p><%= f.submit %></p>
<p><%= f.submit('Accept') %></p>
<% end %>
2 changes: 1 addition & 1 deletion src/api/app/views/webui/project/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<div class="grid_16 alpha omega box box-shadow">
<%= render partial: 'tabs' %>
<div class="grid_10 alpha">
<h3 id="project_title"><%= @project.title %><%= @project if @project.title.blank? -%></h3>
<h3 id="project-title"><%= @project.title %><%= @project if @project.title.blank? -%></h3>
<%= description_wrapper(@project.description) %>
<% if @project.url.present? %>
<p>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
- if project.is_maintenance_incident? && release_targets.present?
- if !project.is_maintenance_incident? && release_targets.present?
%li.list-inline-item
= link_to('#', class: 'nav-link', data: { toggle: 'modal', target: '#project-submit-update-modal' }) do
%i.fas.fa-share-square.text-warning
Expand Down
27 changes: 19 additions & 8 deletions src/api/spec/bootstrap/features/webui/maintenance_workflow_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,14 @@

click_link('Submit as Update')
# we need this find to wait for the dialog to appear
expect(find(:css, '.dialog h2')).to have_text('Submit as Update')
expect(find('#project-submit-update-modal-label')).to have_text('Submit as Update')
fill_in('description', with: 'I want the update')

click_button('Accept')
expect(page).to have_css('#flash-messages', text: 'Created maintenance incident request')
within('#project-submit-update-modal .modal-footer') do
click_button('Accept')
end

expect(page).to have_css('#flash', text: 'Created maintenance incident request')

# Check that sending maintenance updates adds the source revision
new_bs_request_action = BsRequestAction.where(
Expand Down Expand Up @@ -104,10 +107,13 @@
visit project_show_path(project: 'home:tom:branches:ProjectWithRepo:Update')

click_link('Submit as Update')

expect(find(:css, '.dialog h2')).to have_text('Submit as Update')
# we need this find to wait for the dialog to appear
expect(find('#project-submit-update-modal-label')).to have_text('Submit as Update')
fill_in('description', with: 'I have a additional fix')
click_button('Accept')

within('#project-submit-update-modal .modal-footer') do
click_button('Accept')
end

logout

Expand Down Expand Up @@ -141,11 +147,16 @@
visit project_show_path('MaintenanceProject:0')
click_link('Request to Release')

# we need this find to wait for the dialog to appear
expect(find('#project-release-request-modal-label')).to have_text('Create Maintenance Release Request')
fill_in('description', with: 'RELEASE!')
click_button('Accept')

within('#project-release-request-modal .modal-footer') do
click_button('Accept')
end

# As we can't release without build results this should fail
expect(page).to have_css('#flash-messages',
expect(page).to have_css('#flash',
text: "The repository 'MaintenanceProject:0' / 'ProjectWithRepo_Update' / i586 did not finish the build yet")
end
end
37 changes: 37 additions & 0 deletions src/api/spec/bootstrap/features/webui/projects_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,41 @@
expect(find(:css, '#description-text')).to have_text(very_long_description)
end
end

scenario 'changing project title and description' do
login user
visit project_show_path(project: project)

click_on('Edit Project')
expect(page).to have_text("Edit Project #{project}")

fill_in 'project_title', with: 'My Title hopefully got changed'
fill_in 'project_description', with: 'New description. Not kidding.. Brand new!'
click_button 'Accept'

visit project_show_path(project: project)
expect(find(:id, 'project-title')).to have_text('My Title hopefully got changed')
expect(find(:id, 'description-text')).to have_text('New description. Not kidding.. Brand new!')
end

describe 'branching' do
let(:other_user) { create(:confirmed_user, login: 'other_user') }
let!(:package_of_another_project) { create(:package_with_file, name: 'branch_test_package', project: other_user.home_project) }

before do
login user
visit project_show_path(project)
click_link('Branch Existing Package')
end

scenario 'a non-existing package' do
fill_in('linked_project', with: 'non-existing_package')
fill_in('linked_package', with: package_of_another_project.name)

click_button('Accept')

expect(page).to have_text('Failed to branch: Package does not exist.')
expect(page).to have_current_path(project_show_path('home:Jane'))
end
end
end
56 changes: 56 additions & 0 deletions src/api/spec/bootstrap/features/webui/watchlists_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
require 'browser_helper'

RSpec.feature 'Bootstrap_Watchlists', type: :feature, js: true, vcr: true do
let(:user) { create(:confirmed_user, login: 'kody') }
let(:project) { create(:project, name: 'watchlist_test_project') }
let(:user_with_watched_project) do
other_user = create(:confirmed_user, login: 'brian')
other_user.watched_projects << create(:watched_project,
project: create(:project, name: "#{other_user.login}_s_watched_project"))
other_user
end

scenario 'add projects to watchlist' do
login user
visit project_show_path(user.home_project)

click_on('Watchlist')
expect(page).to have_content('List of projects you are watching')
expect(page).to have_css('a.dropdown-item.project-link', count: 0)

expect(page).to have_css('#toggle-watch', text: 'Add this project to Watchlist')
find('#toggle-watch').click

click_on('Watchlist')
expect(page).to have_css('a.dropdown-item.project-link', text: user.home_project_name)
expect(page).to have_css('a.dropdown-item.project-link', count: 1)

visit project_show_path(project: project.name)
click_on('Watchlist')
expect(page).to have_css('#toggle-watch', text: 'Add this project to Watchlist')
find('#toggle-watch').click

click_on('Watchlist')
expect(page).to have_css('a.dropdown-item.project-link', text: user.home_project_name)
expect(page).to have_css('a.dropdown-item.project-link', text: project.name)
expect(page).to have_css('a.dropdown-item.project-link', count: 2)
end

scenario 'remove projects from watchlist' do
login user_with_watched_project
visit project_show_path(project: 'brian_s_watched_project')

click_on('Watchlist')
expect(page).to have_content('List of projects you are watching')
expect(page).to have_css('a.dropdown-item.project-link', text: 'brian_s_watched_project')
expect(page).to have_css('a.dropdown-item.project-link', count: 1)
expect(page).to have_css('#toggle-watch', text: 'Remove this project from Watchlist')

find('#toggle-watch').click

visit project_show_path(project: 'brian_s_watched_project')
click_on('Watchlist')
expect(page).to have_css('a.dropdown-item.project-link', count: 0)
expect(page).to have_css('#toggle-watch', text: 'Add this project to Watchlist')
end
end

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit a73bbbd

Please sign in to comment.