-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d5aa2b9
commit 5a72451
Showing
2 changed files
with
81 additions
and
3 deletions.
There are no files selected for viewing
54 changes: 54 additions & 0 deletions
54
modules/meeting/spec/factories/recurring_meeting_factory.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
#-- copyright | ||
# OpenProject is an open source project management software. | ||
# Copyright (C) the OpenProject GmbH | ||
# | ||
# 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 COPYRIGHT and LICENSE files for more details. | ||
#++ | ||
|
||
FactoryBot.define do | ||
factory :recurring_meeting, class: "RecurringMeeting" do |m| | ||
author factory: :user | ||
project | ||
start_time { Date.tomorrow + 10.hours } | ||
end_date { 1.year.from_now } | ||
duration { 1.0 } | ||
frequency { "weekly" } | ||
interval { 1 } | ||
iterations { 10 } | ||
end_after { "specific_date" } | ||
|
||
location { "https://some-url.com" } | ||
m.sequence(:title) { |n| "Meeting series #{n}" } | ||
|
||
after(:create) do |recurring_meeting, evaluator| | ||
recurring_meeting.project = evaluator.project if evaluator.project | ||
recurring_meeting.template = create(:meeting, recurring_meeting:) | ||
end | ||
|
||
after(:stub) do |recurring_meeting, evaluator| | ||
recurring_meeting.project = evaluator.project if evaluator.project | ||
recurring_meeting.template = build_stubbed(:meeting, recurring_meeting:) | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,29 @@ | ||
require 'rails_helper' | ||
require "spec_helper" | ||
require_module_spec_helper | ||
|
||
RSpec.describe RecurringMeeting, type: :model do | ||
pending "add some examples to (or delete) #{__FILE__}" | ||
RSpec.describe RecurringMeeting, | ||
with_settings: { | ||
date_format: "%Y-%m-%d" | ||
} do | ||
describe "end_date" do | ||
subject { build(:recurring_meeting, start_date: (Date.current + 2.days).iso8601, end_date:) } | ||
|
||
context "with end_date before start_date" do | ||
let(:end_date) { Date.current + 1.day } | ||
|
||
it "is invalid" do | ||
expect(subject).not_to be_valid | ||
expect(subject.errors[:end_date]).to include("must be after #{subject.start_date}.") | ||
end | ||
end | ||
|
||
context "with end_date in the past" do | ||
let(:end_date) { Date.yesterday } | ||
|
||
it "is invalid" do | ||
expect(subject).not_to be_valid | ||
expect(subject.errors[:end_date]).to include("must be in the future.") | ||
end | ||
end | ||
end | ||
end |