Extend watcher tests

pull/5054/head
Oliver Günther 8 years ago
parent a098c44f44
commit ff01fd38f2
No known key found for this signature in database
GPG Key ID: 88872239EB414F99
  1. 12
      spec/features/work_packages/tabs/watcher_tab_spec.rb
  2. 21
      spec/requests/api/v3/watcher_resource_spec.rb

@ -49,7 +49,7 @@ describe 'Watcher tab', js: true, selenium: true do
end
shared_examples 'watchers tab' do
include_context 'ui-select helpers'
include_context 'typeahead helpers'
before do
login_as(user)
@ -59,14 +59,8 @@ describe 'Watcher tab', js: true, selenium: true do
it 'modifying the watcher list modifies the watch button' do
# Add user as watcher
trigger = find('.work-package--watchers-lookup .inplace-editing--trigger-container')
trigger.click
input = find('input.ui-select-search')
input.click
input.send_keys [user.name, :return]
find('.inplace-edit--control--save a').click
typeahead = find('.wp-watcher--autocomplete')
select_typeahead(typeahead, query: user.firstname, select_text: user.name)
# Expect the addition of the user to toggle WP watch button
expect(page).to have_selector('.work-package--watcher-name', count: 1, text: user.name)

@ -43,6 +43,8 @@ describe 'API v3 Watcher resource', type: :request do
let(:work_package) { FactoryGirl.create(:work_package, project: project) }
let(:available_watcher) {
FactoryGirl.create :user,
firstname: 'Something',
lastname: 'Strange',
member_in_project: project,
member_through_role: view_work_packages_role
}
@ -228,6 +230,7 @@ describe 'API v3 Watcher resource', type: :request do
let(:available_watchers_path) { api_v3_paths.available_watchers work_package.id }
before do
available_watcher
get available_watchers_path
end
@ -244,5 +247,23 @@ describe 'API v3 Watcher resource', type: :request do
expect(subject.status).to eql(403)
end
end
describe 'searching for a user' do
let(:available_watchers_path) {
path = api_v3_paths.available_watchers work_package.id
filters = %([{ "name": { "operator": "~", "values": ["#{query}"] } }])
"#{path}?filters=#{filters}"
}
context 'that does not exist' do
let(:query) { 'asdfasdfasdfasdf' }
it_behaves_like 'API V3 collection response', 0, 0, 'User'
end
context 'that does exist' do
let(:query) { 'strange' }
it_behaves_like 'API V3 collection response', 1, 1, 'User'
end
end
end
end

Loading…
Cancel
Save