Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

replace meeting#new cukes with specs

ulferts8863364b8d41
diff --git a/modules/meeting/app/helpers/meetings_helper.rb b/modules/meeting/app/helpers/meetings_helper.rb
index d47c453cba4..37e27dc4d06 100644
--- a/modules/meeting/app/helpers/meetings_helper.rb
+++ b/modules/meeting/app/helpers/meetings_helper.rb
@@ -20,11 +20,16 @@
module MeetingsHelper
def format_participant_list(participants)
- participants.sort.map { |p| link_to_user p.user }.join('; ').html_safe
+ if participants.any?
+ participants.sort.map { |p| link_to_user p.user }.join('; ').html_safe
+ else
+ t('placeholders.default')
+ end
end
def render_meeting_journal(model, journal, options = {})
return '' if journal.initial?
+
journal_content = render_journal_details(journal, :label_updated_time_by, model, options)
content_tag 'div', journal_content, id: "change-#{journal.id}", class: 'journal'
end
diff --git a/modules/meeting/features/meetings_new.feature b/modules/meeting/features/meetings_new.feature
deleted file mode 100644
index 022af03fe4a..00000000000
--- a/modules/meeting/features/meetings_new.feature
+++ /dev/null
@@ -1,107 +0,0 @@
-#-- copyright
-# OpenProject Meeting Plugin
-#
-# Copyright (C) 2011-2014 the OpenProject Foundation (OPF)
-#
-# This program is free software; you can redistribute it and/or
-# modify it under the terms of the GNU General Public License version 3.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-#
-# See doc/COPYRIGHT.md for more details.
-#++
-
-Feature: Create new meetings
-
- Background:
- Given there is 1 project with the following:
- | identifier | dingens |
- | name | dingens |
- And the project "dingens" uses the following modules:
- | meetings |
- And there is 1 user with:
- | login | alice |
- | language | en |
- And there is a role "user"
- And the user "alice" is a "user" in the project "dingens"
-
- Scenario: Navigate to the meeting index page with no permission to create new meetings
- Given the role "user" may have the following rights:
- | view_meetings |
- When I am already logged in as "alice"
- And I go to the Meetings page for the project called "dingens"
- Then I should not see "Meeting" within ".toolbar-items"
-
- Scenario: Navigate to the meeting index page with permission to create new meetings
- Given the role "user" may have the following rights:
- | view_meetings |
- | create_meetings |
- When I am already logged in as "alice"
- And I go to the Meetings page for the project called "dingens"
- Then I should see "Meeting" within ".toolbar-items"
-
- Scenario: Create a new meeting with no title
- Given the role "user" may have the following rights:
- | view_meetings |
- | create_meetings |
- When I am already logged in as "alice"
- And I go to the Meetings page for the project called "dingens"
- And I click on "New Meeting"
- And I click on "Create"
- Then I should see "Title can't be blank"
-
- Scenario Outline: Create a new meeting with a title and a date, time, and duration with no and different time zones set
- Given the role "user" may have the following rights:
- | view_meetings |
- | create_meetings |
- When I am already logged in as "alice"
- And the user "alice" has the following preferences
- | time_zone | <t_zone> |
- And I go to the Meetings page for the project called "dingens"
- And I click on "New Meeting"
- And I fill in the following:
- | meeting_title | FSR Sitzung 123 |
- | meeting-form-start-date | 2013-03-28 |
- | meeting-form-start-time | 13:30 |
- | meeting-form-duration | 1.5 |
- And I click on "Create"
- Then I should see "Successful creation."
- And I should see "FSR Sitzung 123"
- And I should see "03/28/2013 01:30 PM - 03:00 PM"
-
- Examples:
- | t_zone |
- | CET |
- | UTC |
- | |
- | Pacific Time (US & Canada) |
-
- Scenario: Visit the new meeting page to make sure the author is selected as invited
- Given the role "user" may have the following rights:
- | view_meetings |
- | create_meetings |
- When I am already logged in as "alice"
- And I go to the Meetings page for the project called "dingens"
- And I click on "New Meeting"
- Then the "meeting[participants_attributes][][invited]" checkbox should be checked
-
- Scenario: Create a meeting in a project without members shouldn't error out
- Given there is 1 project with the following:
- | identifier | foreverempty |
- | name | foreverempty |
- And the project "foreverempty" uses the following modules:
- | meetings |
- When I am already admin
- And I go to the Meetings page for the project called "foreverempty"
- And I click on "New Meeting"
- And I fill in the following:
- | meeting_title | Emtpy Meetings |
- And I press "Create"
- Then I should see "Successful creation."
diff --git a/modules/meeting/spec/features/meetings_new_spec.rb b/modules/meeting/spec/features/meetings_new_spec.rb
new file mode 100644
index 00000000000..762e4ed21ad
--- /dev/null
+++ b/modules/meeting/spec/features/meetings_new_spec.rb
@@ -0,0 +1,127 @@
+#-- copyright
+# OpenProject is a project management system.
+# Copyright (C) 2012-2015 the OpenProject Foundation (OPF)
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License version 3.
+#
+# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
+# Copyright (C) 2006-2013 Jean-Philippe Lang
+# Copyright (C) 2010-2013 the ChiliProject Team
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+#
+# See doc/COPYRIGHT.rdoc for more details.
+#++
+
+require 'spec_helper'
+
+require_relative '../support/pages/meetings/index'
+
+describe 'Meetings new', type: :feature do
+ let(:project) { FactoryBot.create :project, enabled_module_names: %w[meetings] }
+ let(:time_zone) { 'utc' }
+ let(:user) do
+ FactoryBot.create(:user,
+ lastname: 'First',
+ member_in_project: project,
+ member_with_permissions: permissions).tap do |u|
+ u.pref[:time_zone] = time_zone
+
+ u.save!
+ end
+ end
+ let(:other_user) do
+ FactoryBot.create(:user,
+ lastname: 'Second',
+ member_in_project: project,
+ member_with_permissions: permissions)
+ end
+ let(:admin) do
+ FactoryBot.create(:admin)
+ end
+ let(:permissions) { %i[view_meetings create_meetings] }
+ let(:current_user) { user }
+
+ before do
+ login_as(current_user)
+ end
+
+ let(:index_page) { ::Pages::Meetings::Index.new(project) }
+
+ context 'with permission to create meetings' do
+ before do
+ other_user
+ end
+
+ ['CET', 'UTC', '', 'Pacific Time (US & Canada)'].each do |zone|
+ let(:time_zone) { zone }
+
+ it "allows creating a project and handles errors in time zone #{zone}" do
+ index_page.visit!
+
+ new_page = index_page.click_create_new
+
+ # Error when no title is provided. Only works without js as otherwise html5 would already catch this
+ new_page.click_create
+
+ new_page.expect_notification(type: :error, message: "Title can't be blank")
+
+ new_page.set_title 'Some title'
+ new_page.set_start_date '2013-03-28'
+ new_page.set_start_time '13:30'
+ new_page.set_duration '1.5'
+ new_page.invite(other_user)
+
+ show_page = new_page.click_create
+
+ show_page.expect_notification(message: 'Successful creation')
+
+ show_page.expect_invited(user, other_user)
+
+ show_page.expect_date_time "03/28/2013 01:30 PM - 03:00 PM"
+ end
+ end
+ end
+
+ context 'without permission to create meetings' do
+ let(:permissions) { %i[view_meetings] }
+
+ it 'shows no edit link' do
+ index_page.visit!
+
+ index_page.expect_no_create_new_button
+ end
+ end
+
+ context 'as an admin' do
+ let(:current_user) { admin }
+
+ it 'allows creating meeting in a project without members' do
+ index_page.visit!
+
+ new_page = index_page.click_create_new
+
+ new_page.set_title 'Some title'
+
+ show_page = new_page.click_create
+
+ show_page.expect_notification(message: 'Successful creation')
+
+ # Not sure if that is then intended behaviour but that is what is currently programmed
+ show_page.expect_invited(admin)
+ end
+ end
+end
diff --git a/modules/meeting/spec/support/pages/meetings/base.rb b/modules/meeting/spec/support/pages/meetings/base.rb
new file mode 100644
index 00000000000..61b342f4fa6
--- /dev/null
+++ b/modules/meeting/spec/support/pages/meetings/base.rb
@@ -0,0 +1,41 @@
+#-- copyright
+# OpenProject is a project management system.
+# Copyright (C) 2012-2018 the OpenProject Foundation (OPF)
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License version 3.
+#
+# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
+# Copyright (C) 2006-2017 Jean-Philippe Lang
+# Copyright (C) 2010-2013 the ChiliProject Team
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+#
+# See docs/COPYRIGHT.rdoc for more details.
+#++
+
+module Pages::Meetings
+ class Base < Pages::Page
+ attr_accessor :project
+
+ def initialize(project)
+ self.project = project
+ end
+
+ def notification_type
+ :rails
+ end
+ end
+end
diff --git a/modules/meeting/spec/support/pages/meetings/index.rb b/modules/meeting/spec/support/pages/meetings/index.rb
new file mode 100644
index 00000000000..63aef633dfd
--- /dev/null
+++ b/modules/meeting/spec/support/pages/meetings/index.rb
@@ -0,0 +1,58 @@
+#-- copyright
+# OpenProject is a project management system.
+# Copyright (C) 2012-2018 the OpenProject Foundation (OPF)
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License version 3.
+#
+# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
+# Copyright (C) 2006-2017 Jean-Philippe Lang
+# Copyright (C) 2010-2013 the ChiliProject Team
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+#
+# See docs/COPYRIGHT.rdoc for more details.
+#++
+
+require_relative './new'
+
+module Pages::Meetings
+ class Index < Pages::Page
+ attr_accessor :project
+
+ def initialize(project)
+ self.project = project
+ end
+
+ def click_create_new
+ within '.toolbar-items' do
+ click_link 'Meeting'
+ end
+
+ New.new(project)
+ end
+
+ def expect_no_create_new_button
+ within '.toolbar-items' do
+ expect(page)
+ .to have_no_link 'Meeting'
+ end
+ end
+
+ def path
+ meetings_path(project)
+ end
+ end
+end
diff --git a/modules/meeting/spec/support/pages/meetings/new.rb b/modules/meeting/spec/support/pages/meetings/new.rb
new file mode 100644
index 00000000000..2d1385d884c
--- /dev/null
+++ b/modules/meeting/spec/support/pages/meetings/new.rb
@@ -0,0 +1,70 @@
+#-- copyright
+# OpenProject is a project management system.
+# Copyright (C) 2012-2018 the OpenProject Foundation (OPF)
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License version 3.
+#
+# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
+# Copyright (C) 2006-2017 Jean-Philippe Lang
+# Copyright (C) 2010-2013 the ChiliProject Team
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+#
+# See docs/COPYRIGHT.rdoc for more details.
+#++
+
+require_relative './base'
+require_relative './show'
+
+module Pages::Meetings
+ class New < Base
+ def click_create
+ click_button 'Create'
+
+ meeting = Meeting.last
+
+ if meeting
+ Pages::Meetings::Show.new(meeting)
+ else
+ self
+ end
+ end
+
+ def set_title(text)
+ fill_in 'Title', with: text
+ end
+
+ def set_start_date(date)
+ fill_in 'Start date', with: date
+ end
+
+ def set_start_time(time)
+ fill_in 'Time', with: time
+ end
+
+ def set_duration(duration)
+ fill_in 'Duration', with: duration
+ end
+
+ def invite(user)
+ check "#{user.name} invited"
+ end
+
+ def path
+ new_meeting_path(project)
+ end
+ end
+end
diff --git a/modules/meeting/spec/support/pages/meetings/show.rb b/modules/meeting/spec/support/pages/meetings/show.rb
new file mode 100644
index 00000000000..e7d9db3b51a
--- /dev/null
+++ b/modules/meeting/spec/support/pages/meetings/show.rb
@@ -0,0 +1,62 @@
+#-- copyright
+# OpenProject is a project management system.
+# Copyright (C) 2012-2018 the OpenProject Foundation (OPF)
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License version 3.
+#
+# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
+# Copyright (C) 2006-2017 Jean-Philippe Lang
+# Copyright (C) 2010-2013 the ChiliProject Team
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+#
+# See docs/COPYRIGHT.rdoc for more details.
+#++
+
+require_relative './base'
+
+module Pages::Meetings
+ class Show < Base
+ attr_accessor :meeting
+
+ def initialize(meeting)
+ self.meeting = meeting
+ end
+
+ def expect_no_invited
+ expect(page)
+ .to have_content("#{Meeting.human_attribute_name(:participants_invited)}: -")
+ end
+
+ def expect_no_attended
+ expect(page)
+ .to have_content("#{Meeting.human_attribute_name(:participants_attended)}: -")
+ end
+
+ def expect_invited(*users)
+ users.map(&:name).sort.join('; ')
+ end
+
+ def expect_date_time(expected)
+ expect(page)
+ .to have_content("Time: #{expected}")
+ end
+
+ def path
+ meeting_path(meeting)
+ end
+ end
+end
diff --git a/spec/support/pages/page.rb b/spec/support/pages/page.rb
index e4315d6027b..f59889c60b9 100644
--- a/spec/support/pages/page.rb
+++ b/spec/support/pages/page.rb
@@ -90,6 +90,8 @@ module Pages
expect(page).to have_selector(".notification-box.-#{type}", text: message, wait: 20)
elsif type == :error
expect(page).to have_selector(".errorExplanation", text: message)
+ elsif type == :success
+ expect(page).to have_selector(".flash.notice", text: message)
else
raise NotImplementedError
end