commit
26a1050f8f
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -0,0 +1,52 @@ |
||||
require 'spec_helper' |
||||
|
||||
describe 'Milestones full screen v iew', js: true do |
||||
|
||||
let(:type) { FactoryBot.create :type, is_milestone: true } |
||||
let(:project) { FactoryBot.create(:project, types: [type]) } |
||||
let!(:work_package) { |
||||
FactoryBot.create(:work_package, |
||||
project: project, |
||||
type: type, |
||||
subject: 'Foobar') |
||||
} |
||||
|
||||
let(:wp_page) { ::Pages::FullWorkPackage.new(work_package, project) } |
||||
let(:button) { find('.add-work-package', wait: 5) } |
||||
|
||||
before do |
||||
login_as(user) |
||||
wp_page.visit! |
||||
end |
||||
|
||||
context 'user has :add_work_packages permission' do |
||||
let(:user) do |
||||
FactoryBot.create(:user, member_in_project: project, member_through_role: role) |
||||
end |
||||
let(:role) { FactoryBot.create(:role, permissions: permissions) } |
||||
let(:permissions) do |
||||
%i[view_work_packages add_work_packages] |
||||
end |
||||
|
||||
it 'shows the button as enabled' do |
||||
expect(button['disabled']).to be_falsey |
||||
|
||||
button.click |
||||
expect(page).to have_selector('.menu-item', text: type.name) |
||||
end |
||||
end |
||||
|
||||
context 'user has :view_work_packages permission only' do |
||||
let(:user) do |
||||
FactoryBot.create(:user, member_in_project: project, member_through_role: role) |
||||
end |
||||
let(:role) { FactoryBot.create(:role, permissions: permissions) } |
||||
let(:permissions) do |
||||
%i[view_work_packages] |
||||
end |
||||
|
||||
it 'shows the button as correctly disabled' do |
||||
expect(button['disabled']).to be_truthy |
||||
end |
||||
end |
||||
end |
@ -0,0 +1,79 @@ |
||||
#-- copyright |
||||
# OpenProject is a project management system. |
||||
# Copyright (C) 2012-2018 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-2017 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 docs/COPYRIGHT.rdoc for more details. |
||||
#++ |
||||
|
||||
require 'spec_helper' |
||||
|
||||
describe WorkPackages::DestroyService, 'integration', type: :model do |
||||
let(:user) do |
||||
FactoryBot.create(:user, |
||||
member_in_project: project, |
||||
member_through_role: role) |
||||
end |
||||
let(:role) do |
||||
FactoryBot.create(:role, |
||||
permissions: permissions) |
||||
end |
||||
|
||||
let(:permissions) do |
||||
%i(delete_work_packages view_work_packages add_work_packages manage_subtasks) |
||||
end |
||||
|
||||
let(:project) { FactoryBot.create(:project) } |
||||
|
||||
describe 'deleting a child with estimated_hours set' do |
||||
let(:parent) { FactoryBot.create(:work_package, project: project) } |
||||
let(:child) do |
||||
FactoryBot.create(:work_package, |
||||
project: project, |
||||
parent: parent, |
||||
estimated_hours: 123) |
||||
end |
||||
|
||||
let(:instance) do |
||||
described_class.new(user: user, work_package: child) |
||||
end |
||||
subject { instance.call } |
||||
|
||||
before do |
||||
# Ensure estimated_hours is inherited |
||||
::WorkPackages::UpdateAncestorsService.new(user: user, work_package: child).call(%i[estimated_hours]) |
||||
parent.reload |
||||
end |
||||
|
||||
it 'updates the parent estimated_hours' do |
||||
expect(child.estimated_hours).to eq 123 |
||||
expect(parent.estimated_hours).to eq 123 |
||||
|
||||
expect(subject).to be_success |
||||
|
||||
parent.reload |
||||
|
||||
expect(parent.estimated_hours).to eq(nil) |
||||
end |
||||
end |
||||
end |
Loading…
Reference in new issue