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 cuke by feature spec

ulferts6e8887c6a4a8
diff --git a/modules/meeting/features/meetings_index.feature b/modules/meeting/features/meetings_index.feature
deleted file mode 100644
index 93a00503d4c..00000000000
--- a/modules/meeting/features/meetings_index.feature
+++ /dev/null
@@ -1,97 +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: Show existing 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 role "user" may have the following rights:
- | view_meetings |
- And the user "alice" is a "user" in the project "dingens"
-
- Scenario: Navigate to the meeting index page with no meetings
- When I am already logged in as "alice"
- And I go to the page for the project "dingens"
- And I click on "Meetings"
- Then I should see "Meetings" within "#content"
- And I should see "There is currently nothing to display." within "#content"
-
- Scenario: Navigate to the meeting index page with 2 meetings
- Given there is 1 meeting in project "dingens" created by "alice" with:
- | title | Meeting 1 |
- | location | Room 1 |
- | duration | 1:30 |
- | start_time | 2011-02-11 12:30:00 |
- And there is 1 meeting in project "dingens" created by "alice" with:
- | title | Meeting 2 |
- | location | Room 2 |
- | duration | 2:30 |
- | start_time | 2011-02-10 11:00:00 |
- When I am already logged in as "alice"
- And I go to the page for the project "dingens"
- And I click on "Meetings"
- Then I should see "Meetings" within "#content"
- But I should not see "There is currently nothing to display." within "#content"
- And I should see 4 meetings
-
- Scenario: Lots of Meetings are split into pages
- Given we paginate after 3 items
- Given there is 3 meetings in project "dingens" that start 0 days from now with:
- | title | Meeting Today |
- Given there is 2 meetings in project "dingens" that start -1 days from now with:
- | title | Meeting Last Week |
- When I am already logged in as "alice"
- And I go to the page for the project "dingens"
- And I click on "Meetings"
- # see above: means 3 meetings
- Then I should see 6 meetings
- And I should see "Meeting Today"
- But I should not see "Meeting Last Week"
- When I click on "2"
- # means 2 meetings
- Then I should see 4 meetings
- And I should not see "Meeting Today"
- But I should see "Meeting Last Week"
-
- Scenario: Jumps to page of current date when no page given
- Given we paginate after 3 items
- Given there is 5 meetings in project "dingens" that start +7 days from now with:
- | title | Meeting Next Week |
- Given there is 5 meetings in project "dingens" that start 1 days from now with:
- | title | Meeting Tomorrow |
- Given there is 5 meetings in project "dingens" that start 0 days from now with:
- | title | Meeting Today |
- Given there is 5 meetings in project "dingens" that start -7 days from now with:
- | title | Meeting Last Week |
- When I am already logged in as "alice"
- And I go to the page for the project "dingens"
- And I click on "Meetings"
- Then I should see "Meeting Today"
- And I should see "Meeting Tomorrow"
- But I should not see "Meeting Last Week"
- And I should not see "Meeting Next Week"
diff --git a/modules/meeting/features/step_definitions/meeting_steps.rb b/modules/meeting/features/step_definitions/meeting_steps.rb
index 0899aefcc3e..c819aea7af8 100644
--- a/modules/meeting/features/step_definitions/meeting_steps.rb
+++ b/modules/meeting/features/step_definitions/meeting_steps.rb
@@ -27,14 +27,6 @@ Given /^there is (\d+) [Mm]eetings? in project "(.+)" created by "(.+)" with:$/
end
end
-Given /^there is (\d+) [Mm]eetings? in project "(.+)" that start (.*) days? from now with:$/ do |count, project, time, table|
- count.to_i.times do
- m = FactoryBot.build(:meeting, start_time: Time.now + time.to_i.days)
- m.project = Project.find_by_name(project)
- send_table_to_object(m, table)
- end
-end
-
Given /^the [Mm]eeting "(.+)" has 1 agenda with:$/ do |meeting, table|
m = Meeting.find_by_title(meeting)
ma = MeetingAgenda.find_by_meeting_id(m.id) || FactoryBot.build(:meeting_agenda, meeting: m)
diff --git a/modules/meeting/spec/features/meetings_index_spec.rb b/modules/meeting/spec/features/meetings_index_spec.rb
new file mode 100644
index 00000000000..c5db6e743ed
--- /dev/null
+++ b/modules/meeting/spec/features/meetings_index_spec.rb
@@ -0,0 +1,109 @@
+#-- 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', type: :feature do
+ let(:project) { FactoryBot.create :project, enabled_module_names: %w[meetings] }
+ let(:other_project) { FactoryBot.create :project, enabled_module_names: %w[meetings] }
+ let(:role) { FactoryBot.create(:role, permissions: permissions) }
+ let(:permissions) { %i(view_meetings) }
+ let(:user) do
+ FactoryBot.create(:user) do |user|
+ [project, other_project].each do |p|
+ FactoryBot.create(:member,
+ project: p,
+ principal: user,
+ roles: [role])
+ end
+ end
+ end
+
+ let(:meeting) do
+ FactoryBot.create :meeting, project: project, title: 'Awesome meeting today!', start_time: Time.now
+ end
+ let(:tomorrows_meeting) do
+ FactoryBot.create :meeting, project: project, title: 'Awesome meeting tomorrow!', start_time: Time.now + 1.day
+ end
+ let(:yesterdays_meeting) do
+ FactoryBot.create :meeting, project: project, title: 'Awesome meeting yesterday!', start_time: Time.now - 1.day
+ end
+ let!(:other_project_meeting) do
+ FactoryBot.create :meeting, project: other_project, title: 'Awesome other project meeting!'
+ end
+ let(:meetings_page) { Pages::Meetings::Index.new(project) }
+
+ before do
+ login_as(user)
+ end
+
+ scenario 'visting page via menu with no meetings' do
+ meetings_page.navigate_by_menu
+
+ meetings_page.expect_no_meetings_listed
+ end
+
+ scenario 'visiting page with 1 meeting listed' do
+ meeting
+ meetings_page.visit!
+
+ meetings_page.expect_meetings_listed(meeting)
+ end
+
+ scenario 'visiting page with pagination', with_settings: { per_page_options: '1' } do
+ meeting
+ tomorrows_meeting
+ yesterdays_meeting
+
+ # Jumps to today's meeting if not specified differently
+ meetings_page.visit!
+ meetings_page.expect_meetings_listed(meeting)
+ meetings_page.expect_meetings_not_listed(tomorrows_meeting, yesterdays_meeting)
+
+ meetings_page.expect_to_be_on_page(2)
+
+ # Sorted by start_time ascending
+ meetings_page.to_page(1)
+ meetings_page.expect_meetings_listed(tomorrows_meeting)
+ meetings_page.expect_meetings_not_listed(meeting, yesterdays_meeting)
+
+ meetings_page.to_page(3)
+ meetings_page.expect_meetings_listed(yesterdays_meeting)
+ meetings_page.expect_meetings_not_listed(meeting, tomorrows_meeting)
+
+ # The 'today' link will navigate back to today
+ meetings_page.to_today
+
+ meetings_page.expect_meetings_listed(meeting)
+ meetings_page.expect_meetings_not_listed(tomorrows_meeting, yesterdays_meeting)
+
+ meetings_page.expect_to_be_on_page(2)
+ end
+end
diff --git a/modules/meeting/spec/support/pages/meetings/index.rb b/modules/meeting/spec/support/pages/meetings/index.rb
index 63aef633dfd..0f23e64d2ff 100644
--- a/modules/meeting/spec/support/pages/meetings/index.rb
+++ b/modules/meeting/spec/support/pages/meetings/index.rb
@@ -51,6 +51,54 @@ module Pages::Meetings
end
end
+ def expect_no_meetings_listed
+ within '#content-wrapper' do
+ expect(page)
+ .to have_content I18n.t(:no_results_title_text)
+ end
+ end
+
+ def expect_meetings_listed(*meetings)
+ within '#content-wrapper' do
+ meetings.each do |meeting|
+ expect(page).to have_selector(".meeting",
+ text: meeting.title)
+ end
+ end
+ end
+
+ def expect_meetings_not_listed(*meetings)
+ within '#content-wrapper' do
+ meetings.each do |meeting|
+ expect(page).to have_no_selector(".meeting",
+ text: meeting.title)
+ end
+ end
+ end
+
+ def expect_to_be_on_page(number)
+ expect(page)
+ .to have_selector('.pagination--item.-current',
+ text: number)
+ end
+
+ def to_page(number)
+ within '.pagination--pages' do
+ click_link number.to_s
+ end
+ end
+
+ def to_today
+ click_link 'today'
+ end
+
+ def navigate_by_menu
+ visit project_path(project)
+ within '#main-menu' do
+ click_link 'Meetings'
+ end
+ end
+
def path
meetings_path(project)
end