mirror of
https://github.com/LaCasemate/fab-manager.git
synced 2025-02-20 14:54:15 +01:00
(test) backend test for notifications
This commit is contained in:
parent
84b28ffddf
commit
c90dc8a369
135
db/schema.rb
135
db/schema.rb
@ -150,6 +150,110 @@ ActiveRecord::Schema.define(version: 2023_01_31_104958) do
|
||||
t.index ["tag_id"], name: "index_availability_tags_on_tag_id"
|
||||
end
|
||||
|
||||
create_table "cart_item_coupons", force: :cascade do |t|
|
||||
t.bigint "coupon_id"
|
||||
t.bigint "customer_profile_id"
|
||||
t.bigint "operator_profile_id"
|
||||
t.datetime "created_at", null: false
|
||||
t.datetime "updated_at", null: false
|
||||
t.index ["coupon_id"], name: "index_cart_item_coupons_on_coupon_id"
|
||||
t.index ["customer_profile_id"], name: "index_cart_item_coupons_on_customer_profile_id"
|
||||
t.index ["operator_profile_id"], name: "index_cart_item_coupons_on_operator_profile_id"
|
||||
end
|
||||
|
||||
create_table "cart_item_event_reservation_tickets", force: :cascade do |t|
|
||||
t.integer "booked"
|
||||
t.bigint "event_price_category_id"
|
||||
t.bigint "cart_item_event_reservation_id"
|
||||
t.datetime "created_at", null: false
|
||||
t.datetime "updated_at", null: false
|
||||
t.index ["cart_item_event_reservation_id"], name: "index_cart_item_tickets_on_cart_item_event_reservation"
|
||||
t.index ["event_price_category_id"], name: "index_cart_item_tickets_on_event_price_category"
|
||||
end
|
||||
|
||||
create_table "cart_item_event_reservations", force: :cascade do |t|
|
||||
t.integer "normal_tickets"
|
||||
t.bigint "event_id"
|
||||
t.bigint "operator_profile_id"
|
||||
t.bigint "customer_profile_id"
|
||||
t.datetime "created_at", null: false
|
||||
t.datetime "updated_at", null: false
|
||||
t.index ["customer_profile_id"], name: "index_cart_item_event_reservations_on_customer_profile_id"
|
||||
t.index ["event_id"], name: "index_cart_item_event_reservations_on_event_id"
|
||||
t.index ["operator_profile_id"], name: "index_cart_item_event_reservations_on_operator_profile_id"
|
||||
end
|
||||
|
||||
create_table "cart_item_free_extensions", force: :cascade do |t|
|
||||
t.bigint "subscription_id"
|
||||
t.datetime "new_expiration_date"
|
||||
t.bigint "customer_profile_id"
|
||||
t.datetime "created_at", null: false
|
||||
t.datetime "updated_at", null: false
|
||||
t.index ["customer_profile_id"], name: "index_cart_item_free_extensions_on_customer_profile_id"
|
||||
t.index ["subscription_id"], name: "index_cart_item_free_extensions_on_subscription_id"
|
||||
end
|
||||
|
||||
create_table "cart_item_payment_schedules", force: :cascade do |t|
|
||||
t.bigint "plan_id"
|
||||
t.bigint "coupon_id"
|
||||
t.boolean "requested"
|
||||
t.datetime "start_at"
|
||||
t.bigint "customer_profile_id"
|
||||
t.datetime "created_at", null: false
|
||||
t.datetime "updated_at", null: false
|
||||
t.index ["coupon_id"], name: "index_cart_item_payment_schedules_on_coupon_id"
|
||||
t.index ["customer_profile_id"], name: "index_cart_item_payment_schedules_on_customer_profile_id"
|
||||
t.index ["plan_id"], name: "index_cart_item_payment_schedules_on_plan_id"
|
||||
end
|
||||
|
||||
create_table "cart_item_prepaid_packs", force: :cascade do |t|
|
||||
t.bigint "prepaid_pack_id"
|
||||
t.bigint "customer_profile_id"
|
||||
t.datetime "created_at", null: false
|
||||
t.datetime "updated_at", null: false
|
||||
t.index ["customer_profile_id"], name: "index_cart_item_prepaid_packs_on_customer_profile_id"
|
||||
t.index ["prepaid_pack_id"], name: "index_cart_item_prepaid_packs_on_prepaid_pack_id"
|
||||
end
|
||||
|
||||
create_table "cart_item_reservation_slots", force: :cascade do |t|
|
||||
t.string "cart_item_type"
|
||||
t.bigint "cart_item_id"
|
||||
t.bigint "slot_id"
|
||||
t.bigint "slots_reservation_id"
|
||||
t.boolean "offered", default: false
|
||||
t.datetime "created_at", null: false
|
||||
t.datetime "updated_at", null: false
|
||||
t.index ["cart_item_type", "cart_item_id"], name: "index_cart_item_slots_on_cart_item"
|
||||
t.index ["slot_id"], name: "index_cart_item_reservation_slots_on_slot_id"
|
||||
t.index ["slots_reservation_id"], name: "index_cart_item_reservation_slots_on_slots_reservation_id"
|
||||
end
|
||||
|
||||
create_table "cart_item_reservations", force: :cascade do |t|
|
||||
t.string "reservable_type"
|
||||
t.bigint "reservable_id"
|
||||
t.bigint "plan_id"
|
||||
t.boolean "new_subscription"
|
||||
t.bigint "customer_profile_id"
|
||||
t.bigint "operator_profile_id"
|
||||
t.string "type"
|
||||
t.datetime "created_at", null: false
|
||||
t.datetime "updated_at", null: false
|
||||
t.index ["customer_profile_id"], name: "index_cart_item_reservations_on_customer_profile_id"
|
||||
t.index ["operator_profile_id"], name: "index_cart_item_reservations_on_operator_profile_id"
|
||||
t.index ["plan_id"], name: "index_cart_item_reservations_on_plan_id"
|
||||
t.index ["reservable_type", "reservable_id"], name: "index_cart_item_reservations_on_reservable"
|
||||
end
|
||||
|
||||
create_table "cart_item_subscriptions", force: :cascade do |t|
|
||||
t.bigint "plan_id"
|
||||
t.datetime "start_at"
|
||||
t.bigint "customer_profile_id"
|
||||
t.datetime "created_at", null: false
|
||||
t.datetime "updated_at", null: false
|
||||
t.index ["customer_profile_id"], name: "index_cart_item_subscriptions_on_customer_profile_id"
|
||||
t.index ["plan_id"], name: "index_cart_item_subscriptions_on_plan_id"
|
||||
end
|
||||
|
||||
create_table "categories", id: :serial, force: :cascade do |t|
|
||||
t.string "name"
|
||||
t.datetime "created_at"
|
||||
@ -173,6 +277,7 @@ ActiveRecord::Schema.define(version: 2023_01_31_104958) do
|
||||
t.datetime "updated_at", null: false
|
||||
t.string "validity_per_user"
|
||||
t.integer "amount_off"
|
||||
t.index ["code"], name: "index_coupons_on_code", unique: true
|
||||
end
|
||||
|
||||
create_table "credits", id: :serial, force: :cascade do |t|
|
||||
@ -921,13 +1026,15 @@ ActiveRecord::Schema.define(version: 2023_01_31_104958) do
|
||||
t.datetime "end_at"
|
||||
t.datetime "created_at"
|
||||
t.datetime "updated_at"
|
||||
t.integer "availability_id"
|
||||
t.integer "availability_id", null: false
|
||||
t.jsonb "places", default: [], null: false
|
||||
t.index ["availability_id"], name: "index_slots_on_availability_id"
|
||||
t.index ["places"], name: "index_slots_on_places", using: :gin
|
||||
end
|
||||
|
||||
create_table "slots_reservations", id: :serial, force: :cascade do |t|
|
||||
t.integer "slot_id"
|
||||
t.integer "reservation_id"
|
||||
t.integer "slot_id", null: false
|
||||
t.integer "reservation_id", null: false
|
||||
t.datetime "ex_start_at"
|
||||
t.datetime "ex_end_at"
|
||||
t.datetime "canceled_at"
|
||||
@ -1252,6 +1359,28 @@ ActiveRecord::Schema.define(version: 2023_01_31_104958) do
|
||||
add_foreign_key "auth_provider_mappings", "auth_providers"
|
||||
add_foreign_key "availability_tags", "availabilities"
|
||||
add_foreign_key "availability_tags", "tags"
|
||||
add_foreign_key "cart_item_coupons", "coupons"
|
||||
add_foreign_key "cart_item_coupons", "invoicing_profiles", column: "customer_profile_id"
|
||||
add_foreign_key "cart_item_coupons", "invoicing_profiles", column: "operator_profile_id"
|
||||
add_foreign_key "cart_item_event_reservation_tickets", "cart_item_event_reservations"
|
||||
add_foreign_key "cart_item_event_reservation_tickets", "event_price_categories"
|
||||
add_foreign_key "cart_item_event_reservations", "events"
|
||||
add_foreign_key "cart_item_event_reservations", "invoicing_profiles", column: "customer_profile_id"
|
||||
add_foreign_key "cart_item_event_reservations", "invoicing_profiles", column: "operator_profile_id"
|
||||
add_foreign_key "cart_item_free_extensions", "invoicing_profiles", column: "customer_profile_id"
|
||||
add_foreign_key "cart_item_free_extensions", "subscriptions"
|
||||
add_foreign_key "cart_item_payment_schedules", "coupons"
|
||||
add_foreign_key "cart_item_payment_schedules", "invoicing_profiles", column: "customer_profile_id"
|
||||
add_foreign_key "cart_item_payment_schedules", "plans"
|
||||
add_foreign_key "cart_item_prepaid_packs", "invoicing_profiles", column: "customer_profile_id"
|
||||
add_foreign_key "cart_item_prepaid_packs", "prepaid_packs"
|
||||
add_foreign_key "cart_item_reservation_slots", "slots"
|
||||
add_foreign_key "cart_item_reservation_slots", "slots_reservations"
|
||||
add_foreign_key "cart_item_reservations", "invoicing_profiles", column: "customer_profile_id"
|
||||
add_foreign_key "cart_item_reservations", "invoicing_profiles", column: "operator_profile_id"
|
||||
add_foreign_key "cart_item_reservations", "plans"
|
||||
add_foreign_key "cart_item_subscriptions", "invoicing_profiles", column: "customer_profile_id"
|
||||
add_foreign_key "cart_item_subscriptions", "plans"
|
||||
add_foreign_key "event_price_categories", "events"
|
||||
add_foreign_key "event_price_categories", "price_categories"
|
||||
add_foreign_key "events", "categories"
|
||||
|
13
test/fixtures/notification_preferences.yml
vendored
13
test/fixtures/notification_preferences.yml
vendored
@ -18,8 +18,17 @@ notification_preference_2:
|
||||
|
||||
notification_preference_3:
|
||||
id: 3
|
||||
user_id: 2
|
||||
notification_type_id: 2
|
||||
user_id: 1
|
||||
notification_type_id: 13
|
||||
in_system: false
|
||||
email: false
|
||||
created_at: 2023-02-02 15:25:13.744539000 Z
|
||||
updated_at: 2023-02-02 15:25:13.744539000 Z
|
||||
|
||||
notification_preference_4:
|
||||
id: 4
|
||||
user_id: 2
|
||||
notification_type_id: 35
|
||||
in_system: false
|
||||
email: false
|
||||
created_at: 2023-02-02 15:25:13.744539000 Z
|
||||
|
544
test/fixtures/notification_types.yml
vendored
544
test/fixtures/notification_types.yml
vendored
@ -1,31 +1,543 @@
|
||||
notification_type_1:
|
||||
id: 1
|
||||
name: 'notify_dev_when_sun_shines'
|
||||
category: 'meteo'
|
||||
name: notify_admin_when_project_published
|
||||
category: projects
|
||||
is_configurable: true
|
||||
created_at: 2023-02-02 15:25:13.744539000 Z
|
||||
updated_at: 2023-02-02 15:25:13.744539000 Z
|
||||
created_at: 2023-02-02 08:25:33.353635000 Z
|
||||
updated_at: 2023-02-02 08:25:33.353635000 Z
|
||||
|
||||
notification_type_2:
|
||||
id: 2
|
||||
name: 'notify_dev_when_raining'
|
||||
category: 'meteo'
|
||||
name: notify_project_collaborator_to_valid
|
||||
category: projects
|
||||
is_configurable: true
|
||||
created_at: 2023-02-02 15:25:30.321953000 Z
|
||||
updated_at: 2023-02-02 15:25:30.321953000 Z
|
||||
created_at: 2023-02-02 08:25:33.355650000 Z
|
||||
updated_at: 2023-02-02 08:25:33.355650000 Z
|
||||
|
||||
notification_type_3:
|
||||
id: 3
|
||||
name: 'notify_dev_when_storming'
|
||||
category: 'meteo'
|
||||
name: notify_project_author_when_collaborator_valid
|
||||
category: projects
|
||||
is_configurable: true
|
||||
created_at: 2023-02-02 15:25:13.744539000 Z
|
||||
updated_at: 2023-02-02 15:25:13.744539000 Z
|
||||
created_at: 2023-02-02 08:25:33.357169000 Z
|
||||
updated_at: 2023-02-02 08:25:33.357169000 Z
|
||||
|
||||
notification_type_4:
|
||||
id: 4
|
||||
name: 'notify_dev_when_tsunami'
|
||||
category: 'meteo'
|
||||
name: notify_user_training_valid
|
||||
category: trainings
|
||||
is_configurable: false
|
||||
created_at: 2023-02-02 15:25:30.321953000 Z
|
||||
updated_at: 2023-02-02 15:25:30.321953000 Z
|
||||
created_at: 2023-02-02 08:25:33.358562000 Z
|
||||
updated_at: 2023-02-02 08:25:33.358562000 Z
|
||||
|
||||
notification_type_5:
|
||||
id: 5
|
||||
name: notify_member_subscribed_plan
|
||||
category: subscriptions
|
||||
is_configurable: false
|
||||
created_at: 2023-02-02 08:25:33.359933000 Z
|
||||
updated_at: 2023-02-02 08:25:33.359933000 Z
|
||||
|
||||
notification_type_6:
|
||||
id: 6
|
||||
name: notify_member_create_reservation
|
||||
category: agenda
|
||||
is_configurable: false
|
||||
created_at: 2023-02-02 08:25:33.361468000 Z
|
||||
updated_at: 2023-02-02 08:25:33.361468000 Z
|
||||
|
||||
notification_type_7:
|
||||
id: 7
|
||||
name: notify_member_subscribed_plan_is_changed
|
||||
category: deprecated
|
||||
is_configurable: false
|
||||
created_at: 2023-02-02 08:25:33.362858000 Z
|
||||
updated_at: 2023-02-02 08:25:33.362858000 Z
|
||||
|
||||
notification_type_8:
|
||||
id: 8
|
||||
name: notify_admin_member_create_reservation
|
||||
category: agenda
|
||||
is_configurable: true
|
||||
created_at: 2023-02-02 08:25:33.366800000 Z
|
||||
updated_at: 2023-02-02 08:25:33.366800000 Z
|
||||
|
||||
notification_type_9:
|
||||
id: 9
|
||||
name: notify_member_slot_is_modified
|
||||
category: agenda
|
||||
is_configurable: false
|
||||
created_at: 2023-02-02 08:25:33.368308000 Z
|
||||
updated_at: 2023-02-02 08:25:33.368308000 Z
|
||||
|
||||
notification_type_10:
|
||||
id: 10
|
||||
name: notify_admin_slot_is_modified
|
||||
category: agenda
|
||||
is_configurable: true
|
||||
created_at: 2023-02-02 08:25:33.369576000 Z
|
||||
updated_at: 2023-02-02 08:25:33.369576000 Z
|
||||
|
||||
notification_type_11:
|
||||
id: 11
|
||||
name: notify_admin_when_user_is_created
|
||||
category: users_accounts
|
||||
is_configurable: true
|
||||
created_at: 2023-02-02 08:25:33.370910000 Z
|
||||
updated_at: 2023-02-02 08:25:33.370910000 Z
|
||||
|
||||
notification_type_12:
|
||||
id: 12
|
||||
name: notify_admin_subscribed_plan
|
||||
category: subscriptions
|
||||
is_configurable: true
|
||||
created_at: 2023-02-02 08:25:33.372202000 Z
|
||||
updated_at: 2023-02-02 08:25:33.372202000 Z
|
||||
|
||||
notification_type_13:
|
||||
id: 13
|
||||
name: notify_user_when_invoice_ready
|
||||
category: payments
|
||||
is_configurable: true
|
||||
created_at: 2023-02-02 08:25:33.373802000 Z
|
||||
updated_at: 2023-02-02 08:25:33.373802000 Z
|
||||
|
||||
notification_type_14:
|
||||
id: 14
|
||||
name: notify_member_subscription_will_expire_in_7_days
|
||||
category: subscriptions
|
||||
is_configurable: false
|
||||
created_at: 2023-02-02 08:25:33.374910000 Z
|
||||
updated_at: 2023-02-02 08:25:33.374910000 Z
|
||||
|
||||
notification_type_15:
|
||||
id: 15
|
||||
name: notify_member_subscription_is_expired
|
||||
category: subscriptions
|
||||
is_configurable: false
|
||||
created_at: 2023-02-02 08:25:33.376101000 Z
|
||||
updated_at: 2023-02-02 08:25:33.376101000 Z
|
||||
|
||||
notification_type_16:
|
||||
id: 16
|
||||
name: notify_admin_subscription_will_expire_in_7_days
|
||||
category: subscriptions
|
||||
is_configurable: true
|
||||
created_at: 2023-02-02 08:25:33.377294000 Z
|
||||
updated_at: 2023-02-02 08:25:33.377294000 Z
|
||||
|
||||
notification_type_17:
|
||||
id: 17
|
||||
name: notify_admin_subscription_is_expired
|
||||
category: subscriptions
|
||||
is_configurable: true
|
||||
created_at: 2023-02-02 08:25:33.385681000 Z
|
||||
updated_at: 2023-02-02 08:25:33.385681000 Z
|
||||
|
||||
notification_type_18:
|
||||
id: 18
|
||||
name: notify_admin_subscription_canceled
|
||||
category: subscriptions
|
||||
is_configurable: true
|
||||
created_at: 2023-02-02 08:25:33.386650000 Z
|
||||
updated_at: 2023-02-02 08:25:33.386650000 Z
|
||||
|
||||
notification_type_19:
|
||||
id: 19
|
||||
name: notify_member_subscription_canceled
|
||||
category: subscriptions
|
||||
is_configurable: false
|
||||
created_at: 2023-02-02 08:25:33.387317000 Z
|
||||
updated_at: 2023-02-02 08:25:33.387317000 Z
|
||||
|
||||
notification_type_20:
|
||||
id: 20
|
||||
name: notify_user_when_avoir_ready
|
||||
category: wallet
|
||||
is_configurable: false
|
||||
created_at: 2023-02-02 08:25:33.387952000 Z
|
||||
updated_at: 2023-02-02 08:25:33.387952000 Z
|
||||
|
||||
notification_type_21:
|
||||
id: 21
|
||||
name: notify_member_slot_is_canceled
|
||||
category: agenda
|
||||
is_configurable: false
|
||||
created_at: 2023-02-02 08:25:33.388799000 Z
|
||||
updated_at: 2023-02-02 08:25:33.388799000 Z
|
||||
|
||||
notification_type_22:
|
||||
id: 22
|
||||
name: notify_admin_slot_is_canceled
|
||||
category: agenda
|
||||
is_configurable: true
|
||||
created_at: 2023-02-02 08:25:33.389610000 Z
|
||||
updated_at: 2023-02-02 08:25:33.389610000 Z
|
||||
|
||||
notification_type_23:
|
||||
id: 23
|
||||
name: notify_partner_subscribed_plan
|
||||
category: subscriptions
|
||||
is_configurable: false
|
||||
created_at: 2023-02-02 08:25:33.390409000 Z
|
||||
updated_at: 2023-02-02 08:25:33.390409000 Z
|
||||
|
||||
notification_type_24:
|
||||
id: 24
|
||||
name: notify_member_subscription_extended
|
||||
category: subscriptions
|
||||
is_configurable: false
|
||||
created_at: 2023-02-02 08:25:33.391438000 Z
|
||||
updated_at: 2023-02-02 08:25:33.391438000 Z
|
||||
|
||||
notification_type_25:
|
||||
id: 25
|
||||
name: notify_admin_subscription_extended
|
||||
category: subscriptions
|
||||
is_configurable: true
|
||||
created_at: 2023-02-02 08:25:33.392302000 Z
|
||||
updated_at: 2023-02-02 08:25:33.392302000 Z
|
||||
|
||||
notification_type_26:
|
||||
id: 26
|
||||
name: notify_admin_user_group_changed
|
||||
category: users_accounts
|
||||
is_configurable: true
|
||||
created_at: 2023-02-02 08:25:33.393157000 Z
|
||||
updated_at: 2023-02-02 08:25:33.393157000 Z
|
||||
|
||||
notification_type_27:
|
||||
id: 27
|
||||
name: notify_user_user_group_changed
|
||||
category: users_accounts
|
||||
is_configurable: false
|
||||
created_at: 2023-02-02 08:25:33.394006000 Z
|
||||
updated_at: 2023-02-02 08:25:33.394006000 Z
|
||||
|
||||
notification_type_28:
|
||||
id: 28
|
||||
name: notify_admin_when_user_is_imported
|
||||
category: users_accounts
|
||||
is_configurable: true
|
||||
created_at: 2023-02-02 08:25:33.394864000 Z
|
||||
updated_at: 2023-02-02 08:25:33.394864000 Z
|
||||
|
||||
notification_type_29:
|
||||
id: 29
|
||||
name: notify_user_profile_complete
|
||||
category: users_accounts
|
||||
is_configurable: false
|
||||
created_at: 2023-02-02 08:25:33.395686000 Z
|
||||
updated_at: 2023-02-02 08:25:33.395686000 Z
|
||||
|
||||
notification_type_30:
|
||||
id: 30
|
||||
name: notify_user_auth_migration
|
||||
category: user
|
||||
is_configurable: false
|
||||
created_at: 2023-02-02 08:25:33.396685000 Z
|
||||
updated_at: 2023-02-02 08:25:33.396685000 Z
|
||||
|
||||
notification_type_31:
|
||||
id: 31
|
||||
name: notify_admin_user_merged
|
||||
category: users_accounts
|
||||
is_configurable: true
|
||||
created_at: 2023-02-02 08:25:33.397530000 Z
|
||||
updated_at: 2023-02-02 08:25:33.397530000 Z
|
||||
|
||||
notification_type_32:
|
||||
id: 32
|
||||
name: notify_admin_profile_complete
|
||||
category: users_accounts
|
||||
is_configurable: true
|
||||
created_at: 2023-02-02 08:25:33.398364000 Z
|
||||
updated_at: 2023-02-02 08:25:33.398364000 Z
|
||||
|
||||
notification_type_33:
|
||||
id: 33
|
||||
name: notify_admin_abuse_reported
|
||||
category: projects
|
||||
is_configurable: true
|
||||
created_at: 2023-02-02 08:25:33.399230000 Z
|
||||
updated_at: 2023-02-02 08:25:33.399230000 Z
|
||||
|
||||
notification_type_34:
|
||||
id: 34
|
||||
name: notify_admin_invoicing_changed
|
||||
category: deprecated
|
||||
is_configurable: false
|
||||
created_at: 2023-02-02 08:25:33.400213000 Z
|
||||
updated_at: 2023-02-02 08:25:33.400213000 Z
|
||||
|
||||
notification_type_35:
|
||||
id: 35
|
||||
name: notify_user_wallet_is_credited
|
||||
category: wallet
|
||||
is_configurable: false
|
||||
created_at: 2023-02-02 08:25:33.401163000 Z
|
||||
updated_at: 2023-02-02 08:25:33.401163000 Z
|
||||
|
||||
notification_type_36:
|
||||
id: 36
|
||||
name: notify_admin_user_wallet_is_credited
|
||||
category: wallet
|
||||
is_configurable: true
|
||||
created_at: 2023-02-02 08:25:33.402912000 Z
|
||||
updated_at: 2023-02-02 08:25:33.402912000 Z
|
||||
|
||||
notification_type_37:
|
||||
id: 37
|
||||
name: notify_admin_export_complete
|
||||
category: exports
|
||||
is_configurable: false
|
||||
created_at: 2023-02-02 08:25:33.403710000 Z
|
||||
updated_at: 2023-02-02 08:25:33.403710000 Z
|
||||
|
||||
notification_type_38:
|
||||
id: 38
|
||||
name: notify_member_about_coupon
|
||||
category: agenda
|
||||
is_configurable: false
|
||||
created_at: 2023-02-02 08:25:33.405757000 Z
|
||||
updated_at: 2023-02-02 08:25:33.405757000 Z
|
||||
|
||||
notification_type_39:
|
||||
id: 39
|
||||
name: notify_member_reservation_reminder
|
||||
category: agenda
|
||||
is_configurable: false
|
||||
created_at: 2023-02-02 08:25:33.414402000 Z
|
||||
updated_at: 2023-02-02 08:25:33.414402000 Z
|
||||
|
||||
notification_type_40:
|
||||
id: 40
|
||||
name: notify_admin_free_disk_space
|
||||
category: app_management
|
||||
is_configurable: false
|
||||
created_at: 2023-02-02 08:25:33.415557000 Z
|
||||
updated_at: 2023-02-02 08:25:33.415557000 Z
|
||||
|
||||
notification_type_41:
|
||||
id: 41
|
||||
name: notify_admin_close_period_reminder
|
||||
category: accountings
|
||||
is_configurable: true
|
||||
created_at: 2023-02-02 08:25:33.420521000 Z
|
||||
updated_at: 2023-02-02 08:25:33.420521000 Z
|
||||
|
||||
notification_type_42:
|
||||
id: 42
|
||||
name: notify_admin_archive_complete
|
||||
category: accountings
|
||||
is_configurable: true
|
||||
created_at: 2023-02-02 08:25:33.423553000 Z
|
||||
updated_at: 2023-02-02 08:25:33.423553000 Z
|
||||
|
||||
notification_type_43:
|
||||
id: 43
|
||||
name: notify_privacy_policy_changed
|
||||
category: app_management
|
||||
is_configurable: false
|
||||
created_at: 2023-02-02 08:25:33.424521000 Z
|
||||
updated_at: 2023-02-02 08:25:33.424521000 Z
|
||||
|
||||
notification_type_44:
|
||||
id: 44
|
||||
name: notify_admin_import_complete
|
||||
category: app_management
|
||||
is_configurable: false
|
||||
created_at: 2023-02-02 08:25:33.425438000 Z
|
||||
updated_at: 2023-02-02 08:25:33.425438000 Z
|
||||
|
||||
notification_type_45:
|
||||
id: 45
|
||||
name: notify_admin_refund_created
|
||||
category: wallet
|
||||
is_configurable: true
|
||||
created_at: 2023-02-02 08:25:33.426178000 Z
|
||||
updated_at: 2023-02-02 08:25:33.426178000 Z
|
||||
|
||||
notification_type_46:
|
||||
id: 46
|
||||
name: notify_admins_role_update
|
||||
category: users_accounts
|
||||
is_configurable: true
|
||||
created_at: 2023-02-02 08:25:33.426875000 Z
|
||||
updated_at: 2023-02-02 08:25:33.426875000 Z
|
||||
|
||||
notification_type_47:
|
||||
id: 47
|
||||
name: notify_user_role_update
|
||||
category: users_accounts
|
||||
is_configurable: false
|
||||
created_at: 2023-02-02 08:25:33.427568000 Z
|
||||
updated_at: 2023-02-02 08:25:33.427568000 Z
|
||||
|
||||
notification_type_48:
|
||||
id: 48
|
||||
name: notify_admin_objects_stripe_sync
|
||||
category: payments
|
||||
is_configurable: false
|
||||
created_at: 2023-02-02 08:25:33.428271000 Z
|
||||
updated_at: 2023-02-02 08:25:33.428271000 Z
|
||||
|
||||
notification_type_49:
|
||||
id: 49
|
||||
name: notify_user_when_payment_schedule_ready
|
||||
category: payments
|
||||
is_configurable: false
|
||||
created_at: 2023-02-02 08:25:33.429059000 Z
|
||||
updated_at: 2023-02-02 08:25:33.429059000 Z
|
||||
|
||||
notification_type_50:
|
||||
id: 50
|
||||
name: notify_admin_payment_schedule_failed
|
||||
category: payments
|
||||
is_configurable: true
|
||||
created_at: 2023-02-02 08:25:33.429758000 Z
|
||||
updated_at: 2023-02-02 08:25:33.429758000 Z
|
||||
|
||||
notification_type_51:
|
||||
id: 51
|
||||
name: notify_member_payment_schedule_failed
|
||||
category: payments
|
||||
is_configurable: false
|
||||
created_at: 2023-02-02 08:25:33.430469000 Z
|
||||
updated_at: 2023-02-02 08:25:33.430469000 Z
|
||||
|
||||
notification_type_52:
|
||||
id: 52
|
||||
name: notify_admin_payment_schedule_check_deadline
|
||||
category: payments
|
||||
is_configurable: true
|
||||
created_at: 2023-02-02 08:25:33.431174000 Z
|
||||
updated_at: 2023-02-02 08:25:33.431174000 Z
|
||||
|
||||
notification_type_53:
|
||||
id: 53
|
||||
name: notify_admin_payment_schedule_transfer_deadline
|
||||
category: payments
|
||||
is_configurable: true
|
||||
created_at: 2023-02-02 08:25:33.431950000 Z
|
||||
updated_at: 2023-02-02 08:25:33.431950000 Z
|
||||
|
||||
notification_type_54:
|
||||
id: 54
|
||||
name: notify_admin_payment_schedule_error
|
||||
category: payments
|
||||
is_configurable: true
|
||||
created_at: 2023-02-02 08:25:33.432809000 Z
|
||||
updated_at: 2023-02-02 08:25:33.432809000 Z
|
||||
|
||||
notification_type_55:
|
||||
id: 55
|
||||
name: notify_member_payment_schedule_error
|
||||
category: payments
|
||||
is_configurable: false
|
||||
created_at: 2023-02-02 08:25:33.433749000 Z
|
||||
updated_at: 2023-02-02 08:25:33.433749000 Z
|
||||
|
||||
notification_type_56:
|
||||
id: 56
|
||||
name: notify_admin_payment_schedule_gateway_canceled
|
||||
category: payments
|
||||
is_configurable: true
|
||||
created_at: 2023-02-02 08:25:33.434479000 Z
|
||||
updated_at: 2023-02-02 08:25:33.434479000 Z
|
||||
|
||||
notification_type_57:
|
||||
id: 57
|
||||
name: notify_member_payment_schedule_gateway_canceled
|
||||
category: payments
|
||||
is_configurable: false
|
||||
created_at: 2023-02-02 08:25:33.435161000 Z
|
||||
updated_at: 2023-02-02 08:25:33.435161000 Z
|
||||
|
||||
notification_type_58:
|
||||
id: 58
|
||||
name: notify_admin_user_proof_of_identity_files_created
|
||||
category: proof_of_identity
|
||||
is_configurable: true
|
||||
created_at: 2023-02-02 08:25:33.435886000 Z
|
||||
updated_at: 2023-02-02 08:25:33.435886000 Z
|
||||
|
||||
notification_type_59:
|
||||
id: 59
|
||||
name: notify_admin_user_proof_of_identity_files_updated
|
||||
category: proof_of_identity
|
||||
is_configurable: true
|
||||
created_at: 2023-02-02 08:25:33.436627000 Z
|
||||
updated_at: 2023-02-02 08:25:33.436627000 Z
|
||||
|
||||
notification_type_60:
|
||||
id: 60
|
||||
name: notify_user_is_validated
|
||||
category: users_accounts
|
||||
is_configurable: false
|
||||
created_at: 2023-02-02 08:25:33.437360000 Z
|
||||
updated_at: 2023-02-02 08:25:33.437360000 Z
|
||||
|
||||
notification_type_61:
|
||||
id: 61
|
||||
name: notify_user_is_invalidated
|
||||
category: users_accounts
|
||||
is_configurable: false
|
||||
created_at: 2023-02-02 08:25:33.438226000 Z
|
||||
updated_at: 2023-02-02 08:25:33.438226000 Z
|
||||
|
||||
notification_type_62:
|
||||
id: 62
|
||||
name: notify_user_proof_of_identity_refusal
|
||||
category: proof_of_identity
|
||||
is_configurable: false
|
||||
created_at: 2023-02-02 08:25:33.439078000 Z
|
||||
updated_at: 2023-02-02 08:25:33.439078000 Z
|
||||
|
||||
notification_type_63:
|
||||
id: 63
|
||||
name: notify_admin_user_proof_of_identity_refusal
|
||||
category: proof_of_identity
|
||||
is_configurable: true
|
||||
created_at: 2023-02-02 08:25:33.439926000 Z
|
||||
updated_at: 2023-02-02 08:25:33.439926000 Z
|
||||
|
||||
notification_type_64:
|
||||
id: 64
|
||||
name: notify_user_order_is_ready
|
||||
category: shop
|
||||
is_configurable: true
|
||||
created_at: 2023-02-02 08:25:33.440769000 Z
|
||||
updated_at: 2023-02-02 08:25:33.440769000 Z
|
||||
|
||||
notification_type_65:
|
||||
id: 65
|
||||
name: notify_user_order_is_canceled
|
||||
category: shop
|
||||
is_configurable: true
|
||||
created_at: 2023-02-02 08:25:33.441630000 Z
|
||||
updated_at: 2023-02-02 08:25:33.441630000 Z
|
||||
|
||||
notification_type_66:
|
||||
id: 66
|
||||
name: notify_user_order_is_refunded
|
||||
category: shop
|
||||
is_configurable: true
|
||||
created_at: 2023-02-02 08:25:33.442370000 Z
|
||||
updated_at: 2023-02-02 08:25:33.442370000 Z
|
||||
|
||||
notification_type_67:
|
||||
id: 67
|
||||
name: notify_admin_low_stock_threshold
|
||||
category: shop
|
||||
is_configurable: true
|
||||
created_at: 2023-02-02 08:25:33.443101000 Z
|
||||
updated_at: 2023-02-02 08:25:33.443101000 Z
|
||||
|
||||
notification_type_68:
|
||||
id: 68
|
||||
name: notify_admin_training_auto_cancelled
|
||||
category: trainings
|
||||
is_configurable: true
|
||||
created_at: 2023-02-02 08:25:33.443888000 Z
|
||||
updated_at: 2023-02-02 08:25:33.443888000 Z
|
||||
|
94
test/fixtures/notifications.yml
vendored
94
test/fixtures/notifications.yml
vendored
@ -1,17 +1,3 @@
|
||||
|
||||
notification_7:
|
||||
id: 7
|
||||
receiver_id: 1
|
||||
attached_object_id: 1
|
||||
attached_object_type: Project
|
||||
notification_type_id: 1
|
||||
is_read: false
|
||||
created_at: 2016-04-04 15:39:08.273215000 Z
|
||||
updated_at: 2016-04-04 15:39:08.273215000 Z
|
||||
receiver_type: User
|
||||
is_send: true
|
||||
meta_data: {}
|
||||
|
||||
notification_1:
|
||||
id: 1
|
||||
receiver_id: 1
|
||||
@ -90,6 +76,45 @@ notification_6:
|
||||
is_send: true
|
||||
meta_data: {}
|
||||
|
||||
notification_7:
|
||||
id: 7
|
||||
receiver_id: 1
|
||||
attached_object_id: 1
|
||||
attached_object_type: Project
|
||||
notification_type_id: 1
|
||||
is_read: false
|
||||
created_at: 2016-04-04 15:39:08.273215000 Z
|
||||
updated_at: 2016-04-04 15:39:08.273215000 Z
|
||||
receiver_type: User
|
||||
is_send: true
|
||||
meta_data: {}
|
||||
|
||||
notification_8:
|
||||
id: 8
|
||||
receiver_id: 3
|
||||
attached_object_id: 1
|
||||
attached_object_type: Subscription
|
||||
notification_type_id: 5
|
||||
is_read: false
|
||||
created_at: 2016-04-05 08:35:51.792984000 Z
|
||||
updated_at: 2016-04-05 08:35:51.792984000 Z
|
||||
receiver_type: User
|
||||
is_send: true
|
||||
meta_data: {}
|
||||
|
||||
notification_9:
|
||||
id: 9
|
||||
receiver_id: 1
|
||||
attached_object_id: 1
|
||||
attached_object_type: Subscription
|
||||
notification_type_id: 12
|
||||
is_read: false
|
||||
created_at: 2016-04-05 08:35:51.837022000 Z
|
||||
updated_at: 2016-04-05 08:35:51.837022000 Z
|
||||
receiver_type: User
|
||||
is_send: true
|
||||
meta_data: {}
|
||||
|
||||
notification_10:
|
||||
id: 10
|
||||
receiver_id: 6
|
||||
@ -116,15 +141,15 @@ notification_11:
|
||||
is_send: true
|
||||
meta_data: {}
|
||||
|
||||
notification_9:
|
||||
id: 9
|
||||
receiver_id: 1
|
||||
attached_object_id: 1
|
||||
notification_12:
|
||||
id: 12
|
||||
receiver_id: 4
|
||||
attached_object_id: 2
|
||||
attached_object_type: Subscription
|
||||
notification_type_id: 12
|
||||
notification_type_id: 5
|
||||
is_read: false
|
||||
created_at: 2016-04-05 08:35:51.837022000 Z
|
||||
updated_at: 2016-04-05 08:35:51.837022000 Z
|
||||
created_at: 2016-04-05 08:36:46.833829000 Z
|
||||
updated_at: 2016-04-05 08:36:46.833829000 Z
|
||||
receiver_type: User
|
||||
is_send: true
|
||||
meta_data: {}
|
||||
@ -155,28 +180,15 @@ notification_14:
|
||||
is_send: true
|
||||
meta_data: {}
|
||||
|
||||
notification_8:
|
||||
id: 8
|
||||
receiver_id: 3
|
||||
attached_object_id: 1
|
||||
attached_object_type: Subscription
|
||||
notification_type_id: 5
|
||||
is_read: false
|
||||
created_at: 2016-04-05 08:35:51.792984000 Z
|
||||
updated_at: 2016-04-05 08:35:51.792984000 Z
|
||||
receiver_type: User
|
||||
is_send: true
|
||||
meta_data: {}
|
||||
|
||||
notification_12:
|
||||
id: 12
|
||||
receiver_id: 4
|
||||
notification_15:
|
||||
id: 15
|
||||
receiver_id: 1
|
||||
attached_object_id: 2
|
||||
attached_object_type: Subscription
|
||||
notification_type_id: 5
|
||||
attached_object_type: Invoice
|
||||
notification_type_id: 13
|
||||
is_read: false
|
||||
created_at: 2016-04-05 08:36:46.833829000 Z
|
||||
updated_at: 2016-04-05 08:36:46.833829000 Z
|
||||
created_at: 2016-04-05 08:36:47.235854000 Z
|
||||
updated_at: 2016-04-05 08:36:47.235854000 Z
|
||||
receiver_type: User
|
||||
is_send: true
|
||||
meta_data: {}
|
||||
|
@ -27,7 +27,7 @@ class NotificationPreferencesTest < ActionDispatch::IntegrationTest
|
||||
notification_preference: {
|
||||
id: 1,
|
||||
user_id: 1,
|
||||
notification_type: 'notify_dev_when_sun_shines',
|
||||
notification_type: 'notify_admin_when_project_published',
|
||||
in_system: false,
|
||||
email: false
|
||||
}
|
||||
@ -41,7 +41,9 @@ class NotificationPreferencesTest < ActionDispatch::IntegrationTest
|
||||
# Check the status was updated
|
||||
res = json_response(response.body)
|
||||
assert_equal 1, res[:id]
|
||||
assert_equal 'notify_dev_when_sun_shines', res[:notification_type]
|
||||
assert_equal 'notify_admin_when_project_published', res[:notification_type]
|
||||
assert_equal false, res[:in_system]
|
||||
assert_equal false, res[:email]
|
||||
end
|
||||
|
||||
test 'bulk update notification preference' do
|
||||
@ -51,14 +53,14 @@ class NotificationPreferencesTest < ActionDispatch::IntegrationTest
|
||||
{
|
||||
id: 1,
|
||||
user_id: 1,
|
||||
notification_type: 'notify_dev_when_sun_shines',
|
||||
notification_type: 'notify_admin_when_project_published',
|
||||
in_system: false,
|
||||
email: false
|
||||
},
|
||||
{
|
||||
id: 2,
|
||||
user_id: 1,
|
||||
notification_type: 'notify_dev_when_raining',
|
||||
notification_type: 'notify_project_collaborator_to_valid',
|
||||
in_system: false,
|
||||
email: false
|
||||
}
|
||||
|
104
test/integration/notifications/notifications_test.rb
Normal file
104
test/integration/notifications/notifications_test.rb
Normal file
@ -0,0 +1,104 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require 'test_helper'
|
||||
|
||||
class NotificationsTest < ActionDispatch::IntegrationTest
|
||||
test 'Index lists all notifications if user has no notifications preferences' do
|
||||
@member = User.find(4)
|
||||
login_as(@member, scope: :user)
|
||||
|
||||
get '/api/notifications'
|
||||
|
||||
# Check response format & status
|
||||
assert_equal 200, response.status, response.body
|
||||
assert_equal Mime[:json], response.content_type
|
||||
|
||||
# Check the list items are ok
|
||||
# ! Only works if notifications fixtures for this user are < NOTIFICATIONS_PER_PAGE (See NotificationsController#index)
|
||||
notifications_total = json_response(response.body)[:totals][:total]
|
||||
|
||||
assert_not_equal notifications.count, 0
|
||||
assert_equal Notification.where(receiver_id: @member.id).count, notifications_total
|
||||
end
|
||||
|
||||
test 'Index filters notifications if user has preferences for in_system notifications set to false' do
|
||||
@admin = User.find_by(username: 'admin')
|
||||
login_as(@admin, scope: :user)
|
||||
|
||||
get '/api/notifications'
|
||||
|
||||
# Check response format & status
|
||||
assert_equal 200, response.status, response.body
|
||||
assert_equal Mime[:json], response.content_type
|
||||
|
||||
# Check the list items are ok
|
||||
notifications_total = json_response(response.body)[:totals][:total]
|
||||
assert_not_equal notifications.count, 0
|
||||
|
||||
assert_equal NotificationPreference.where(user_id: @admin.id, in_system: false).count, 1
|
||||
assert_equal (Notification.where(receiver_id: @admin.id).count - 1), notifications_total
|
||||
end
|
||||
|
||||
test 'Last unread returns last 3 unread notifications' do
|
||||
@member = User.find(4)
|
||||
login_as(@member, scope: :user)
|
||||
|
||||
transaction1 = WalletService.new(user: @member, wallet: @member.wallet).credit(1)
|
||||
transaction2 = WalletService.new(user: @member, wallet: @member.wallet).credit(2)
|
||||
transaction3 = WalletService.new(user: @member, wallet: @member.wallet).credit(4)
|
||||
|
||||
get '/api/notifications/last_unread'
|
||||
|
||||
# Check response format & status
|
||||
assert_equal 200, response.status, response.body
|
||||
assert_equal Mime[:json], response.content_type
|
||||
|
||||
# Check the list items are ok
|
||||
# Beware that the order of last unread notifications is descending,
|
||||
# Since the last created will be the first to appear.
|
||||
last_notifications = json_response(response.body)[:notifications]
|
||||
assert_equal last_notifications[0][:attached_object][:id], transaction3.id
|
||||
assert_equal last_notifications[1][:attached_object][:id], transaction2.id
|
||||
assert_equal last_notifications[2][:attached_object][:id], transaction1.id
|
||||
end
|
||||
|
||||
test 'update marks a notification as read' do
|
||||
@member = User.find(4)
|
||||
login_as(@member, scope: :user)
|
||||
|
||||
transaction = WalletService.new(user: @member, wallet: @member.wallet).credit(1)
|
||||
|
||||
notification = Notification.where(receiver_id: @member.id).last
|
||||
puts notification.receiver_id
|
||||
assert_equal notification.attached_object_id, transaction.id
|
||||
assert_equal notification.is_read, false
|
||||
|
||||
patch "/api/notifications/#{notification.id}"
|
||||
|
||||
# Check response format & status
|
||||
assert_equal 200, response.status, response.body
|
||||
assert_equal Mime[:json], response.content_type
|
||||
|
||||
# Check the list items are ok
|
||||
updated_notification = json_response(response.body)
|
||||
|
||||
assert_equal updated_notification[:attached_object][:id], transaction.id
|
||||
assert_equal updated_notification[:is_read], true
|
||||
end
|
||||
|
||||
test 'update_all marks all notification as read' do
|
||||
@admin = User.find_by(username: 'admin')
|
||||
login_as(@admin, scope: :user)
|
||||
|
||||
patch '/api/notifications'
|
||||
|
||||
# Check response format & status
|
||||
assert_equal 204, response.status, response.body
|
||||
|
||||
notifications = Notification.where(receiver_id: @admin.id)
|
||||
|
||||
notifications.each do |notification|
|
||||
assert_equal true, notification.is_read
|
||||
end
|
||||
end
|
||||
end
|
Loading…
x
Reference in New Issue
Block a user