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

Rename remainders of reason_ian to reason

Oliver Güntherb91faeac6a4e
diff --git a/app/models/queries/notifications/filters/reason_filter.rb b/app/models/queries/notifications/filters/reason_filter.rb
index 8edb8da063b..b667865f5fa 100644
--- a/app/models/queries/notifications/filters/reason_filter.rb
+++ b/app/models/queries/notifications/filters/reason_filter.rb
@@ -30,7 +30,7 @@
class Queries::Notifications::Filters::ReasonFilter < Queries::Notifications::Filters::NotificationFilter
def allowed_values
- Notification.reason_ians.keys.map { |reason| [reason, reason] }
+ Notification.reasons.keys.map { |reason| [reason, reason] }
end
def type
@@ -38,7 +38,7 @@ class Queries::Notifications::Filters::ReasonFilter < Queries::Notifications::Fi
end
def where
- id_values = values.map { |value| Notification.reason_ians[value] }
- operator_strategy.sql_for_field(id_values, self.class.model.table_name, :reason_ian)
+ id_values = values.map { |value| Notification.reasons[value] }
+ operator_strategy.sql_for_field(id_values, self.class.model.table_name, :reason)
end
end
diff --git a/app/models/queries/notifications/group_bys/group_by_reason.rb b/app/models/queries/notifications/group_bys/group_by_reason.rb
index 343038db3a9..c09c9b87aba 100644
--- a/app/models/queries/notifications/group_bys/group_by_reason.rb
+++ b/app/models/queries/notifications/group_bys/group_by_reason.rb
@@ -36,6 +36,6 @@ class Queries::Notifications::GroupBys::GroupByReason < Queries::GroupBys::Base
end
def name
- :reason_ian
+ :reason
end
end
diff --git a/app/models/queries/notifications/orders/reason_order.rb b/app/models/queries/notifications/orders/reason_order.rb
index 90f508539ca..26b6234ce89 100644
--- a/app/models/queries/notifications/orders/reason_order.rb
+++ b/app/models/queries/notifications/orders/reason_order.rb
@@ -36,6 +36,6 @@ class Queries::Notifications::Orders::ReasonOrder < Queries::Orders::Base
end
def name
- :reason_ian
+ :reason
end
end
diff --git a/modules/documents/spec/services/notifications/create_from_model_service_document_spec.rb b/modules/documents/spec/services/notifications/create_from_model_service_document_spec.rb
index 42b624c9840..27dac200425 100644
--- a/modules/documents/spec/services/notifications/create_from_model_service_document_spec.rb
+++ b/modules/documents/spec/services/notifications/create_from_model_service_document_spec.rb
@@ -61,9 +61,9 @@ describe Notifications::CreateFromModelService, 'document', with_settings: { jou
it_behaves_like 'creates notification' do
let(:notification_channel_reasons) do
{
- read_ian: nil,
- reason: false,
- mail_reminder_sent: nil
+ read_ian: false,
+ reason: :subscribed,
+ mail_reminder_sent: false
}
end
end
@@ -108,9 +108,9 @@ describe Notifications::CreateFromModelService, 'document', with_settings: { jou
it_behaves_like 'creates notification' do
let(:notification_channel_reasons) do
{
- read_ian: nil,
- reason: false,
- mail_reminder_sent: nil
+ read_ian: false,
+ reason: :subscribed,
+ mail_reminder_sent: false
}
end
end
diff --git a/spec/models/queries/notifications/notification_query_spec.rb b/spec/models/queries/notifications/notification_query_spec.rb
index 5321cf1c3d1..e7dab0b5e4f 100644
--- a/spec/models/queries/notifications/notification_query_spec.rb
+++ b/spec/models/queries/notifications/notification_query_spec.rb
@@ -135,7 +135,7 @@ describe Queries::Notifications::NotificationQuery, type: :model do
expected = <<~SQL.squish
SELECT "notifications".* FROM "notifications"
WHERE "notifications"."recipient_id" = #{recipient.id}
- ORDER BY "notifications"."reason_ian" DESC, "notifications"."id" DESC
+ ORDER BY "notifications"."reason" DESC, "notifications"."id" DESC
SQL
expect(instance.results.to_sql).to eql expected
@@ -171,10 +171,10 @@ describe Queries::Notifications::NotificationQuery, type: :model do
describe '#results' do
it 'is the same as handwriting the query' do
expected = <<~SQL.squish
- SELECT "notifications"."reason_ian", COUNT(*) FROM "notifications"
+ SELECT "notifications"."reason", COUNT(*) FROM "notifications"
WHERE "notifications"."recipient_id" = #{recipient.id}
- GROUP BY "notifications"."reason_ian"
- ORDER BY "notifications"."reason_ian" ASC
+ GROUP BY "notifications"."reason"
+ ORDER BY "notifications"."reason" ASC
SQL
expect(instance.groups.to_sql).to eql expected
diff --git a/spec/requests/api/v3/notifications/index_resource_spec.rb b/spec/requests/api/v3/notifications/index_resource_spec.rb
index 9202ccf5b25..bd0cf0617e1 100644
--- a/spec/requests/api/v3/notifications/index_resource_spec.rb
+++ b/spec/requests/api/v3/notifications/index_resource_spec.rb
@@ -81,15 +81,6 @@ describe ::API::V3::Notifications::NotificationsAPI,
it_behaves_like 'API V3 collection response', 2, 2, 'Notification'
- context 'with a digest notification' do
- let(:digest_notification) { FactoryBot.create :notification, recipient: recipient, reason: nil }
- let(:notifications) { [notification1, notification2, digest_notification] }
-
- it_behaves_like 'API V3 collection response', 2, 2, 'Notification' do
- let(:elements) { [notification2, notification1] }
- end
- end
-
context 'with a readIAN filter' do
let(:nil_notification) { FactoryBot.create :notification, recipient: recipient, read_ian: nil }
@@ -171,7 +162,7 @@ describe ::API::V3::Notifications::NotificationsAPI,
context 'with a reason filter' do
let(:notification3) do
FactoryBot.create :notification,
- reason_ian: :assigned,
+ reason: :assigned,
recipient: recipient,
resource: work_package,
project: work_package.project,
@@ -179,7 +170,7 @@ describe ::API::V3::Notifications::NotificationsAPI,
end
let(:notification4) do
FactoryBot.create :notification,
- reason_ian: :responsible,
+ reason: :responsible,
recipient: recipient,
resource: work_package,
project: work_package.project,
@@ -192,7 +183,7 @@ describe ::API::V3::Notifications::NotificationsAPI,
{
'reason' => {
'operator' => '=',
- 'values' => [notification1.reason_ian.to_s, notification4.reason_ian.to_s]
+ 'values' => [notification1.reason.to_s, notification4.reason.to_s]
}
}
]
@@ -229,7 +220,7 @@ describe ::API::V3::Notifications::NotificationsAPI,
let(:responsible_notification) do
FactoryBot.create :notification,
recipient: recipient,
- reason_ian: :responsible,
+ reason: :responsible,
resource: work_package,
project: work_package.project,
journal: work_package.journals.first
@@ -263,7 +254,7 @@ describe ::API::V3::Notifications::NotificationsAPI,
resource: work_package2,
project: work_package2.project,
recipient: recipient,
- reason_ian: :responsible,
+ reason: :responsible,
journal: work_package2.journals.first
end