From 6761e2c84f673d0219819548cd99b251523e137c Mon Sep 17 00:00:00 2001 From: Jarek Radosz Date: Tue, 1 Aug 2023 22:32:30 +0200 Subject: [PATCH] DEV: Clean up the plugin (#426) --- .gitignore | 8 +- .streerc | 2 +- Gemfile | 1 + Gemfile.lock | 46 +- README.md | 18 +- .../upcoming_events/index.html.erb | 0 .../components/admin-holidays-list-item.hbs | 0 .../components/admin-holidays-list.hbs | 2 +- .../bulk-invite-sample-csv-file.hbs | 0 .../components/csv-uploader.hbs | 0 .../components/event-field.hbs | 0 .../discourse/components/region-input.js | 2 +- .../components/toggle-invitees-modal.hbs | 0 .../components/upcoming-events-calendar.hbs | 0 .../components/upcoming-events-calendar.js | 4 +- .../on-holiday-indicator.hbs | 0 .../after-user-name/holiday-flair.hbs | 0 .../after-user-name/holiday-flair.js | 0 .../category-calendar.hbs | 0 .../category-calendar.js | 0 .../category-calendar.hbs | 0 .../category-calendar.js | 0 .../category-events.hbs | 0 .../user-custom-preferences/region.hbs | 0 .../user-custom-preferences/region.js | 2 +- .../discourse-post-event-builder.js | 2 +- .../helpers/format-event-name.js | 0 .../helpers/format-future-date.js | 2 +- .../{ => discourse}/helpers/render-invitee.js | 0 .../initializers/add-event-ui-builder.js | 0 .../initializers/add-hamburger-menu-action.js | 0 .../initializers/decorate-topic-title.js | 4 +- .../initializers/disable-sort.js | 0 .../initializers/discourse-calendar.js | 10 +- .../initializers/discourse-group-timezones.js | 0 .../discourse-post-event-decorator.js | 2 +- .../initializers/event-relative-date.js | 2 +- .../{ => discourse}/lib/clean-title.js | 0 .../javascripts/{ => discourse}/lib/colors.js | 0 .../discourse-markdown/discourse-calendar.js | 0 .../discourse-post-event-block.js | 0 .../{ => discourse}/lib/event-local-date.js | 2 +- .../lib/event-relative-date.js | 2 +- .../lib/guess-best-date-format.js | 0 .../{ => discourse}/lib/raw-event-helper.js | 0 .../{ => discourse}/lib/regions.js | 0 .../{ => discourse}/lib/round-time.js | 0 ...discourse-group-timezones-time-traveler.js | 2 +- .../widgets/discourse-group-timezones.js | 2 +- .../discourse/widgets/discourse-post-event.js | 4 +- .../common/discourse-calendar.scss | 6 +- .../common/discourse-post-event-builder.scss | 4 +- .../common/discourse-post-event-core-ext.scss | 4 +- .../common/discourse-post-event.scss | 8 +- .../common/upcoming-events-calendar.scss | 2 +- .../mobile/discourse-calendar.scss | 4 +- .../mobile/discourse-post-event.scss | 2 +- config/routes.rb | 30 +- config/settings.yml | 1 - lib/calendar_settings_validator.rb | 4 +- package.json | 6 +- plugin.rb | 1 - spec/integration/post_spec.rb | 48 +- .../discourse_post_event/bulk_invite_spec.rb | 25 +- .../discourse_post_event/bump_topic_spec.rb | 8 +- .../send_reminder_spec.rb | 134 +- .../scheduled/create_holiday_events_spec.rb | 22 +- .../scheduled/delete_expired_event_posts.rb | 14 +- .../update_holiday_usernames_spec.rb | 22 +- .../discourse_post_event/event_finder_spec.rb | 24 +- .../discourse_post_event/event_parser_spec.rb | 29 +- spec/serializers/user_serializer_spec.rb | 8 +- .../admin-holidays-list-item-test.js | 121 +- .../components/admin-holidays-list-test.js | 71 +- .../components/region-input-test.js | 61 +- yarn.lock | 1371 +++++++++-------- 76 files changed, 1101 insertions(+), 1048 deletions(-) delete mode 100644 app/views/discourse_post_event/upcoming_events/index.html.erb rename assets/javascripts/discourse/{templates => }/components/admin-holidays-list-item.hbs (100%) rename assets/javascripts/discourse/{templates => }/components/admin-holidays-list.hbs (90%) rename assets/javascripts/discourse/{templates => }/components/bulk-invite-sample-csv-file.hbs (100%) rename assets/javascripts/discourse/{templates => }/components/csv-uploader.hbs (100%) rename assets/javascripts/discourse/{templates => }/components/event-field.hbs (100%) rename assets/javascripts/discourse/{templates => }/components/toggle-invitees-modal.hbs (100%) rename assets/javascripts/discourse/{templates => }/components/upcoming-events-calendar.hbs (100%) rename assets/javascripts/{ => discourse}/connectors/after-chat-channel-username/on-holiday-indicator.hbs (100%) rename assets/javascripts/{templates => discourse}/connectors/after-user-name/holiday-flair.hbs (100%) rename assets/javascripts/{ => discourse}/connectors/after-user-name/holiday-flair.js (100%) rename assets/javascripts/{templates => discourse}/connectors/before-topic-list-body/category-calendar.hbs (100%) rename assets/javascripts/{ => discourse}/connectors/before-topic-list-body/category-calendar.js (100%) rename assets/javascripts/{templates => discourse}/connectors/discovery-list-container-top/category-calendar.hbs (100%) rename assets/javascripts/{ => discourse}/connectors/discovery-list-container-top/category-calendar.js (100%) rename assets/javascripts/{templates => discourse}/connectors/discovery-list-container-top/category-events.hbs (100%) rename assets/javascripts/{templates => discourse}/connectors/user-custom-preferences/region.hbs (100%) rename assets/javascripts/{ => discourse}/connectors/user-custom-preferences/region.js (85%) rename assets/javascripts/{ => discourse}/helpers/format-event-name.js (100%) rename assets/javascripts/{ => discourse}/helpers/format-future-date.js (69%) rename assets/javascripts/{ => discourse}/helpers/render-invitee.js (100%) rename assets/javascripts/{ => discourse}/initializers/add-event-ui-builder.js (100%) rename assets/javascripts/{ => discourse}/initializers/add-hamburger-menu-action.js (100%) rename assets/javascripts/{ => discourse}/initializers/decorate-topic-title.js (88%) rename assets/javascripts/{ => discourse}/initializers/disable-sort.js (100%) rename assets/javascripts/{ => discourse}/initializers/discourse-calendar.js (98%) rename assets/javascripts/{ => discourse}/initializers/discourse-group-timezones.js (100%) rename assets/javascripts/{ => discourse}/initializers/discourse-post-event-decorator.js (98%) rename assets/javascripts/{ => discourse}/initializers/event-relative-date.js (89%) rename assets/javascripts/{ => discourse}/lib/clean-title.js (100%) rename assets/javascripts/{ => discourse}/lib/colors.js (100%) rename assets/javascripts/{ => discourse}/lib/discourse-markdown/discourse-calendar.js (100%) rename assets/javascripts/{ => discourse}/lib/discourse-markdown/discourse-post-event-block.js (100%) rename assets/javascripts/{ => discourse}/lib/event-local-date.js (86%) rename assets/javascripts/{ => discourse}/lib/event-relative-date.js (94%) rename assets/javascripts/{ => discourse}/lib/guess-best-date-format.js (100%) rename assets/javascripts/{ => discourse}/lib/raw-event-helper.js (100%) rename assets/javascripts/{ => discourse}/lib/regions.js (100%) rename assets/javascripts/{ => discourse}/lib/round-time.js (100%) diff --git a/.gitignore b/.gitignore index 9cc7a2dfa..74cad9dba 100644 --- a/.gitignore +++ b/.gitignore @@ -1,7 +1,3 @@ -.DS_Store -gems/ -/node_modules -.on-save.json node_modules -yarn-error.log -.rubocop-https---raw-githubusercontent-com-discourse-* +/gems +/auto_generated diff --git a/.streerc b/.streerc index 2c98fa779..1418bf835 100644 --- a/.streerc +++ b/.streerc @@ -1,3 +1,3 @@ --print-width=100 ---plugins=plugin/trailing_comma +--plugins=plugin/trailing_comma,disable_ternary --ignore-files=vendor/* \ No newline at end of file diff --git a/Gemfile b/Gemfile index 31d8bf774..d5e805cc8 100644 --- a/Gemfile +++ b/Gemfile @@ -5,4 +5,5 @@ source "https://rubygems.org" group :development do gem "rubocop-discourse" gem "syntax_tree" + gem "syntax_tree-disable_ternary" end diff --git a/Gemfile.lock b/Gemfile.lock index 348ff700c..dcdb3b8cc 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -2,35 +2,46 @@ GEM remote: https://rubygems.org/ specs: ast (2.4.2) - json (2.6.2) - parallel (1.22.1) - parser (3.1.2.1) + json (2.6.3) + language_server-protocol (3.17.0.3) + parallel (1.23.0) + parser (3.2.2.3) ast (~> 2.4.1) - prettier_print (1.2.0) + racc + prettier_print (1.2.1) + racc (1.7.1) rainbow (3.1.1) - regexp_parser (2.6.0) - rexml (3.2.5) - rubocop (1.36.0) + regexp_parser (2.8.1) + rexml (3.2.6) + rubocop (1.55.1) json (~> 2.3) + language_server-protocol (>= 3.17.0) parallel (~> 1.10) - parser (>= 3.1.2.1) + parser (>= 3.2.2.3) rainbow (>= 2.2.2, < 4.0) regexp_parser (>= 1.8, < 3.0) rexml (>= 3.2.5, < 4.0) - rubocop-ast (>= 1.20.1, < 2.0) + rubocop-ast (>= 1.28.1, < 2.0) ruby-progressbar (~> 1.7) - unicode-display_width (>= 1.4.0, < 3.0) - rubocop-ast (1.21.0) - parser (>= 3.1.1.0) - rubocop-discourse (3.0) + unicode-display_width (>= 2.4.0, < 3.0) + rubocop-ast (1.29.0) + parser (>= 3.2.1.0) + rubocop-capybara (2.18.0) + rubocop (~> 1.41) + rubocop-discourse (3.3.0) rubocop (>= 1.1.0) rubocop-rspec (>= 2.0.0) - rubocop-rspec (2.13.2) + rubocop-factory_bot (2.23.1) rubocop (~> 1.33) - ruby-progressbar (1.11.0) - syntax_tree (5.1.0) + rubocop-rspec (2.23.0) + rubocop (~> 1.33) + rubocop-capybara (~> 2.17) + rubocop-factory_bot (~> 2.22) + ruby-progressbar (1.13.0) + syntax_tree (6.1.1) prettier_print (>= 1.2.0) - unicode-display_width (2.3.0) + syntax_tree-disable_ternary (1.0.0) + unicode-display_width (2.4.2) PLATFORMS ruby @@ -38,6 +49,7 @@ PLATFORMS DEPENDENCIES rubocop-discourse syntax_tree + syntax_tree-disable_ternary BUNDLED WITH 2.1.4 diff --git a/README.md b/README.md index 690b1f80c..71c70879e 100644 --- a/README.md +++ b/README.md @@ -1,38 +1,38 @@ -## Discourse Calendar +# Discourse Calendar Adds the ability to create a dynamic calendar in the first post of a topic. Topic discussing the plugin itself can be found here: [https://meta.discourse.org/t/discourse-calendar/97376](https://meta.discourse.org/t/discourse-calendar/97376) -### Customisation +## Customization -#### Plugins - -##### Events +### Events - `discourse_post_event_event_will_start` this DiscourseEvent will be triggered one hour before an event starts - `discourse_post_event_event_started` this DiscourseEvent will be triggered when an event starts - `discourse_post_event_event_ended` this DiscourseEvent will be triggered when an event ends -#### Custom Fields +### Custom Fields Custom fields can be set in plugin settings. Once added a new form will appear on event UI. These custom fields are available when a plugin event is triggered. -#### Holidays +### Holidays See an incorrect or missing holiday? Familiarize yourself with the [holiday definition Syntax](vendor/holidays/definitions/doc/SYNTAX.md). Then make your updates in the `vendor/holiday/definitions` directory. Generate updated holidays as follows. + ```sh cd vendor/holidays # Generate holiday definitions -bundle exec rake generate:definitions +bin/rails generate:definitions ``` Install the plugin and switch to the discourse root(not the plugin directory). + ```sh # Collect all holiday regions into assets/javascripts/lib/regions.js -bundle exec rake javascript:update_constants +bin/rails javascript:update_constants ``` diff --git a/app/views/discourse_post_event/upcoming_events/index.html.erb b/app/views/discourse_post_event/upcoming_events/index.html.erb deleted file mode 100644 index e69de29bb..000000000 diff --git a/assets/javascripts/discourse/templates/components/admin-holidays-list-item.hbs b/assets/javascripts/discourse/components/admin-holidays-list-item.hbs similarity index 100% rename from assets/javascripts/discourse/templates/components/admin-holidays-list-item.hbs rename to assets/javascripts/discourse/components/admin-holidays-list-item.hbs diff --git a/assets/javascripts/discourse/templates/components/admin-holidays-list.hbs b/assets/javascripts/discourse/components/admin-holidays-list.hbs similarity index 90% rename from assets/javascripts/discourse/templates/components/admin-holidays-list.hbs rename to assets/javascripts/discourse/components/admin-holidays-list.hbs index b9c5f8ae2..c15f82066 100644 --- a/assets/javascripts/discourse/templates/components/admin-holidays-list.hbs +++ b/assets/javascripts/discourse/components/admin-holidays-list.hbs @@ -11,7 +11,7 @@ {{/each}} diff --git a/assets/javascripts/discourse/templates/components/bulk-invite-sample-csv-file.hbs b/assets/javascripts/discourse/components/bulk-invite-sample-csv-file.hbs similarity index 100% rename from assets/javascripts/discourse/templates/components/bulk-invite-sample-csv-file.hbs rename to assets/javascripts/discourse/components/bulk-invite-sample-csv-file.hbs diff --git a/assets/javascripts/discourse/templates/components/csv-uploader.hbs b/assets/javascripts/discourse/components/csv-uploader.hbs similarity index 100% rename from assets/javascripts/discourse/templates/components/csv-uploader.hbs rename to assets/javascripts/discourse/components/csv-uploader.hbs diff --git a/assets/javascripts/discourse/templates/components/event-field.hbs b/assets/javascripts/discourse/components/event-field.hbs similarity index 100% rename from assets/javascripts/discourse/templates/components/event-field.hbs rename to assets/javascripts/discourse/components/event-field.hbs diff --git a/assets/javascripts/discourse/components/region-input.js b/assets/javascripts/discourse/components/region-input.js index 652d2949a..0fcf29198 100644 --- a/assets/javascripts/discourse/components/region-input.js +++ b/assets/javascripts/discourse/components/region-input.js @@ -1,5 +1,5 @@ import { computed } from "@ember/object"; -import { HOLIDAY_REGIONS } from "discourse/plugins/discourse-calendar/lib/regions"; +import { HOLIDAY_REGIONS } from "../lib/regions"; import I18n from "I18n"; import ComboBoxComponent from "select-kit/components/combo-box"; diff --git a/assets/javascripts/discourse/templates/components/toggle-invitees-modal.hbs b/assets/javascripts/discourse/components/toggle-invitees-modal.hbs similarity index 100% rename from assets/javascripts/discourse/templates/components/toggle-invitees-modal.hbs rename to assets/javascripts/discourse/components/toggle-invitees-modal.hbs diff --git a/assets/javascripts/discourse/templates/components/upcoming-events-calendar.hbs b/assets/javascripts/discourse/components/upcoming-events-calendar.hbs similarity index 100% rename from assets/javascripts/discourse/templates/components/upcoming-events-calendar.hbs rename to assets/javascripts/discourse/components/upcoming-events-calendar.hbs diff --git a/assets/javascripts/discourse/components/upcoming-events-calendar.js b/assets/javascripts/discourse/components/upcoming-events-calendar.js index b137ec1d8..25bfabd4c 100644 --- a/assets/javascripts/discourse/components/upcoming-events-calendar.js +++ b/assets/javascripts/discourse/components/upcoming-events-calendar.js @@ -1,6 +1,6 @@ import { Promise } from "rsvp"; -import { isNotFullDayEvent } from "discourse/plugins/discourse-calendar/lib/guess-best-date-format"; -import { formatEventName } from "discourse/plugins/discourse-calendar/helpers/format-event-name"; +import { isNotFullDayEvent } from "../lib/guess-best-date-format"; +import { formatEventName } from "../helpers/format-event-name"; import loadScript from "discourse/lib/load-script"; import Component from "@ember/component"; import { schedule } from "@ember/runloop"; diff --git a/assets/javascripts/connectors/after-chat-channel-username/on-holiday-indicator.hbs b/assets/javascripts/discourse/connectors/after-chat-channel-username/on-holiday-indicator.hbs similarity index 100% rename from assets/javascripts/connectors/after-chat-channel-username/on-holiday-indicator.hbs rename to assets/javascripts/discourse/connectors/after-chat-channel-username/on-holiday-indicator.hbs diff --git a/assets/javascripts/templates/connectors/after-user-name/holiday-flair.hbs b/assets/javascripts/discourse/connectors/after-user-name/holiday-flair.hbs similarity index 100% rename from assets/javascripts/templates/connectors/after-user-name/holiday-flair.hbs rename to assets/javascripts/discourse/connectors/after-user-name/holiday-flair.hbs diff --git a/assets/javascripts/connectors/after-user-name/holiday-flair.js b/assets/javascripts/discourse/connectors/after-user-name/holiday-flair.js similarity index 100% rename from assets/javascripts/connectors/after-user-name/holiday-flair.js rename to assets/javascripts/discourse/connectors/after-user-name/holiday-flair.js diff --git a/assets/javascripts/templates/connectors/before-topic-list-body/category-calendar.hbs b/assets/javascripts/discourse/connectors/before-topic-list-body/category-calendar.hbs similarity index 100% rename from assets/javascripts/templates/connectors/before-topic-list-body/category-calendar.hbs rename to assets/javascripts/discourse/connectors/before-topic-list-body/category-calendar.hbs diff --git a/assets/javascripts/connectors/before-topic-list-body/category-calendar.js b/assets/javascripts/discourse/connectors/before-topic-list-body/category-calendar.js similarity index 100% rename from assets/javascripts/connectors/before-topic-list-body/category-calendar.js rename to assets/javascripts/discourse/connectors/before-topic-list-body/category-calendar.js diff --git a/assets/javascripts/templates/connectors/discovery-list-container-top/category-calendar.hbs b/assets/javascripts/discourse/connectors/discovery-list-container-top/category-calendar.hbs similarity index 100% rename from assets/javascripts/templates/connectors/discovery-list-container-top/category-calendar.hbs rename to assets/javascripts/discourse/connectors/discovery-list-container-top/category-calendar.hbs diff --git a/assets/javascripts/connectors/discovery-list-container-top/category-calendar.js b/assets/javascripts/discourse/connectors/discovery-list-container-top/category-calendar.js similarity index 100% rename from assets/javascripts/connectors/discovery-list-container-top/category-calendar.js rename to assets/javascripts/discourse/connectors/discovery-list-container-top/category-calendar.js diff --git a/assets/javascripts/templates/connectors/discovery-list-container-top/category-events.hbs b/assets/javascripts/discourse/connectors/discovery-list-container-top/category-events.hbs similarity index 100% rename from assets/javascripts/templates/connectors/discovery-list-container-top/category-events.hbs rename to assets/javascripts/discourse/connectors/discovery-list-container-top/category-events.hbs diff --git a/assets/javascripts/templates/connectors/user-custom-preferences/region.hbs b/assets/javascripts/discourse/connectors/user-custom-preferences/region.hbs similarity index 100% rename from assets/javascripts/templates/connectors/user-custom-preferences/region.hbs rename to assets/javascripts/discourse/connectors/user-custom-preferences/region.hbs diff --git a/assets/javascripts/connectors/user-custom-preferences/region.js b/assets/javascripts/discourse/connectors/user-custom-preferences/region.js similarity index 85% rename from assets/javascripts/connectors/user-custom-preferences/region.js rename to assets/javascripts/discourse/connectors/user-custom-preferences/region.js index 58eb26fc4..962ef7bc2 100644 --- a/assets/javascripts/connectors/user-custom-preferences/region.js +++ b/assets/javascripts/discourse/connectors/user-custom-preferences/region.js @@ -1,5 +1,5 @@ import { action } from "@ember/object"; -import { TIME_ZONE_TO_REGION } from "discourse/plugins/discourse-calendar/lib/regions"; +import { TIME_ZONE_TO_REGION } from "../../lib/regions"; export default { setupComponent(args, component) { diff --git a/assets/javascripts/discourse/controllers/discourse-post-event-builder.js b/assets/javascripts/discourse/controllers/discourse-post-event-builder.js index a87242566..9235a4ac3 100644 --- a/assets/javascripts/discourse/controllers/discourse-post-event-builder.js +++ b/assets/javascripts/discourse/controllers/discourse-post-event-builder.js @@ -7,7 +7,7 @@ import { action, computed, set } from "@ember/object"; import { equal, gte } from "@ember/object/computed"; import { extractError } from "discourse/lib/ajax-error"; import { inject as service } from "@ember/service"; -import { buildParams, replaceRaw } from "../../lib/raw-event-helper"; +import { buildParams, replaceRaw } from "../lib/raw-event-helper"; const DEFAULT_REMINDER = { type: "notification", diff --git a/assets/javascripts/helpers/format-event-name.js b/assets/javascripts/discourse/helpers/format-event-name.js similarity index 100% rename from assets/javascripts/helpers/format-event-name.js rename to assets/javascripts/discourse/helpers/format-event-name.js diff --git a/assets/javascripts/helpers/format-future-date.js b/assets/javascripts/discourse/helpers/format-future-date.js similarity index 69% rename from assets/javascripts/helpers/format-future-date.js rename to assets/javascripts/discourse/helpers/format-future-date.js index 602b3e2ea..9284db85c 100644 --- a/assets/javascripts/helpers/format-future-date.js +++ b/assets/javascripts/discourse/helpers/format-future-date.js @@ -1,4 +1,4 @@ -import guessDateFormat from "discourse/plugins/discourse-calendar/lib/guess-best-date-format"; +import guessDateFormat from "../lib/guess-best-date-format"; import { htmlHelper } from "discourse-common/lib/helpers"; export default htmlHelper((date) => { diff --git a/assets/javascripts/helpers/render-invitee.js b/assets/javascripts/discourse/helpers/render-invitee.js similarity index 100% rename from assets/javascripts/helpers/render-invitee.js rename to assets/javascripts/discourse/helpers/render-invitee.js diff --git a/assets/javascripts/initializers/add-event-ui-builder.js b/assets/javascripts/discourse/initializers/add-event-ui-builder.js similarity index 100% rename from assets/javascripts/initializers/add-event-ui-builder.js rename to assets/javascripts/discourse/initializers/add-event-ui-builder.js diff --git a/assets/javascripts/initializers/add-hamburger-menu-action.js b/assets/javascripts/discourse/initializers/add-hamburger-menu-action.js similarity index 100% rename from assets/javascripts/initializers/add-hamburger-menu-action.js rename to assets/javascripts/discourse/initializers/add-hamburger-menu-action.js diff --git a/assets/javascripts/initializers/decorate-topic-title.js b/assets/javascripts/discourse/initializers/decorate-topic-title.js similarity index 88% rename from assets/javascripts/initializers/decorate-topic-title.js rename to assets/javascripts/discourse/initializers/decorate-topic-title.js index 953460cf6..1dee7aebf 100644 --- a/assets/javascripts/initializers/decorate-topic-title.js +++ b/assets/javascripts/discourse/initializers/decorate-topic-title.js @@ -1,6 +1,6 @@ import { withPluginApi } from "discourse/lib/plugin-api"; -import eventRelativeDate from "discourse/plugins/discourse-calendar/lib/event-relative-date"; -import eventLocalDate from "discourse/plugins/discourse-calendar/lib/event-local-date"; +import eventRelativeDate from "../lib/event-relative-date"; +import eventLocalDate from "../lib/event-local-date"; function initializeDecorateTopicTitle(api) { api.decorateTopicTitle((topic, node, topicTitleType) => { diff --git a/assets/javascripts/initializers/disable-sort.js b/assets/javascripts/discourse/initializers/disable-sort.js similarity index 100% rename from assets/javascripts/initializers/disable-sort.js rename to assets/javascripts/discourse/initializers/disable-sort.js diff --git a/assets/javascripts/initializers/discourse-calendar.js b/assets/javascripts/discourse/initializers/discourse-calendar.js similarity index 98% rename from assets/javascripts/initializers/discourse-calendar.js rename to assets/javascripts/discourse/initializers/discourse-calendar.js index d6c8c36ed..63546a54d 100644 --- a/assets/javascripts/initializers/discourse-calendar.js +++ b/assets/javascripts/discourse/initializers/discourse-calendar.js @@ -8,14 +8,10 @@ import { withPluginApi } from "discourse/lib/plugin-api"; import { ajax } from "discourse/lib/ajax"; import Category from "discourse/models/category"; import I18n from "I18n"; -import { - colorToHex, - contrastColor, - stringToColor, -} from "discourse/plugins/discourse-calendar/lib/colors"; +import { colorToHex, contrastColor, stringToColor } from "../lib/colors"; import { createPopper } from "@popperjs/core"; -import { isNotFullDayEvent } from "discourse/plugins/discourse-calendar/lib/guess-best-date-format"; -import { formatEventName } from "discourse/plugins/discourse-calendar/helpers/format-event-name"; +import { isNotFullDayEvent } from "../lib/guess-best-date-format"; +import { formatEventName } from "../helpers/format-event-name"; import getURL from "discourse-common/lib/get-url"; function loadFullCalendar() { diff --git a/assets/javascripts/initializers/discourse-group-timezones.js b/assets/javascripts/discourse/initializers/discourse-group-timezones.js similarity index 100% rename from assets/javascripts/initializers/discourse-group-timezones.js rename to assets/javascripts/discourse/initializers/discourse-group-timezones.js diff --git a/assets/javascripts/initializers/discourse-post-event-decorator.js b/assets/javascripts/discourse/initializers/discourse-post-event-decorator.js similarity index 98% rename from assets/javascripts/initializers/discourse-post-event-decorator.js rename to assets/javascripts/discourse/initializers/discourse-post-event-decorator.js index 410ebb715..1211584d8 100644 --- a/assets/javascripts/initializers/discourse-post-event-decorator.js +++ b/assets/javascripts/discourse/initializers/discourse-post-event-decorator.js @@ -1,5 +1,5 @@ import I18n from "I18n"; -import guessDateFormat from "discourse/plugins/discourse-calendar/lib/guess-best-date-format"; +import guessDateFormat from "../lib/guess-best-date-format"; import { cookAsync } from "discourse/lib/text"; import WidgetGlue from "discourse/widgets/glue"; import { getRegister } from "discourse-common/lib/get-owner"; diff --git a/assets/javascripts/initializers/event-relative-date.js b/assets/javascripts/discourse/initializers/event-relative-date.js similarity index 89% rename from assets/javascripts/initializers/event-relative-date.js rename to assets/javascripts/discourse/initializers/event-relative-date.js index 7097fb169..a3f00bb0d 100644 --- a/assets/javascripts/initializers/event-relative-date.js +++ b/assets/javascripts/discourse/initializers/event-relative-date.js @@ -1,6 +1,6 @@ import { isTesting } from "discourse-common/config/environment"; import { cancel } from "@ember/runloop"; -import eventRelativeDate from "discourse/plugins/discourse-calendar/lib/event-relative-date"; +import eventRelativeDate from "../lib/event-relative-date"; import discourseLater from "discourse-common/lib/later"; function computeRelativeEventDates() { diff --git a/assets/javascripts/lib/clean-title.js b/assets/javascripts/discourse/lib/clean-title.js similarity index 100% rename from assets/javascripts/lib/clean-title.js rename to assets/javascripts/discourse/lib/clean-title.js diff --git a/assets/javascripts/lib/colors.js b/assets/javascripts/discourse/lib/colors.js similarity index 100% rename from assets/javascripts/lib/colors.js rename to assets/javascripts/discourse/lib/colors.js diff --git a/assets/javascripts/lib/discourse-markdown/discourse-calendar.js b/assets/javascripts/discourse/lib/discourse-markdown/discourse-calendar.js similarity index 100% rename from assets/javascripts/lib/discourse-markdown/discourse-calendar.js rename to assets/javascripts/discourse/lib/discourse-markdown/discourse-calendar.js diff --git a/assets/javascripts/lib/discourse-markdown/discourse-post-event-block.js b/assets/javascripts/discourse/lib/discourse-markdown/discourse-post-event-block.js similarity index 100% rename from assets/javascripts/lib/discourse-markdown/discourse-post-event-block.js rename to assets/javascripts/discourse/lib/discourse-markdown/discourse-post-event-block.js diff --git a/assets/javascripts/lib/event-local-date.js b/assets/javascripts/discourse/lib/event-local-date.js similarity index 86% rename from assets/javascripts/lib/event-local-date.js rename to assets/javascripts/discourse/lib/event-local-date.js index aaf261729..d76b8578d 100644 --- a/assets/javascripts/lib/event-local-date.js +++ b/assets/javascripts/discourse/lib/event-local-date.js @@ -1,4 +1,4 @@ -import guessDateFormat from "discourse/plugins/discourse-calendar/lib/guess-best-date-format"; +import guessDateFormat from "./guess-best-date-format"; export default function eventLocalDate(container) { container.classList.remove("past", "current", "future"); diff --git a/assets/javascripts/lib/event-relative-date.js b/assets/javascripts/discourse/lib/event-relative-date.js similarity index 94% rename from assets/javascripts/lib/event-relative-date.js rename to assets/javascripts/discourse/lib/event-relative-date.js index 0c437c8ff..18883e64b 100644 --- a/assets/javascripts/lib/event-relative-date.js +++ b/assets/javascripts/discourse/lib/event-relative-date.js @@ -1,5 +1,5 @@ import I18n from "I18n"; -import guessDateFormat from "discourse/plugins/discourse-calendar/lib/guess-best-date-format"; +import guessDateFormat from "./guess-best-date-format"; function _computeCurrentEvent(container, endsAt) { const indicator = document.createElement("div"); diff --git a/assets/javascripts/lib/guess-best-date-format.js b/assets/javascripts/discourse/lib/guess-best-date-format.js similarity index 100% rename from assets/javascripts/lib/guess-best-date-format.js rename to assets/javascripts/discourse/lib/guess-best-date-format.js diff --git a/assets/javascripts/lib/raw-event-helper.js b/assets/javascripts/discourse/lib/raw-event-helper.js similarity index 100% rename from assets/javascripts/lib/raw-event-helper.js rename to assets/javascripts/discourse/lib/raw-event-helper.js diff --git a/assets/javascripts/lib/regions.js b/assets/javascripts/discourse/lib/regions.js similarity index 100% rename from assets/javascripts/lib/regions.js rename to assets/javascripts/discourse/lib/regions.js diff --git a/assets/javascripts/lib/round-time.js b/assets/javascripts/discourse/lib/round-time.js similarity index 100% rename from assets/javascripts/lib/round-time.js rename to assets/javascripts/discourse/lib/round-time.js diff --git a/assets/javascripts/discourse/widgets/discourse-group-timezones-time-traveler.js b/assets/javascripts/discourse/widgets/discourse-group-timezones-time-traveler.js index ffdf56fc3..b25cc4a47 100644 --- a/assets/javascripts/discourse/widgets/discourse-group-timezones-time-traveler.js +++ b/assets/javascripts/discourse/widgets/discourse-group-timezones-time-traveler.js @@ -1,6 +1,6 @@ import hbs from "discourse/widgets/hbs-compiler"; import { createWidget } from "discourse/widgets/widget"; -import roundTime from "discourse/plugins/discourse-calendar/lib/round-time"; +import roundTime from "../lib/round-time"; export default createWidget("discourse-group-timezones-time-traveler", { tagName: "div.group-timezones-time-traveler", diff --git a/assets/javascripts/discourse/widgets/discourse-group-timezones.js b/assets/javascripts/discourse/widgets/discourse-group-timezones.js index b051689e7..49f7ae231 100644 --- a/assets/javascripts/discourse/widgets/discourse-group-timezones.js +++ b/assets/javascripts/discourse/widgets/discourse-group-timezones.js @@ -1,6 +1,6 @@ import hbs from "discourse/widgets/hbs-compiler"; import { createWidget } from "discourse/widgets/widget"; -import roundTime from "discourse/plugins/discourse-calendar/lib/round-time"; +import roundTime from "../lib/round-time"; export default createWidget("discourse-group-timezones", { tagName: "div.group-timezones", diff --git a/assets/javascripts/discourse/widgets/discourse-post-event.js b/assets/javascripts/discourse/widgets/discourse-post-event.js index 9f9330e9f..004089eb2 100644 --- a/assets/javascripts/discourse/widgets/discourse-post-event.js +++ b/assets/javascripts/discourse/widgets/discourse-post-event.js @@ -1,14 +1,14 @@ import I18n from "I18n"; import TextLib, { emojiUnescape } from "discourse/lib/text"; import { exportEntity } from "discourse/lib/export-csv"; -import cleanTitle from "discourse/plugins/discourse-calendar/lib/clean-title"; +import cleanTitle from "../lib/clean-title"; import { dasherize } from "@ember/string"; import EmberObject from "@ember/object"; import showModal from "discourse/lib/show-modal"; import hbs from "discourse/widgets/hbs-compiler"; import { createWidget } from "discourse/widgets/widget"; import { routeAction } from "discourse/helpers/route-action"; -import { buildParams, replaceRaw } from "../../lib/raw-event-helper"; +import { buildParams, replaceRaw } from "../lib/raw-event-helper"; import { escapeExpression } from "discourse/lib/utilities"; export default createWidget("discourse-post-event", { diff --git a/assets/stylesheets/common/discourse-calendar.scss b/assets/stylesheets/common/discourse-calendar.scss index a3c8b17ae..86f4d2a65 100644 --- a/assets/stylesheets/common/discourse-calendar.scss +++ b/assets/stylesheets/common/discourse-calendar.scss @@ -150,7 +150,7 @@ } .fc-list-item-add-to-calendar { color: var(--tertiary); - font-size: $font-down-1; + font-size: var(--font-down-1); } } @@ -307,7 +307,7 @@ a.holiday { align-items: center; justify-content: space-between; color: inherit; - font-size: $font-down-1; + font-size: var(--font-down-1); .before { margin-right: auto; @@ -358,7 +358,7 @@ a.holiday { } .offset { - font-size: $font-down-2; + font-size: var(--font-down-2); margin-left: 0.5em; } } diff --git a/assets/stylesheets/common/discourse-post-event-builder.scss b/assets/stylesheets/common/discourse-post-event-builder.scss index 240873f53..cb8b8e629 100644 --- a/assets/stylesheets/common/discourse-post-event-builder.scss +++ b/assets/stylesheets/common/discourse-post-event-builder.scss @@ -13,7 +13,7 @@ } .name { - font-size: $font-down-1; + font-size: var(--font-down-1); } &.from { @@ -69,7 +69,7 @@ border: 0; .name { - font-size: $font-down-1; + font-size: var(--font-down-1); } } } diff --git a/assets/stylesheets/common/discourse-post-event-core-ext.scss b/assets/stylesheets/common/discourse-post-event-core-ext.scss index 409d01997..a43ce8fe8 100644 --- a/assets/stylesheets/common/discourse-post-event-core-ext.scss +++ b/assets/stylesheets/common/discourse-post-event-core-ext.scss @@ -8,7 +8,7 @@ .event-date { display: inline-flex; align-items: center; - font-size: $font-down-2; + font-size: var(--font-down-2); border: 1px solid var(--primary-medium); background: none; padding: 0 0.25em; @@ -30,7 +30,7 @@ .header-title { .event-date { - font-size: $font-down-4; + font-size: var(--font-down-4); color: var(--primary-medium); font-weight: normal; padding: 0.25em; diff --git a/assets/stylesheets/common/discourse-post-event.scss b/assets/stylesheets/common/discourse-post-event.scss index 18060e2ed..893aabbcd 100644 --- a/assets/stylesheets/common/discourse-post-event.scss +++ b/assets/stylesheets/common/discourse-post-event.scss @@ -85,14 +85,14 @@ $interested: #fb985d; .month { text-align: center; color: red; - font-size: $font-down-1; + font-size: var(--font-down-1); text-transform: uppercase; } .day { text-align: center; font-weight: 500; - font-size: $font-up-2; + font-size: var(--font-up-2); } } @@ -111,7 +111,7 @@ $interested: #fb985d; display: flex; align-items: center; color: var(--primary-medium); - font-size: $font-down-1; + font-size: var(--font-down-1); margin: 0.25em 0; .separator { @@ -253,7 +253,7 @@ $interested: #fb985d; border: 1px solid var(--primary-low); .d-icon { - font-size: $font-down-3; + font-size: var(--font-down-3); } } } diff --git a/assets/stylesheets/common/upcoming-events-calendar.scss b/assets/stylesheets/common/upcoming-events-calendar.scss index 499727217..360640f5b 100644 --- a/assets/stylesheets/common/upcoming-events-calendar.scss +++ b/assets/stylesheets/common/upcoming-events-calendar.scss @@ -124,6 +124,6 @@ } .fc-list-item-add-to-calendar { color: var(--tertiary); - font-size: $font-down-1; + font-size: var(--font-down-1); } } diff --git a/assets/stylesheets/mobile/discourse-calendar.scss b/assets/stylesheets/mobile/discourse-calendar.scss index 49d2dd1c5..e43c0429d 100644 --- a/assets/stylesheets/mobile/discourse-calendar.scss +++ b/assets/stylesheets/mobile/discourse-calendar.scss @@ -6,7 +6,7 @@ background: none; h2.discourse-calendar-title { - font-size: $font-0; + font-size: var(--font-0); flex-wrap: nowrap; max-width: 75%; white-space: nowrap; @@ -24,7 +24,7 @@ text-align: center; padding: 0.25em; span { - font-size: $font-down-1; + font-size: var(--font-down-1); text-align: center; padding: 0; } diff --git a/assets/stylesheets/mobile/discourse-post-event.scss b/assets/stylesheets/mobile/discourse-post-event.scss index 35335b1fa..4626cd618 100644 --- a/assets/stylesheets/mobile/discourse-post-event.scss +++ b/assets/stylesheets/mobile/discourse-post-event.scss @@ -24,7 +24,7 @@ } .event-invitees-status { - font-size: $font-down-1; + font-size: var(--font-down-1); } .event-invitees .event-invitees-avatars .topic-invitee-avatar .avatar-flair { diff --git a/config/routes.rb b/config/routes.rb index cb3082b28..353ca3fd7 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,20 +1,5 @@ # frozen_string_literal: true -Discourse::Application.routes.draw do - mount ::DiscourseCalendar::Engine, at: "/" - - get "/admin/plugins/calendar" => "admin/plugins#index", :constraints => StaffConstraint.new - get "/admin/discourse-calendar/holiday-regions/:region_code/holidays" => - "admin/discourse_calendar/admin_holidays#index", - :constraints => StaffConstraint.new - post "/admin/discourse-calendar/holidays/disable" => - "admin/discourse_calendar/admin_holidays#disable", - :constraints => StaffConstraint.new - delete "/admin/discourse-calendar/holidays/enable" => - "admin/discourse_calendar/admin_holidays#enable", - :constraints => StaffConstraint.new -end - DiscoursePostEvent::Engine.routes.draw do get "/discourse-post-event/events" => "events#index", :format => :json get "/discourse-post-event/events/:id" => "events#show" @@ -30,4 +15,17 @@ get "/upcoming-events" => "upcoming_events#index" end -Discourse::Application.routes.draw { mount ::DiscoursePostEvent::Engine, at: "/" } +Discourse::Application.routes.draw do + mount ::DiscourseCalendar::Engine, at: "/" + mount ::DiscoursePostEvent::Engine, at: "/" + + scope constraints: StaffConstraint.new do + get "/admin/plugins/calendar" => "admin/plugins#index" + get "/admin/discourse-calendar/holiday-regions/:region_code/holidays" => + "admin/discourse_calendar/admin_holidays#index" + post "/admin/discourse-calendar/holidays/disable" => + "admin/discourse_calendar/admin_holidays#disable" + delete "/admin/discourse-calendar/holidays/enable" => + "admin/discourse_calendar/admin_holidays#enable" + end +end diff --git a/config/settings.yml b/config/settings.yml index c0e6e955a..ab2c98f22 100644 --- a/config/settings.yml +++ b/config/settings.yml @@ -89,4 +89,3 @@ discourse_post_event: disable_resorting_on_categories_enabled: default: false client: true - diff --git a/lib/calendar_settings_validator.rb b/lib/calendar_settings_validator.rb index 1ea51f4f5..ebb432004 100644 --- a/lib/calendar_settings_validator.rb +++ b/lib/calendar_settings_validator.rb @@ -13,11 +13,11 @@ def valid_value?(val) hour = split.first return false if hour.length != 2 - return false unless hour.to_i >= 0 && hour.to_i < 24 + return false if hour.to_i < 0 || hour.to_i >= 24 minutes = split.second return false if minutes.length != 2 - return false unless minutes.to_i >= 0 && minutes.to_i < 60 + return false if minutes.to_i < 0 || minutes.to_i >= 60 true end diff --git a/package.json b/package.json index d8bd4a759..320f381dd 100644 --- a/package.json +++ b/package.json @@ -1,10 +1,10 @@ { "name": "discourse-calendar", - "version": "1.0.0", - "repository": "git@github.com:discourse/discourse-calendar.git", + "version": "0.3.0", + "repository": "https://github.com/discourse/discourse-calendar", "author": "Discourse", "license": "MIT", "devDependencies": { - "eslint-config-discourse": "^3.4.0" + "eslint-config-discourse": "^3.5.0" } } diff --git a/plugin.rb b/plugin.rb index 5078aece2..31f7d1e27 100644 --- a/plugin.rb +++ b/plugin.rb @@ -5,7 +5,6 @@ # version: 0.3 # author: Daniel Waterworth, Joffrey Jaffeux # url: https://github.com/discourse/discourse-calendar -# transpile_js: true libdir = File.join(File.dirname(__FILE__), "vendor/holidays/lib") $LOAD_PATH.unshift(libdir) unless $LOAD_PATH.include?(libdir) diff --git a/spec/integration/post_spec.rb b/spec/integration/post_spec.rb index 569bfd9e7..7c81c5b36 100644 --- a/spec/integration/post_spec.rb +++ b/spec/integration/post_spec.rb @@ -4,9 +4,6 @@ require "securerandom" describe Post do - Event ||= DiscoursePostEvent::Event - Invitee ||= DiscoursePostEvent::Invitee - before do freeze_time Jobs.run_immediately! @@ -58,8 +55,12 @@ end it "sends a post revision to going invitees" do - Invitee.create_attendance!(going_user.id, post_1.id, :going) - Invitee.create_attendance!(interested_user.id, post_1.id, :interested) + DiscoursePostEvent::Invitee.create_attendance!(going_user.id, post_1.id, :going) + DiscoursePostEvent::Invitee.create_attendance!( + interested_user.id, + post_1.id, + :interested, + ) expect { revisor = PostRevisor.new(post_1) @@ -78,8 +79,12 @@ before { event_1.event_dates.first.update_columns(starts_at: 5.hours.ago) } it "doesn’t send a post revision to anyone" do - Invitee.create_attendance!(going_user.id, post_1.id, :going) - Invitee.create_attendance!(interested_user.id, event_1.id, :interested) + DiscoursePostEvent::Invitee.create_attendance!(going_user.id, post_1.id, :going) + DiscoursePostEvent::Invitee.create_attendance!( + interested_user.id, + event_1.id, + :interested, + ) expect { revisor = PostRevisor.new(event_1.post) @@ -104,8 +109,12 @@ original_ends_at: nil, ) - Invitee.create_attendance!(going_user.id, event_1.id, :going) - Invitee.create_attendance!(interested_user.id, event_1.id, :interested) + DiscoursePostEvent::Invitee.create_attendance!(going_user.id, event_1.id, :going) + DiscoursePostEvent::Invitee.create_attendance!( + interested_user.id, + event_1.id, + :interested, + ) event_1.reload @@ -124,7 +133,10 @@ it "it removes status from every invitees" do expect(event_1.invitees.pluck(:status)).to match_array( - [Invitee.statuses[:going], Invitee.statuses[:interested]], + [ + DiscoursePostEvent::Invitee.statuses[:going], + DiscoursePostEvent::Invitee.statuses[:interested], + ], ) event_1.update_with_params!(original_ends_at: Time.now) @@ -158,12 +170,12 @@ context "when updating status to private" do it "it changes the status and force invitees" do expect(event_1.raw_invitees).to eq(["trust_level_0"]) - expect(event_1.status).to eq(Event.statuses[:public]) + expect(event_1.status).to eq(DiscoursePostEvent::Event.statuses[:public]) - event_1.update_with_params!(status: Event.statuses[:private]) + event_1.update_with_params!(status: DiscoursePostEvent::Event.statuses[:private]) expect(event_1.raw_invitees).to eq([]) - expect(event_1.status).to eq(Event.statuses[:private]) + expect(event_1.status).to eq(DiscoursePostEvent::Event.statuses[:private]) end end end @@ -452,7 +464,7 @@ Fabricate( :event, post: post_1, - status: Event.statuses[:private], + status: DiscoursePostEvent::Event.statuses[:private], raw_invitees: [group_1.name], original_starts_at: 3.hours.ago, original_ends_at: nil, @@ -464,7 +476,7 @@ Fabricate( :event, post: post_1, - status: Event.statuses[:private], + status: DiscoursePostEvent::Event.statuses[:private], raw_invitees: [group_1.name], recurrence: "FREQ=WEEKLY;BYDAY=MO", original_starts_at: 2.hours.from_now, @@ -506,12 +518,12 @@ context "when updating status to public" do it "it changes the status and force invitees" do expect(event_1.raw_invitees).to eq([group_1.name]) - expect(event_1.status).to eq(Event.statuses[:private]) + expect(event_1.status).to eq(DiscoursePostEvent::Event.statuses[:private]) - event_1.update_with_params!(status: Event.statuses[:public]) + event_1.update_with_params!(status: DiscoursePostEvent::Event.statuses[:public]) expect(event_1.raw_invitees).to eq(["trust_level_0"]) - expect(event_1.status).to eq(Event.statuses[:public]) + expect(event_1.status).to eq(DiscoursePostEvent::Event.statuses[:public]) end end diff --git a/spec/jobs/regular/discourse_post_event/bulk_invite_spec.rb b/spec/jobs/regular/discourse_post_event/bulk_invite_spec.rb index a3bb162e4..fa39ed9a7 100644 --- a/spec/jobs/regular/discourse_post_event/bulk_invite_spec.rb +++ b/spec/jobs/regular/discourse_post_event/bulk_invite_spec.rb @@ -19,16 +19,19 @@ context "with invalid params" do context "with no invitees given" do it "raises an invalid parameters errors" do - expect { subject.execute(current_user_id: 1, event_id: 1) }.to raise_error( - Discourse::InvalidParameters, - ) + expect { + Jobs::DiscoursePostEventBulkInvite.new.execute(current_user_id: 1, event_id: 1) + }.to raise_error(Discourse::InvalidParameters) end end context "with no current_user_id given" do it "raises an invalid parameters errors" do expect { - subject.execute(invitees: [{ identifier: "bob", attendance: "going" }], event_id: 1) + Jobs::DiscoursePostEventBulkInvite.new.execute( + invitees: [{ identifier: "bob", attendance: "going" }], + event_id: 1, + ) }.to raise_error(Discourse::InvalidParameters) end end @@ -36,7 +39,7 @@ context "with no event_id given" do it "raises an invalid parameters errors" do expect { - subject.execute( + Jobs::DiscoursePostEventBulkInvite.new.execute( invitees: [{ identifier: "bob", attendance: "going" }], current_user_id: 1, ) @@ -51,7 +54,7 @@ it "raises an error" do expect { - subject.execute( + Jobs::DiscoursePostEventBulkInvite.new.execute( event_id: post_event_1.id, invitees: [{ identifier: "bob", attendance: "going" }], current_user_id: lurker.id, @@ -101,7 +104,7 @@ ) .once - subject.execute(valid_params) + Jobs::DiscoursePostEventBulkInvite.new.execute(valid_params) invitee_klass = DiscoursePostEvent::Invitee @@ -117,7 +120,7 @@ end it "removes the invitee if set to unknown" do - subject.execute(valid_params) + Jobs::DiscoursePostEventBulkInvite.new.execute(valid_params) invitee_klass = DiscoursePostEvent::Invitee @@ -129,7 +132,7 @@ invitee_klass.statuses[:not_going], ) - subject.execute( + Jobs::DiscoursePostEventBulkInvite.new.execute( event_id: post_event_1.id, invitees: [{ "identifier" => group_1.name, "attendance" => "unknown" }], current_user_id: user_1.id, @@ -149,7 +152,7 @@ invitee_klass = DiscoursePostEvent::Invitee - subject.execute( + Jobs::DiscoursePostEventBulkInvite.new.execute( event_id: post_event_1.id, invitees: [{ "identifier" => group_1.name }], current_user_id: user_1.id, @@ -183,7 +186,7 @@ ) .once - subject.execute(valid_params) + Jobs::DiscoursePostEventBulkInvite.new.execute(valid_params) invitee_klass = DiscoursePostEvent::Invitee diff --git a/spec/jobs/regular/discourse_post_event/bump_topic_spec.rb b/spec/jobs/regular/discourse_post_event/bump_topic_spec.rb index 175bf9d74..36b442364 100644 --- a/spec/jobs/regular/discourse_post_event/bump_topic_spec.rb +++ b/spec/jobs/regular/discourse_post_event/bump_topic_spec.rb @@ -19,7 +19,7 @@ context "when params are present" do it "creates an auto-bump topic timer" do freeze_time - subject.execute(topic_id: topic_1.id, date: "2019-12-10 5:00") + Jobs::DiscoursePostEventBumpTopic.new.execute(topic_id: topic_1.id, date: "2019-12-10 5:00") timer = TopicTimer.find_by(topic: topic_1) expect(timer.status_type).to eq(TopicTimer.types[:bump]) @@ -29,10 +29,12 @@ context "when the topic_id param is missing" do it "does not throw an error if the date param is present" do - expect { subject.execute(date: "2019-12-10 5:00") }.not_to raise_error + expect { + Jobs::DiscoursePostEventBumpTopic.new.execute(date: "2019-12-10 5:00") + }.not_to raise_error end it "does not throw an error if the date param is missing" do - expect { subject.execute({}) }.not_to raise_error + expect { Jobs::DiscoursePostEventBumpTopic.new.execute({}) }.not_to raise_error end end end diff --git a/spec/jobs/regular/discourse_post_event/send_reminder_spec.rb b/spec/jobs/regular/discourse_post_event/send_reminder_spec.rb index 7a31f2d5c..251fbdf6a 100644 --- a/spec/jobs/regular/discourse_post_event/send_reminder_spec.rb +++ b/spec/jobs/regular/discourse_post_event/send_reminder_spec.rb @@ -3,8 +3,6 @@ require "rails_helper" describe Jobs::DiscoursePostEventSendReminder do - Invitee ||= DiscoursePostEvent::Invitee - let(:admin_1) { Fabricate(:user, admin: true) } let(:going_user) { Fabricate(:user) } let(:interested_user) { Fabricate(:user) } @@ -16,12 +14,20 @@ let(:reminders) { "notification.5.minutes" } def init_invitees - Invitee.create_attendance!(going_user.id, event_1.id, :going) - Invitee.create_attendance!(interested_user.id, event_1.id, :interested) - Invitee.create_attendance!(not_going_user.id, event_1.id, :not_going) - Invitee.create_attendance!(going_user_unread_notification.id, event_1.id, :going) - Invitee.create_attendance!(going_user_read_notification.id, event_1.id, :going) - Invitee.create_attendance!(visited_going_user.id, event_1.id, :going) + DiscoursePostEvent::Invitee.create_attendance!(going_user.id, event_1.id, :going) + DiscoursePostEvent::Invitee.create_attendance!(interested_user.id, event_1.id, :interested) + DiscoursePostEvent::Invitee.create_attendance!(not_going_user.id, event_1.id, :not_going) + DiscoursePostEvent::Invitee.create_attendance!( + going_user_unread_notification.id, + event_1.id, + :going, + ) + DiscoursePostEvent::Invitee.create_attendance!( + going_user_read_notification.id, + event_1.id, + :going, + ) + DiscoursePostEvent::Invitee.create_attendance!(visited_going_user.id, event_1.id, :going) [ going_user, @@ -52,9 +58,13 @@ def init_invitees describe "#execute" do context "with invalid params" do it "raises an invalid parameters errors" do - expect { subject.execute(event_id: 1) }.to raise_error(Discourse::InvalidParameters) + expect { Jobs::DiscoursePostEventSendReminder.new.execute(event_id: 1) }.to raise_error( + Discourse::InvalidParameters, + ) - expect { subject.execute(reminder: "foo") }.to raise_error(Discourse::InvalidParameters) + expect { Jobs::DiscoursePostEventSendReminder.new.execute(reminder: "foo") }.to raise_error( + Discourse::InvalidParameters, + ) end end @@ -66,7 +76,12 @@ def init_invitees it "is not erroring when post is already deleted" do post_1.delete - expect { subject.execute(event_id: event_1.id, reminder: reminders) }.not_to raise_error + expect { + Jobs::DiscoursePostEventSendReminder.new.execute( + event_id: event_1.id, + reminder: reminders, + ) + }.not_to raise_error end end @@ -87,32 +102,47 @@ def init_invitees it "creates a new notification for going user" do expect(going_user.unread_notifications).to eq(0) - expect { subject.execute(event_id: event_1.id, reminder: reminders) }.to change { - going_user.reload.unread_notifications - }.by(1) + expect { + Jobs::DiscoursePostEventSendReminder.new.execute( + event_id: event_1.id, + reminder: reminders, + ) + }.to change { going_user.reload.unread_notifications }.by(1) end it "doesn’t create a new notification for not going user" do expect(not_going_user.unread_notifications).to eq(0) - expect { subject.execute(event_id: event_1.id, reminder: reminders) }.not_to change { - not_going_user.reload.unread_notifications - } + expect { + Jobs::DiscoursePostEventSendReminder.new.execute( + event_id: event_1.id, + reminder: reminders, + ) + }.not_to change { not_going_user.reload.unread_notifications } end it "doesn’t create a new notification if there’s already one" do expect(going_user_unread_notification.unread_notifications).to eq(1) - expect { subject.execute(event_id: event_1.id, reminder: reminders) }.not_to change { - going_user_unread_notification.reload.unread_notifications - } + expect { + Jobs::DiscoursePostEventSendReminder.new.execute( + event_id: event_1.id, + reminder: reminders, + ) + }.not_to change { going_user_unread_notification.reload.unread_notifications } end it "delete previous notifications before creating a new one" do - subject.execute(event_id: event_1.id, reminder: reminders) + Jobs::DiscoursePostEventSendReminder.new.execute( + event_id: event_1.id, + reminder: reminders, + ) going_user.notifications.update_all(read: true) - subject.execute(event_id: event_1.id, reminder: reminders) + Jobs::DiscoursePostEventSendReminder.new.execute( + event_id: event_1.id, + reminder: reminders, + ) expect( going_user @@ -149,40 +179,58 @@ def init_invitees it "creates a new notification for going user" do expect(going_user.reload.unread_notifications).to eq(0) - expect { subject.execute(event_id: event_1.id, reminder: reminders) }.to change { - going_user.reload.unread_notifications - }.by(1) + expect { + Jobs::DiscoursePostEventSendReminder.new.execute( + event_id: event_1.id, + reminder: reminders, + ) + }.to change { going_user.reload.unread_notifications }.by(1) end it "creates a new notification for interested user" do expect(interested_user.reload.unread_notifications).to eq(0) - expect { subject.execute(event_id: event_1.id, reminder: reminders) }.to change { - interested_user.reload.unread_notifications - }.by(1) + expect { + Jobs::DiscoursePostEventSendReminder.new.execute( + event_id: event_1.id, + reminder: reminders, + ) + }.to change { interested_user.reload.unread_notifications }.by(1) end it "doesn’t create a new notification for not going user" do expect(not_going_user.unread_notifications).to eq(0) - expect { subject.execute(event_id: event_1.id, reminder: reminders) }.not_to change { - not_going_user.reload.unread_notifications - } + expect { + Jobs::DiscoursePostEventSendReminder.new.execute( + event_id: event_1.id, + reminder: reminders, + ) + }.not_to change { not_going_user.reload.unread_notifications } end it "doesn’t create a new notification if there’s already one" do expect(going_user_unread_notification.unread_notifications).to eq(1) - expect { subject.execute(event_id: event_1.id, reminder: reminders) }.not_to change { - going_user_unread_notification.reload.unread_notifications - } + expect { + Jobs::DiscoursePostEventSendReminder.new.execute( + event_id: event_1.id, + reminder: reminders, + ) + }.not_to change { going_user_unread_notification.reload.unread_notifications } end it "deletes previous notifications when creating a new one" do - subject.execute(event_id: event_1.id, reminder: reminders) + Jobs::DiscoursePostEventSendReminder.new.execute( + event_id: event_1.id, + reminder: reminders, + ) going_user.notifications.update_all(read: true) - subject.execute(event_id: event_1.id, reminder: reminders) + Jobs::DiscoursePostEventSendReminder.new.execute( + event_id: event_1.id, + reminder: reminders, + ) expect( going_user @@ -205,7 +253,10 @@ def init_invitees }.to_json, ) - subject.execute(event_id: event_1.id, reminder: reminders) + Jobs::DiscoursePostEventSendReminder.new.execute( + event_id: event_1.id, + reminder: reminders, + ) messages = Notification.where( user: going_user, @@ -221,9 +272,12 @@ def init_invitees it "doesn’t create a new notification for visiting user" do expect(visited_going_user.unread_notifications).to eq(0) - expect { subject.execute(event_id: event_1.id, reminder: reminders) }.not_to change { - visited_going_user.reload.unread_notifications - } + expect { + Jobs::DiscoursePostEventSendReminder.new.execute( + event_id: event_1.id, + reminder: reminders, + ) + }.not_to change { visited_going_user.reload.unread_notifications } end end end diff --git a/spec/jobs/scheduled/create_holiday_events_spec.rb b/spec/jobs/scheduled/create_holiday_events_spec.rb index 5b25cecf8..7b791a05d 100644 --- a/spec/jobs/scheduled/create_holiday_events_spec.rb +++ b/spec/jobs/scheduled/create_holiday_events_spec.rb @@ -23,7 +23,7 @@ frenchy freeze_time Time.zone.local(2019, 8, 1) - subject.execute(nil) + DiscourseCalendar::CreateHolidayEvents.new.execute(nil) expect(CalendarEvent.where(user_id: frenchy.id).count).to eq(0) end @@ -31,7 +31,7 @@ it "adds all holidays in the next 6 months" do frenchy freeze_time Time.zone.local(2019, 8, 1) - subject.execute(nil) + DiscourseCalendar::CreateHolidayEvents.new.execute(nil) expect(CalendarEvent.pluck(:region, :description, :start_date, :username)).to eq( [ @@ -47,7 +47,7 @@ it "checks for observed dates" do aussie freeze_time Time.zone.local(2020, 1, 20) - subject.execute(nil) + DiscourseCalendar::CreateHolidayEvents.new.execute(nil) # The "Australia Day" is always observed on a Monday expect(CalendarEvent.pluck(:region, :description, :start_date, :username)).to eq( @@ -62,7 +62,7 @@ it "only checks for holidays during business days" do frenchy freeze_time Time.zone.local(2019, 7, 1) - subject.execute(nil) + DiscourseCalendar::CreateHolidayEvents.new.execute(nil) # The "Fête Nationale" is on July 14th but it's on a Sunday in 2019 expect(CalendarEvent.pluck(:region, :description, :start_date, :username)).to eq( @@ -106,7 +106,7 @@ }, ) - subject.execute(nil) + DiscourseCalendar::CreateHolidayEvents.new.execute(nil) expect(CalendarEvent.pluck(:region, :description, :start_date, :username)).to eq([]) end @@ -114,14 +114,14 @@ it "cleans up holidays from deactivated/silenced/suspended users" do frenchy freeze_time Time.zone.local(2019, 8, 1) - subject.execute(nil) + DiscourseCalendar::CreateHolidayEvents.new.execute(nil) expect(CalendarEvent.exists?(username: frenchy.username)).to eq(true) frenchy.active = false frenchy.save! - subject.execute(nil) + DiscourseCalendar::CreateHolidayEvents.new.execute(nil) expect(CalendarEvent.exists?(username: frenchy.username)).to eq(false) end @@ -138,7 +138,7 @@ it "only adds enabled holidays to the calendar" do frenchy freeze_time Time.zone.local(2019, 7, 1) - subject.execute(nil) + DiscourseCalendar::CreateHolidayEvents.new.execute(nil) expect(CalendarEvent.pluck(:region, :description, :start_date, :username)).to eq( [ @@ -152,7 +152,7 @@ it "doesn't add disabled holidays to the calendar" do frenchy freeze_time Time.zone.local(2019, 7, 1) - subject.execute(nil) + DiscourseCalendar::CreateHolidayEvents.new.execute(nil) expect(CalendarEvent.pluck(:description)).not_to include(france_assomption[:holiday_name]) expect(CalendarEvent.pluck(:description)).not_to include(france_toussaint[:holiday_name]) @@ -163,7 +163,7 @@ it "uses the user TZ when available" do frenchy.user_option.update!(timezone: "Europe/Paris") freeze_time Time.zone.local(2019, 8, 1) - subject.execute(nil) + DiscourseCalendar::CreateHolidayEvents.new.execute(nil) calendar_event = CalendarEvent.first expect(calendar_event.region).to eq("fr") @@ -181,7 +181,7 @@ it "uses the user TZ when available" do frenchy.user_option.update!(timezone: "Europe/Paris") freeze_time Time.zone.local(2019, 8, 1) - subject.execute(nil) + DiscourseCalendar::CreateHolidayEvents.new.execute(nil) calendar_event = CalendarEvent.first expect(calendar_event.region).to eq("fr") diff --git a/spec/jobs/scheduled/delete_expired_event_posts.rb b/spec/jobs/scheduled/delete_expired_event_posts.rb index 95a5434b6..cc4b0e71b 100644 --- a/spec/jobs/scheduled/delete_expired_event_posts.rb +++ b/spec/jobs/scheduled/delete_expired_event_posts.rb @@ -27,7 +27,7 @@ raw: "Summer ☀️ Solstice [date=#{Date.current.year + 1}-06-21]", ) - subject.execute(nil) + DiscourseCalendar::DeleteExpiredEventPosts.new.execute(nil) expect(Post.exists?(post_with_one_date.id)).to eq(false) expect(Post.exists?(post_with_two_dates.id)).to eq(false) @@ -53,7 +53,7 @@ description: "Matariki", ) - subject.execute(nil) + DiscourseCalendar::DeleteExpiredEventPosts.new.execute(nil) expect(CalendarEvent.exists?(matariki.id)).to eq(true) end @@ -62,7 +62,7 @@ post = create_post(raw: "Discourse 💬 Launch 🚀 on [date=2013-02-05]") CalendarEvent.create!(topic: post.topic, post: post, start_date: Date.new(2013, 2, 5)) - subject.execute(nil) + DiscourseCalendar::DeleteExpiredEventPosts.new.execute(nil) expect(Post.exists?(post.id)).to eq(true) end @@ -74,7 +74,7 @@ raw: 'WWW - Weekly Wednesday Watercooler [date=2022-01-05 recurring="1.week"] 🐸', ) - subject.execute(nil) + DiscourseCalendar::DeleteExpiredEventPosts.new.execute(nil) expect(Post.exists?(post.id)).to eq(true) end @@ -88,7 +88,7 @@ calendar_topic.update!(archived: true) - subject.execute(nil) + DiscourseCalendar::DeleteExpiredEventPosts.new.execute(nil) expect(Post.exists?(post.id)).to eq(true) end @@ -102,7 +102,7 @@ calendar_topic.update!(closed: true) - subject.execute(nil) + DiscourseCalendar::DeleteExpiredEventPosts.new.execute(nil) expect(Post.exists?(post.id)).to eq(true) end @@ -153,7 +153,7 @@ freeze_time Time.parse("2018-10-01 00:00:00 UTC") - subject.execute(nil) + DiscourseCalendar::DeleteExpiredEventPosts.new.execute(nil) expect(Post.exists?(post.id)).to eq(false) expect(Post.exists?(reply_without_event.id)).to eq(false) diff --git a/spec/jobs/scheduled/update_holiday_usernames_spec.rb b/spec/jobs/scheduled/update_holiday_usernames_spec.rb index be0cafab0..1ab24524f 100644 --- a/spec/jobs/scheduled/update_holiday_usernames_spec.rb +++ b/spec/jobs/scheduled/update_holiday_usernames_spec.rb @@ -17,12 +17,12 @@ raw = 'Rome [date="2018-06-05" time="10:20:00"] to [date="2018-06-06" time="10:20:00"]' post = create_post(raw: raw, topic: calendar_post.topic) - subject.execute(nil) + DiscourseCalendar::UpdateHolidayUsernames.new.execute(nil) expect(DiscourseCalendar.users_on_holiday).to eq([post.user.username]) freeze_time Time.utc(2018, 6, 7, 18, 40) - subject.execute(nil) + DiscourseCalendar::UpdateHolidayUsernames.new.execute(nil) expect(DiscourseCalendar.users_on_holiday).to eq([]) end @@ -36,7 +36,7 @@ raw2 = 'Rome [date="2018-06-05"]' # the whole day post2 = create_post(raw: raw2, topic: calendar_post.topic) - subject.execute(nil) + DiscourseCalendar::UpdateHolidayUsernames.new.execute(nil) expect( UserCustomField.exists?( name: DiscourseCalendar::HOLIDAY_CUSTOM_FIELD, @@ -51,7 +51,7 @@ ).to be_truthy freeze_time Time.utc(2018, 6, 6, 10, 00) - subject.execute(nil) + DiscourseCalendar::UpdateHolidayUsernames.new.execute(nil) expect( UserCustomField.exists?( name: DiscourseCalendar::HOLIDAY_CUSTOM_FIELD, @@ -66,7 +66,7 @@ ).to be_falsey freeze_time Time.utc(2018, 6, 7, 10, 00) - subject.execute(nil) + DiscourseCalendar::UpdateHolidayUsernames.new.execute(nil) expect( UserCustomField.exists?( name: DiscourseCalendar::HOLIDAY_CUSTOM_FIELD, @@ -88,7 +88,7 @@ raw = 'Rome [date="2018-06-05" time="10:20:00"] to [date="2018-06-06" time="10:20:00"]' post = create_post(raw: raw, topic: calendar_post.topic) - subject.execute(nil) + DiscourseCalendar::UpdateHolidayUsernames.new.execute(nil) post.user.reload status = post.user.user_status @@ -105,7 +105,7 @@ raw = 'Rome [date="2018-06-05" time="10:20:00"] to [date="2018-06-06" time="10:20:00"]' post = create_post(raw: raw, topic: calendar_post.topic) - subject.execute(nil) + DiscourseCalendar::UpdateHolidayUsernames.new.execute(nil) post.user.reload expect(post.user.user_status).to be_nil @@ -120,7 +120,7 @@ custom_status = { description: "I am working on holiday", emoji: "construction_worker_man" } post.user.set_status!(custom_status[:description], custom_status[:emoji]) - subject.execute(nil) + DiscourseCalendar::UpdateHolidayUsernames.new.execute(nil) post.user.reload status = post.user.user_status @@ -151,7 +151,7 @@ ) freeze_time tomorrow + 2.day - subject.execute(nil) + DiscourseCalendar::UpdateHolidayUsernames.new.execute(nil) post.user.reload status = post.user.user_status @@ -168,7 +168,7 @@ raw = 'Rome [date="2018-06-05" time="10:20:00"] to [date="2018-06-06" time="10:20:00"]' post = create_post(raw: raw, topic: calendar_post.topic) - subject.execute(nil) + DiscourseCalendar::UpdateHolidayUsernames.new.execute(nil) post.user.reload expect(post.user.user_status).to be_present @@ -180,7 +180,7 @@ { raw: 'Rome [date="2018-06-05" time="10:20:00"] to [date="2018-12-10" time="10:20:00"]' }, revised_at: Time.now, ) - subject.execute(nil) + DiscourseCalendar::UpdateHolidayUsernames.new.execute(nil) post.user.reload expect(post.user.user_status).to be_present diff --git a/spec/lib/discourse_post_event/event_finder_spec.rb b/spec/lib/discourse_post_event/event_finder_spec.rb index ddba9544e..a0eafe01b 100644 --- a/spec/lib/discourse_post_event/event_finder_spec.rb +++ b/spec/lib/discourse_post_event/event_finder_spec.rb @@ -5,7 +5,7 @@ fab!(:current_user) { Fabricate(:user) } fab!(:user) { Fabricate(:user) } - subject { DiscoursePostEvent::EventFinder } + subject(:finder) { DiscoursePostEvent::EventFinder } before do Jobs.run_immediately! @@ -24,7 +24,7 @@ let!(:event) { Fabricate(:event, post: post1) } it "returns the event" do - expect(subject.search(current_user)).to match_array([event]) + expect(finder.search(current_user)).to match_array([event]) end end @@ -41,7 +41,7 @@ let!(:event) { Fabricate(:event, post: post1) } it "returns the event" do - expect(subject.search(current_user)).to match_array([event]) + expect(finder.search(current_user)).to match_array([event]) end end @@ -59,7 +59,7 @@ let!(:event) { Fabricate(:event, post: post1) } it "doesn’t return the event" do - expect(subject.search(current_user)).to match_array([]) + expect(finder.search(current_user)).to match_array([]) end end @@ -83,7 +83,7 @@ let!(:event2) { Fabricate(:event, post: post2) } it "returns only the specified event" do - expect(subject.search(current_user, { post_id: post2.id })).to match_array([event2]) + expect(finder.search(current_user, { post_id: post2.id })).to match_array([event2]) end end @@ -122,10 +122,8 @@ end it "returns correct events" do - expect(subject.search(current_user, { expired: false })).to eq( - [current_event, future_event], - ) - expect(subject.search(current_user, { expired: true })).to eq([older_event, old_event]) + expect(finder.search(current_user, { expired: false })).to eq([current_event, future_event]) + expect(finder.search(current_user, { expired: true })).to eq([older_event, old_event]) end context "when a past event has been edited to be in the future" do @@ -140,10 +138,10 @@ end it "returns correct events" do - expect(subject.search(current_user, { expired: false })).to eq( + expect(finder.search(current_user, { expired: false })).to eq( [current_event, future_event], ) - expect(subject.search(current_user, { expired: true })).to eq([older_event, old_event]) + expect(finder.search(current_user, { expired: true })).to eq([older_event, old_event]) end end @@ -159,10 +157,10 @@ end it "returns correct events" do - expect(subject.search(current_user, { expired: false })).to eq( + expect(finder.search(current_user, { expired: false })).to eq( [current_event, future_event], ) - expect(subject.search(current_user, { expired: true })).to eq([older_event, old_event]) + expect(finder.search(current_user, { expired: true })).to eq([older_event, old_event]) end end end diff --git a/spec/lib/discourse_post_event/event_parser_spec.rb b/spec/lib/discourse_post_event/event_parser_spec.rb index 398e7a466..0e07816f7 100644 --- a/spec/lib/discourse_post_event/event_parser_spec.rb +++ b/spec/lib/discourse_post_event/event_parser_spec.rb @@ -7,17 +7,17 @@ def build_post(user, raw) end describe DiscoursePostEvent::EventParser do - subject { DiscoursePostEvent::EventParser } + subject(:parser) { DiscoursePostEvent::EventParser } let(:user) { Fabricate(:user) } it "works with no event" do - events = subject.extract_events(build_post(user, "this could be a nice event")) + events = parser.extract_events(build_post(user, "this could be a nice event")) expect(events.length).to eq(0) end it "finds one event" do - events = subject.extract_events(build_post(user, '[event start="foo" end="bar"]\n[/event]')) + events = parser.extract_events(build_post(user, '[event start="foo" end="bar"]\n[/event]')) expect(events.length).to eq(1) end @@ -30,33 +30,32 @@ def build_post(user, raw) [/event] TXT - events = subject.extract_events(post_event) + events = parser.extract_events(post_event) expect(events.length).to eq(2) end it "parses options" do - events = subject.extract_events(build_post(user, '[event start="foo" end="bar"]\n[/event]')) + events = parser.extract_events(build_post(user, '[event start="foo" end="bar"]\n[/event]')) expect(events[0][:start]).to eq("foo") expect(events[0][:end]).to eq("bar") end it "works with escaped string" do events = - subject.extract_events( + parser.extract_events( build_post(user, "I am going to get that fixed.\n\n[event start=\"bar\"]\n[/event]"), ) expect(events[0][:start]).to eq("bar") end it "parses options where value has spaces" do - events = - subject.extract_events(build_post(user, '[event start="foo" name="bar baz"]\n[/event]')) + events = parser.extract_events(build_post(user, '[event start="foo" name="bar baz"]\n[/event]')) expect(events[0][:name]).to eq("bar baz") end it "doesn’t parse invalid options" do events = - subject.extract_events( + parser.extract_events( build_post( user, "I am going to get that fixed.\n\n[event start=\"foo\" something=\"bar\"]\n[/event]", @@ -65,7 +64,7 @@ def build_post(user, raw) expect(events[0][:something]).to be(nil) events = - subject.extract_events( + parser.extract_events( build_post(user, "I am going to get that fixed.\n\n[event something=\"bar\"]\n[/event]"), ) expect(events).to eq([]) @@ -79,7 +78,7 @@ def build_post(user, raw) ``` TXT - events = subject.extract_events(post_event) + events = parser.extract_events(post_event) expect(events).to eq([]) end @@ -89,13 +88,13 @@ def build_post(user, raw) [event start="2020"][/event] TXT - events = subject.extract_events(post_event) + events = parser.extract_events(post_event) expect(events).to eq([]) end it "doesn’t escape event name" do events = - subject.extract_events( + parser.extract_events( build_post(user, '[event start="foo" name="bar