Don't access CF internal ids

pull/6208/head
Oliver Günther 7 years ago
parent 2740d85633
commit b0eced4428
No known key found for this signature in database
GPG Key ID: 88872239EB414F99
  1. 24
      spec/features/work_packages/details/custom_fields/custom_field_spec.rb
  2. 8
      spec/features/work_packages/table/edit_work_packages_spec.rb
  3. 9
      spec/features/work_packages/table/switch_types_spec.rb
  4. 2
      spec/support/capybara.rb
  5. 16
      spec/support/pages/abstract_work_package.rb
  6. 3
      spec/support/pages/abstract_work_package_create.rb
  7. 3
      spec/support/pages/full_work_package.rb
  8. 4
      spec/support/pages/full_work_package_create.rb
  9. 4
      spec/support/pages/split_work_package.rb
  10. 4
      spec/support/pages/split_work_package_create.rb

@ -19,8 +19,8 @@ describe 'custom field inplace editor', js: true do
}
let(:wp_page) { Pages::SplitWorkPackage.new(work_package) }
let(:property_name) { :custom_field_1 }
let(:field) { wp_page.edit_field(:customField1) }
let(:property_name) { "customField#{custom_field.id}" }
let(:field) { wp_page.edit_field(property_name) }
before do
login_as(user)
@ -42,8 +42,8 @@ describe 'custom field inplace editor', js: true do
let(:custom_field) {
FactoryGirl.create(:text_issue_custom_field, name: 'LongText')
}
let(:field) { WorkPackageTextAreaField.new wp_page, property_name }
let(:initial_custom_values) { { custom_field.id => 'foo' } }
let(:field) { WorkPackageTextAreaField.new wp_page, :customField1 }
it 'can cancel through the button only' do
# Activate the field
@ -76,12 +76,12 @@ describe 'custom field inplace editor', js: true do
let(:custom_fields) { [custom_field1, custom_field2] }
let(:field1) {
f = wp_page.edit_field(:customField1)
f = wp_page.custom_edit_field(custom_field1)
f.field_type = 'select'
f
}
let(:field2) {
f = wp_page.edit_field(:customField2)
f = wp_page.custom_edit_field(custom_field2)
f.field_type = 'select'
f
}
@ -102,8 +102,8 @@ describe 'custom field inplace editor', js: true do
message: I18n.t('js.notice_successful_update'),
field: field2
wp_page.expect_attributes customField1: 'bar',
customField2: 'Y'
wp_page.expect_attributes :"customField#{custom_field1.id}" => 'bar',
:"customField#{custom_field2.id}" => 'Y'
field1.activate!
field1.expect_value("/api/v3/custom_options/#{custom_value('bar')}")
@ -126,7 +126,6 @@ describe 'custom field inplace editor', js: true do
FactoryGirl.create(:integer_issue_custom_field, args.merge(name: 'MyNumber'))
}
let(:initial_custom_values) { { custom_field.id => 123 } }
let(:fieldName) { "customField#{custom_field.id}" }
context 'with length restrictions' do
let(:args) {
@ -148,7 +147,7 @@ describe 'custom field inplace editor', js: true do
# Correct value
expect_update '9999',
message: I18n.t('js.notice_successful_update')
wp_page.expect_attributes fieldName => '9999'
wp_page.expect_attributes property_name => '9999'
end
end
@ -159,19 +158,19 @@ describe 'custom field inplace editor', js: true do
field.activate!
expect_update '9999999999',
message: I18n.t('js.notice_successful_update')
wp_page.expect_attributes fieldName => '9999999999'
wp_page.expect_attributes property_name => '9999999999'
# Remove value
field.activate!
expect_update '',
message: I18n.t('js.notice_successful_update')
wp_page.expect_attributes fieldName => '-'
wp_page.expect_attributes property_name => '-'
# Zero value
field.activate_edition
expect_update '0',
message: I18n.t('js.notice_successful_update')
wp_page.expect_attributes fieldName => '0'
wp_page.expect_attributes property_name => '0'
end
end
@ -197,7 +196,6 @@ describe 'custom field inplace editor', js: true do
}
let(:args) { {} }
let(:initial_custom_values) { { custom_field.id => 123.50 } }
let(:fieldName) { "customField#{custom_field.id}" }
context 'with english locale' do
let(:user) { FactoryGirl.create :admin, language: 'en' }

