diff --git a/spec/features/work_packages/project_context_switch_spec.rb b/spec/features/work_packages/project_context_switch_spec.rb new file mode 100644 index 0000000000..4082b5433e --- /dev/null +++ b/spec/features/work_packages/project_context_switch_spec.rb @@ -0,0 +1,33 @@ +require 'spec_helper' + +describe 'Project context switching spec', js: true do + let(:user) { FactoryGirl.create :admin } + + let(:project) { FactoryGirl.create(:project) } + let(:work_package) { FactoryGirl.create(:work_package, project: project) } + + let(:wp_table) { Pages::WorkPackagesTable.new } + let(:wp_page) { Pages::FullWorkPackage.new(work_package, project) } + + before do + login_as(user) + work_package + end + + it 'allows to switch context' do + wp_table.visit! + wp_table.expect_work_package_listed work_package + + # Open WP in global selection + wp_table.open_full_screen_by_link work_package + + # Follow link to project context + expect(page).to have_selector('.attributes-group.-project-context') + link = find('.attributes-group.-project-context .project-context--switch-link') + expect(link[:href]).to include(project_work_package_path(project.id, work_package.id)) + + link.click + wp_page.ensure_page_loaded + expect(page).to have_no_selector('.attributes-group.-project-context') + end +end diff --git a/spec/support/pages/work_packages_table.rb b/spec/support/pages/work_packages_table.rb index 5b0a445ca2..3ed675fd7d 100644 --- a/spec/support/pages/work_packages_table.rb +++ b/spec/support/pages/work_packages_table.rb @@ -137,6 +137,8 @@ module Pages def open_full_screen_by_link(work_package) row(work_package).click_link(work_package.id) + + FullWorkPackage.new(work_package) end def row(work_package)