Merge pull request #3678 from ulferts/fix/spec_robustness

Fix/spec robustness
pull/3689/head
Oliver Günther 9 years ago
commit cfb92a704f
  1. 2
      app/services/user_search_service.rb
  2. 5
      spec/features/work_packages/navigation_spec.rb
  3. 12
      spec/support/authentication_helpers.rb
  4. 8
      spec/support/pages/full_work_package.rb

@ -51,7 +51,7 @@ class UserSearchService
def ids_search(scope)
ids = params[:ids].split(',')
scope.where(id: ids)
scope.not_builtin.where(id: ids)
end
def query_search(scope)

@ -34,8 +34,8 @@ RSpec.feature 'Work package navigation', selenium: true do
let(:work_package) { FactoryGirl.build(:work_package, project: project) }
before do
work_package.save!
login_as(user)
work_package.save!
end
scenario 'all different angular based work package views', js: true do
@ -89,5 +89,8 @@ RSpec.feature 'Work package navigation', selenium: true do
full_work_package.expect_subject
full_work_package.expect_current_path
# Safeguard: ensure spec to have finished loading everything before proceeding to the next spec
full_work_package.ensure_page_loaded
end
end

@ -26,8 +26,18 @@
# See doc/COPYRIGHT.rdoc for more details.
#++
require 'rack_session_access/capybara'
module AuthenticationHelpers
def login_as user
def login_as(user)
if is_a? RSpec::Rails::FeatureExampleGroup
# If we want to mock having finished the login process
# we must set the user_id in rack.session accordingly
# Otherwise e.g. calls to Warden will behave unexpectantly
# as they will login AnonymousUser
page.set_rack_session(user_id: user.id)
end
allow(User).to receive(:current).and_return(user)
end
end

@ -30,7 +30,6 @@ require 'support/pages/page'
module Pages
class FullWorkPackage < Page
attr_reader :work_package
def initialize(work_package)
@ -48,6 +47,11 @@ module Pages
expect(current_path).to eql path
end
def ensure_page_loaded
expect(page).to have_selector('.work-package-details-activities-activity-contents .user',
text: work_package.journals.last.user.name)
end
private
def container
@ -55,7 +59,7 @@ module Pages
end
def path
work_package_path(work_package.id, "activity")
work_package_path(work_package.id, 'activity')
end
end
end

Loading…
Cancel
Save