[26856] Also set the current project context in the comment field (#6129)

And extend the tests to test both in and out of project context

https://community.openproject.com/wp/26856

[ci skip]
pull/6132/head
Oliver Günther 7 years ago committed by GitHub
parent 58991c2b40
commit f79a9c2ade
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 4
      frontend/app/components/work-packages/work-package-comment/work-package-comment.directive.ts
  2. 12
      spec/features/work_packages/details/activity_comments_spec.rb
  3. 29
      spec/features/work_packages/details/inplace_editor/shared_examples.rb

@ -98,6 +98,10 @@ export class CommentFieldDirectiveController {
this.$timeout(() => this.$element.find('.wp-inline-edit--field').focus());
}
public get project() {
return this.workPackage.project;
}
public resetField(withText?:string) {
this.field = new WorkPackageCommentField(this.workPackage, I18n);
this.field.initializeFieldValue(withText);

@ -20,12 +20,12 @@ describe 'activity comments', js: true, selenium: true do
let(:initial_comment) { 'the first comment in this WP' }
before do
login_as(user)
allow(user.pref).to receive(:warn_on_leaving_unsaved?).and_return(false)
login_as(current_user)
allow(current_user.pref).to receive(:warn_on_leaving_unsaved?).and_return(false)
end
context 'with permission' do
let(:user) { FactoryGirl.create :admin }
let(:current_user) { FactoryGirl.create :admin }
before do
wp_page.visit!
@ -125,6 +125,10 @@ describe 'activity comments', js: true, selenium: true do
end
end
it_behaves_like 'a principal autocomplete field' do
let(:field) { comment_field }
end
describe 'quoting' do
it 'can quote a previous comment' do
expect(page).to have_selector('.user-comment .message',
@ -194,7 +198,7 @@ describe 'activity comments', js: true, selenium: true do
end
context 'with no permission' do
let(:user) { FactoryGirl.create(:user, member_in_project: project, member_through_role: role) }
let(:current_user) { FactoryGirl.create(:user, member_in_project: project, member_through_role: role) }
let(:role) { FactoryGirl.create :role, permissions: %i(view_work_packages) }
before do

@ -127,12 +127,29 @@ shared_examples 'a principal autocomplete field' do
let!(:user) { FactoryGirl.create :user, member_in_project: project, firstname: 'John' }
let!(:mentioned_user) { FactoryGirl.create :user, member_in_project: project, firstname: 'Laura', lastname: 'Foobar' }
it 'autocompletes links to user profiles' do
field.activate!
field.input_element.send_keys(" @lau")
expect(page).to have_selector('.atwho-view-ul li.cur', text: mentioned_user.name)
shared_examples 'principal autocomplete on field' do
before do
wp_page.visit!
wp_page.ensure_page_loaded
end
it 'autocompletes links to user profiles' do
field.activate!
field.input_element.send_keys(" @lau")
expect(page).to have_selector('.atwho-view-ul li.cur', text: mentioned_user.name)
field.input_element.send_keys(" @Laura Fo")
expect(page).to have_selector('.atwho-view-ul li.cur', text: mentioned_user.name)
end
end
context 'in project' do
let(:wp_page) { Pages::SplitWorkPackage.new(work_package, project) }
it_behaves_like 'principal autocomplete on field'
end
field.input_element.send_keys(" @Laura Fo")
expect(page).to have_selector('.atwho-view-ul li.cur', text: mentioned_user.name)
context 'outside project' do
let(:wp_page) { Pages::SplitWorkPackage.new(work_package) }
it_behaves_like 'principal autocomplete on field'
end
end

Loading…
Cancel
Save