Merge pull request #4382 from oliverguenther/fix/23069/wp-context-menu
Fix invalid links to work package actionspull/4387/head
commit
cbcc7d18da
@ -0,0 +1,86 @@ |
||||
require 'spec_helper' |
||||
|
||||
describe 'Work package table context menu', js: true do |
||||
let(:user) { FactoryGirl.create(:admin) } |
||||
let(:work_package) { FactoryGirl.create(:work_package) } |
||||
|
||||
let(:wp_table) { Pages::WorkPackagesTable.new } |
||||
let(:menu) { Components::WorkPackagesContextMenu.new } |
||||
|
||||
def goto_context_menu |
||||
# Go to table |
||||
wp_table.visit! |
||||
wp_table.expect_work_package_listed(work_package) |
||||
|
||||
# Open context menu |
||||
menu.expect_closed |
||||
menu.open_for(work_package) |
||||
end |
||||
|
||||
before do |
||||
login_as(user) |
||||
work_package |
||||
end |
||||
|
||||
it 'provides a context menu for a single work package' do |
||||
# Open detail pane |
||||
goto_context_menu |
||||
menu.choose('Open details view') |
||||
expect(page).to have_selector('#work-package-subject', text: work_package.subject) |
||||
|
||||
# Open full view |
||||
goto_context_menu |
||||
menu.choose('Open fullscreen view') |
||||
expect(page).to have_selector('.work-packages--show-view #work-package-subject', |
||||
text: work_package.subject) |
||||
|
||||
# Open edit link |
||||
goto_context_menu |
||||
menu.choose('Edit') |
||||
expect(page).to have_selector('#inplace-edit--write-value--subject') |
||||
find('#work-packages--edit-actions-cancel').click |
||||
expect(page).to have_no_selector('#inplace-edit--write-value--subject') |
||||
|
||||
# Open log time |
||||
goto_context_menu |
||||
menu.choose('Log time') |
||||
expect(page).to have_selector('h2', text: I18n.t(:label_spent_time)) |
||||
|
||||
# Open Move |
||||
goto_context_menu |
||||
menu.choose('Move') |
||||
expect(page).to have_selector('h2', text: I18n.t(:button_move)) |
||||
expect(page).to have_selector('a.issue', text: "##{work_package.id}") |
||||
|
||||
# Open Copy |
||||
goto_context_menu |
||||
menu.choose('Copy') |
||||
expect(page).to have_selector('h2', text: I18n.t(:button_copy)) |
||||
expect(page).to have_selector('a.issue', text: "##{work_package.id}") |
||||
|
||||
# Open Delete |
||||
goto_context_menu |
||||
menu.choose('Delete') |
||||
wp_table.dismiss_alert_dialog! |
||||
end |
||||
|
||||
context 'multiple selected' do |
||||
let!(:work_package2) { FactoryGirl.create(:work_package) } |
||||
|
||||
before do |
||||
# Go to table |
||||
wp_table.visit! |
||||
wp_table.expect_work_package_listed(work_package) |
||||
wp_table.expect_work_package_listed(work_package2) |
||||
|
||||
# Select both |
||||
all('td.checkbox input').each { |el| el.set(true) } |
||||
end |
||||
|
||||
it 'shows a subset of the available menu items' do |
||||
menu.open_for(work_package) |
||||
menu.expect_options ['Open details view', 'Open fullscreen view', |
||||
'Edit', 'Copy', 'Move', 'Delete'] |
||||
end |
||||
end |
||||
end |
@ -0,0 +1,64 @@ |
||||
#-- copyright |
||||
# OpenProject is a project management system. |
||||
# Copyright (C) 2012-2015 the OpenProject Foundation (OPF) |
||||
# |
||||
# This program is free software; you can redistribute it and/or |
||||
# modify it under the terms of the GNU General Public License version 3. |
||||
# |
||||
# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows: |
||||
# Copyright (C) 2006-2013 Jean-Philippe Lang |
||||
# Copyright (C) 2010-2013 the ChiliProject Team |
||||
# |
||||
# This program is free software; you can redistribute it and/or |
||||
# modify it under the terms of the GNU General Public License |
||||
# as published by the Free Software Foundation; either version 2 |
||||
# of the License, or (at your option) any later version. |
||||
# |
||||
# This program is distributed in the hope that it will be useful, |
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
# GNU General Public License for more details. |
||||
# |
||||
# You should have received a copy of the GNU General Public License |
||||
# along with this program; if not, write to the Free Software |
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
||||
# |
||||
# See doc/COPYRIGHT.rdoc for more details. |
||||
#++ |
||||
|
||||
module Components |
||||
class WorkPackagesContextMenu |
||||
include Capybara::DSL |
||||
include RSpec::Matchers |
||||
|
||||
def open_for(work_package) |
||||
find("#work-package-#{work_package.id}").right_click |
||||
expect_open |
||||
end |
||||
|
||||
def expect_open |
||||
expect(page).to have_selector(selector) |
||||
end |
||||
|
||||
def expect_closed |
||||
expect(page).to have_no_selector(selector) |
||||
end |
||||
|
||||
def choose(target) |
||||
find("#{selector} a", text: target).click |
||||
end |
||||
|
||||
def expect_options(options) |
||||
expect_open |
||||
options.each do |text| |
||||
expect(page).to have_selector("#{selector} a", text: text) |
||||
end |
||||
end |
||||
|
||||
private |
||||
|
||||
def selector |
||||
'#work-package-context-menu' |
||||
end |
||||
end |
||||
end |
Loading…
Reference in new issue