Merge pull request #4111 from ulferts/fix/rewrite_wp_edit_cuke_as_spec
rewrite wp edit cuke as specpull/4117/head
commit
6323228334
@ -1,30 +1,93 @@ |
||||
require 'spec_helper' |
||||
require 'features/work_packages/details/inplace_editor/work_package_field' |
||||
require 'features/page_objects/notification' |
||||
|
||||
|
||||
describe 'edit work package', js: true do |
||||
let(:user) { FactoryGirl.create :admin } |
||||
let(:project) { FactoryGirl.create(:project) } |
||||
let(:work_package) { FactoryGirl.create(:work_package, project: project) } |
||||
let(:dev_role) do |
||||
FactoryGirl.create :role, |
||||
permissions: [:view_work_packages, |
||||
:add_work_packages] |
||||
end |
||||
let(:dev) do |
||||
FactoryGirl.create :user, |
||||
firstname: 'Dev', |
||||
lastname: 'Guy', |
||||
member_in_project: project, |
||||
member_through_role: dev_role |
||||
end |
||||
let(:manager_role) do |
||||
FactoryGirl.create :role, |
||||
permissions: [:view_work_packages, |
||||
:edit_work_packages] |
||||
end |
||||
let(:manager) do |
||||
FactoryGirl.create :user, |
||||
firstname: 'Manager', |
||||
lastname: 'Guy', |
||||
member_in_project: project, |
||||
member_through_role: manager_role |
||||
end |
||||
let(:type) { FactoryGirl.create :type } |
||||
let(:type2) { FactoryGirl.create :type } |
||||
let(:project) { FactoryGirl.create(:project, types: [type, type2]) } |
||||
let(:work_package) { FactoryGirl.create(:work_package, author: dev, project: project, type: type) } |
||||
|
||||
let(:new_subject) { 'Some other subject' } |
||||
let(:subject_field) { WorkPackageField.new(page, :subject) } |
||||
let(:wp_page) { Pages::FullWorkPackage.new(work_package) } |
||||
let(:priority2) { FactoryGirl.create :priority } |
||||
let(:status2) { FactoryGirl.create :status } |
||||
let(:workflow) do |
||||
FactoryGirl.create :workflow, |
||||
type_id: type2.id, |
||||
old_status: work_package.status, |
||||
new_status: status2, |
||||
role: manager_role |
||||
end |
||||
let(:version) { FactoryGirl.create :version, project: project } |
||||
let(:category) { FactoryGirl.create :category, project: project } |
||||
|
||||
before do |
||||
login_as(user) |
||||
login_as(manager) |
||||
|
||||
manager |
||||
dev |
||||
priority2 |
||||
workflow |
||||
|
||||
visit edit_work_package_path(work_package) |
||||
wp_page.visit! |
||||
end |
||||
|
||||
it 'shows the work package in edit mode' do |
||||
subject = page.find("#inplace-edit--write-value--subject") |
||||
expect(subject.value).to eq(work_package.subject) |
||||
it 'allows updating and seeing the results' do |
||||
wp_page.ensure_page_loaded |
||||
|
||||
wp_page.view_all_attributes |
||||
|
||||
wp_page.update_attributes type: type2.name, |
||||
:'start-date' => '2013-03-04', |
||||
:'end-date' => '2013-03-20', |
||||
responsible: manager.name, |
||||
assignee: manager.name, |
||||
estimatedTime: '5.00', |
||||
percentageDone: '30', |
||||
subject: 'a new subject', |
||||
description: 'a new description', |
||||
priority: priority2.name, |
||||
status: status2.name, |
||||
version: version.name, |
||||
category: category.name |
||||
|
||||
subject.set new_subject |
||||
find('#work-packages--edit-actions-save').click |
||||
wp_page.expect_notification message: I18n.t('js.notice_successful_update') |
||||
|
||||
subject_field.expect_state_text(new_subject) |
||||
expect(work_package.reload.subject).to eq(new_subject) |
||||
wp_page.expect_attributes Type: type2.name, |
||||
Responsible: manager.name, |
||||
Assignee: manager.name, |
||||
Date: '03/04/2013 - 03/20/2013', |
||||
'Estimated time' => '5.00', |
||||
Progress: '30', |
||||
Subject: 'a new subject', |
||||
Description: 'a new description', |
||||
Priority: priority2.name, |
||||
Status: status2.name, |
||||
Version: version.name, |
||||
Category: category.name |
||||
end |
||||
end |
||||
|
Loading…
Reference in new issue