@ -177,10 +177,10 @@ describe 'Inline editing work packages', js: true do
expect(page).to have_selector('th a', text: cf_text_name.upcase)
expect(wp_table.row(work_package)).to have_selector('.wp-table--cell-container.-error', count: 2)
cf_text = wp_table.edit_field(work_package, :customField2)
cf_text = wp_table.edit_field(work_package, "customField#{custom_fields.last.id}")
cf_text.update('my custom text', expect_failure: true)
cf_list = wp_table.edit_field(work_package, :customField1)
cf_list = wp_table.edit_field(work_package, "customField#{custom_fields.first.id}")
cf_list.field_type = 'select'
expect(cf_list.input_element).to have_selector('option[selected]', text: 'Please select')
cf_list.set_value('bar')
@ -193,8 +193,8 @@ describe 'Inline editing work packages', js: true do
)
work_package.reload
expect(work_package.custom_field_1).to eq('bar')
expect(work_package.custom_field_2).to eq('my custom text')
expect(work_package.send(custom_fields.first.accessor_name)).to eq('bar')
expect(work_package.send(custom_fields.last.accessor_name)).to eq('my custom text')
# Saveguard to let the background update complete
wp_table.visit!

@ -48,8 +48,8 @@ describe 'Switching types in work package table', js: true do
end
let(:type_field) { wp_table.edit_field(work_package, :type) }
let(:text_field) { wp_table.edit_field(work_package, :customField1) }
let(:req_text_field) { wp_table.edit_field(work_package, :customField2) }
let(:text_field) { wp_table.edit_field(work_package, :"customField#{cf_text.id}") }
let(:req_text_field) { wp_table.edit_field(work_package, :"customField#{cf_req_text.id}") }
before do
login_as(user)
@ -127,8 +127,8 @@ describe 'Switching types in work package table', js: true do
context 'switching to single view' do
let(:wp_split) { wp_table.open_split_view(work_package) }
let(:type_field) { wp_split.edit_field(:type) }
let(:text_field) { wp_split.edit_field(:customField1) }
let(:req_text_field) { wp_split.edit_field(:customField2) }
let(:text_field) { wp_split.edit_field(:"customField#{cf_text.id}") }
let(:req_text_field) { wp_split.edit_field(:"customField#{cf_req_text.id}") }
it 'allows editing and cancelling the new required fields' do
wp_split
@ -278,6 +278,7 @@ describe 'Switching types in work package table', js: true do
login_as(user)
visit new_project_work_packages_path(project.identifier, type: type.id)
expect_angular_frontend_initialized
end
it 'can switch to the type with CF list' do

@ -41,7 +41,7 @@ Capybara.register_server :single_puma do |app, port, host|
workers: 0,
daemon: false,
Silent: false,
Threads: "0:8",
Threads: "0:4",
config_files: ['-']
end
Capybara.server = :single_puma

@ -48,8 +48,20 @@ module Pages
expect(page).to have_selector('.tabrow li.selected', text: tab.to_s.upcase)
end
def edit_field(attribute, context)
WorkPackageField.new(context, attribute)
def edit_field(attribute)
WorkPackageField.new(container, attribute)
end
def custom_edit_field(custom_field)
edit_field("customField#{custom_field.id}").tap do |field|
if custom_field.list?
field.field_type = :select
end
end
end
def container
raise NotImplementedError
end
def expect_hidden_field(attribute)

@ -60,7 +60,8 @@ module Pages
end
def expect_fully_loaded
expect(page).to have_selector '#wp-new-inline-edit--field-subject'
expect_angular_frontend_initialized
expect(page).to have_selector '#wp-new-inline-edit--field-subject', wait: 20
end
def save!

@ -30,9 +30,6 @@ require 'support/pages/abstract_work_package'
module Pages
class FullWorkPackage < Pages::AbstractWorkPackage
def edit_field(attribute)
super(attribute, container)
end
private

@ -31,10 +31,6 @@ require 'support/pages/abstract_work_package_create'
module Pages
class FullWorkPackageCreate < AbstractWorkPackageCreate
def edit_field(attribute)
super(attribute, container)
end
private
def container

@ -38,10 +38,6 @@ module Pages
@selector = '.work-packages--details'
end
def edit_field(attribute)
super(attribute, container)
end
def switch_to_tab(tab:)
find('.tabrow li a', text: tab.upcase).click
end

@ -40,10 +40,6 @@ module Pages
parent_work_package: parent_work_package)
end
def edit_field(attribute)
super(attribute, container)
end
def container
find('.work-packages--new')
end

Loading…
Cancel
Save