From fbf10700b69b5dca30e16e1c17cf3b175d9780b7 Mon Sep 17 00:00:00 2001 From: lodewiges <131907615+lodewiges@users.noreply.github.com> Date: Mon, 11 Nov 2024 16:46:12 +0100 Subject: [PATCH 1/9] Implementing a button for Presence in the 2de kamer (#449) * intial commit * Remove a mistake from permissions.rb * added migration file * Fixed lint --- .../v1/study_room_presences_controller.rb | 2 + app/models/study_room_presence.rb | 20 ++++ app/models/user.rb | 5 +- app/policies/study_room_presence_policy.rb | 2 + .../v1/study_room_presence_resource.rb | 17 +++ config/routes.rb | 1 + ...241027103012_create_study_room_presence.rb | 17 +++ db/schema.rb | 13 +- db/seeds/content.rb | 4 + db/seeds/permissions.rb | 3 + spec/factories/study_room_presences.rb | 11 ++ spec/jobs/user_archive_job_spec.rb | 2 + spec/models/study_room_presence_spec.rb | 112 ++++++++++++++++++ .../create_spec.rb | 12 ++ .../destroy_spec.rb | 11 ++ .../index_spec.rb | 13 ++ .../show_spec.rb | 12 ++ .../update_spec.rb | 12 ++ 18 files changed, 265 insertions(+), 4 deletions(-) create mode 100644 app/controllers/v1/study_room_presences_controller.rb create mode 100644 app/models/study_room_presence.rb create mode 100644 app/policies/study_room_presence_policy.rb create mode 100644 app/resources/v1/study_room_presence_resource.rb create mode 100644 db/migrate/20241027103012_create_study_room_presence.rb create mode 100644 spec/factories/study_room_presences.rb create mode 100644 spec/models/study_room_presence_spec.rb create mode 100644 spec/requests/v1/study_room_presence_controller/create_spec.rb create mode 100644 spec/requests/v1/study_room_presence_controller/destroy_spec.rb create mode 100644 spec/requests/v1/study_room_presence_controller/index_spec.rb create mode 100644 spec/requests/v1/study_room_presence_controller/show_spec.rb create mode 100644 spec/requests/v1/study_room_presence_controller/update_spec.rb diff --git a/app/controllers/v1/study_room_presences_controller.rb b/app/controllers/v1/study_room_presences_controller.rb new file mode 100644 index 00000000..ec82c76c --- /dev/null +++ b/app/controllers/v1/study_room_presences_controller.rb @@ -0,0 +1,2 @@ +class V1::StudyRoomPresencesController < V1::ApplicationController +end diff --git a/app/models/study_room_presence.rb b/app/models/study_room_presence.rb new file mode 100644 index 00000000..a6ae4ecc --- /dev/null +++ b/app/models/study_room_presence.rb @@ -0,0 +1,20 @@ +class StudyRoomPresence < ApplicationRecord + belongs_to :user + + validates :start_time, presence: true + validates :end_time, presence: true + validates_datetime :end_time, after: :start_time + validates :status, inclusion: { in: %w[chilling studying banaan] } + + scope :current, (lambda { + where('start_time <= :current_time AND end_time >= :current_time', + current_time: Time.current) + }) + scope :future, (lambda { + where('start_time >= :current_time', current_time: Time.current) + }) + scope :current_and_future, (lambda { + where('(start_time <= :current_time AND end_time >= :current_time) +or (start_time >= :current_time)', current_time: Time.current) + }) +end diff --git a/app/models/user.rb b/app/models/user.rb index 500c4ca9..d5029281 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -16,6 +16,7 @@ class User < ApplicationRecord # rubocop:disable Metrics/ClassLength has_many :user_permissions, through: :permissions_users, source: :permission has_many :article_comments, foreign_key: :author_id has_many :board_room_presences, dependent: :delete_all + has_many :study_room_presences, dependent: :delete_all has_many :photo_comments, foreign_key: :author_id has_many :created_photo_tags, class_name: 'PhotoTag', foreign_key: :author_id, dependent: :delete_all @@ -214,8 +215,8 @@ def allow_tomato_sharing_valid? return unless allow_tomato_sharing_changed?(from: true, to: false) errors.add(:allow_tomato_sharing, - 'before being removed from tomato your credits needs to be zero. - Please ask the board to be removed from tomato.') + 'before being removed from sofia your credits needs to be zero. + Please ask the board to be removed from sofia.') end def generate_ical_secret_key diff --git a/app/policies/study_room_presence_policy.rb b/app/policies/study_room_presence_policy.rb new file mode 100644 index 00000000..bfc78ee2 --- /dev/null +++ b/app/policies/study_room_presence_policy.rb @@ -0,0 +1,2 @@ +class StudyRoomPresencePolicy < ApplicationPolicy +end diff --git a/app/resources/v1/study_room_presence_resource.rb b/app/resources/v1/study_room_presence_resource.rb new file mode 100644 index 00000000..c2e7d00d --- /dev/null +++ b/app/resources/v1/study_room_presence_resource.rb @@ -0,0 +1,17 @@ +class V1::StudyRoomPresenceResource < V1::ApplicationResource + attributes :start_time, :end_time, :status + + has_one :user, always_include_linkage_data: true + + filter :current, apply: ->(records, _value, _options) { records.current } + filter :future, apply: ->(records, _value, _options) { records.future } + filter :current_and_future, apply: ->(records, _value, _options) { records.current_and_future } + + before_create do + @model.user_id = current_user.id + end + + def self.creatable_fields(_context) + %i[start_time end_time status] + end +end diff --git a/config/routes.rb b/config/routes.rb index 20b919f4..d0299850 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -20,6 +20,7 @@ jsonapi_resources :articles jsonapi_resources :article_comments jsonapi_resources :board_room_presences + jsonapi_resources :study_room_presences jsonapi_resources :books do collection do get :isbn_lookup diff --git a/db/migrate/20241027103012_create_study_room_presence.rb b/db/migrate/20241027103012_create_study_room_presence.rb new file mode 100644 index 00000000..d7133dc2 --- /dev/null +++ b/db/migrate/20241027103012_create_study_room_presence.rb @@ -0,0 +1,17 @@ +class CreateStudyRoomPresence < ActiveRecord::Migration[7.0] + def change + create_table :study_room_presences do |t| + t.datetime :start_time, null: false + t.datetime :end_time, null: false + t.text :status, null: false + t.integer :user_id, null: false + t.datetime :deleted_at + t.timestamps + end + end + + Permission.create(name: 'study_room_presence.create') + Permission.create(name: 'study_room_presence.read') + Permission.create(name: 'study_room_presence.update') + Permission.create(name: 'study_room_presence.destroy') +end diff --git a/db/schema.rb b/db/schema.rb index 428b436a..726dbcaf 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -9,8 +9,7 @@ # migrations use external dependencies or application code. # # It's strongly recommended that you check this file into your version control system. - -ActiveRecord::Schema[7.0].define(version: 2024_10_18_155243) do +ActiveRecord::Schema[7.0].define(version: 2024_10_27_103012) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -523,6 +522,16 @@ t.index ["mail_alias_id"], name: "index_stored_mails_on_mail_alias_id" end + create_table "study_room_presences", force: :cascade do |t| + t.datetime "start_time", null: false + t.datetime "end_time", null: false + t.text "status", null: false + t.integer "user_id", null: false + t.datetime "deleted_at" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + end + create_table "users", id: :serial, force: :cascade do |t| t.string "email" t.string "username" diff --git a/db/seeds/content.rb b/db/seeds/content.rb index 856f65f4..2667adc2 100644 --- a/db/seeds/content.rb +++ b/db/seeds/content.rb @@ -1,6 +1,10 @@ # rubocop:disable Style/CombinableLoops members = Group.find_by(name: 'Leden').users +members.sample(4).each do |user| + FactoryBot.create(:study_room_presence, user:) +end + articles = [] members.sample(15).each do |user| articles << FactoryBot.create(:article, author: user, group: nil) diff --git a/db/seeds/permissions.rb b/db/seeds/permissions.rb index 85bb9579..2ecc1586 100644 --- a/db/seeds/permissions.rb +++ b/db/seeds/permissions.rb @@ -24,6 +24,7 @@ def create_permissions(permission_map) 'article' => %i[create read update destroy], 'article_comment' => %i[create read update destroy], 'board_room_presence' => %i[create read update destroy], + 'study_room_presence' => %i[create read update destroy], 'book' => %i[create read update destroy], 'group' => %i[create read update destroy], 'membership' => %i[create read update destroy], @@ -65,6 +66,7 @@ def create_permissions(permission_map) 'article' => %i[create read], 'article_comment' => %i[create read], 'board_room_presence' => %i[read], + 'study_room_presence' => %i[create read], 'book' => %i[read], 'group' => %i[read], 'membership' => %i[read], @@ -101,6 +103,7 @@ def create_permissions(permission_map) 'article' => %i[read], 'article_comment' => %i[create read], 'board_room_presence' => %i[read], + 'study_room_presence' => %i[read], 'book' => [], 'group' => [], 'poll' => [], diff --git a/spec/factories/study_room_presences.rb b/spec/factories/study_room_presences.rb new file mode 100644 index 00000000..31bc0d4b --- /dev/null +++ b/spec/factories/study_room_presences.rb @@ -0,0 +1,11 @@ +FactoryBot.define do + factory :study_room_presence do + start_time { Faker::Time.between(from: 3.days.ago, to: 5.days.ago) } + end_time { Faker::Time.between(from: 10.days.from_now, to: 5.days.from_now) } + status { %w[chilling studying banaan].sample } + user + + trait(:future) { start_time { Faker::Time.between(from: 1.day.from_now, to: 4.days.from_now) } } + trait(:history) { end_time { Faker::Time.between(from: 2.days.ago, to: 1.day.ago) } } + end +end diff --git a/spec/jobs/user_archive_job_spec.rb b/spec/jobs/user_archive_job_spec.rb index 615a4bcd..9eb639df 100644 --- a/spec/jobs/user_archive_job_spec.rb +++ b/spec/jobs/user_archive_job_spec.rb @@ -44,6 +44,7 @@ describe 'other entities are destroyed' do before do create(:board_room_presence, user:) + create(:study_room_presence, user:) create(:mandate, user:) create(:transaction, user:) create(:mail_alias, user:) @@ -53,6 +54,7 @@ end it { expect { job }.to change(BoardRoomPresence, :count).by(-1) } + it { expect { job }.to change(StudyRoomPresence, :count).by(-1) } it { expect { job }.to change(Debit::Mandate, :count).by(-1) } it { expect { job }.to change(Debit::Transaction, :count).by(-1) } it { expect { job }.to change(MailAlias, :count).by(-1) } diff --git a/spec/models/study_room_presence_spec.rb b/spec/models/study_room_presence_spec.rb new file mode 100644 index 00000000..6367f52d --- /dev/null +++ b/spec/models/study_room_presence_spec.rb @@ -0,0 +1,112 @@ +require 'rails_helper' + +RSpec.describe StudyRoomPresence, type: :model do + subject(:study_room_presence) { build_stubbed(:study_room_presence) } + + describe '#valid?' do + it { expect(study_room_presence).to be_valid } + + context 'when without start time' do + subject(:study_room_presence) do + build_stubbed(:study_room_presence, start_time: nil) + end + + it { expect(study_room_presence).not_to be_valid } + end + + context 'when without end time' do + subject(:study_room_presence) do + build_stubbed(:study_room_presence, end_time: nil) + end + + it { expect(study_room_presence).not_to be_valid } + end + + context 'when end time before start time' do + subject(:study_room_presence) do + build_stubbed(:study_room_presence, + end_time: 1.day.ago, start_time: 1.day.from_now) + end + + it { expect(study_room_presence).not_to be_valid } + end + + context 'when without status' do + subject(:study_room_presence) { build_stubbed(:study_room_presence, status: nil) } + + it { expect(study_room_presence).not_to be_valid } + end + + context 'when without a user' do + subject(:study_room_presence) { build_stubbed(:study_room_presence, user: nil) } + + it { expect(study_room_presence).not_to be_valid } + end + end + + describe '#current' do + context 'when started in the past and ended in the future' do + before { create(:study_room_presence) } + + it { expect(described_class.current.count).to eq 1 } + end + + context 'when not yet started' do + before { create(:study_room_presence, start_time: 1.minute.from_now) } + + it { expect(described_class.current.count).to eq 0 } + end + + context 'when just ended' do + before { create(:study_room_presence, end_time: 1.second.ago) } + + it { expect(described_class.current.count).to eq 0 } + end + end + + describe '#future' do + context 'when started in the past and ended in the future' do + before { create(:study_room_presence) } + + it { expect(described_class.future.count).to eq 0 } + end + + context 'when not yet started' do + before { create(:study_room_presence, start_time: 1.minute.from_now) } + + it { expect(described_class.future.count).to eq 1 } + end + + context 'when just ended' do + before { create(:study_room_presence, end_time: 1.second.ago) } + + it { expect(described_class.future.count).to eq 0 } + end + end + + describe '#current_and_future' do + context 'when started in the past and ended in the future' do + before { create(:study_room_presence) } + + it { expect(described_class.current_and_future.count).to eq 1 } + end + + context 'when not yet started' do + before { create(:study_room_presence, start_time: 1.minute.from_now) } + + it { expect(described_class.current_and_future.count).to eq 1 } + end + + context 'when just ended' do + before { create(:study_room_presence, end_time: 1.second.ago) } + + it { expect(described_class.current_and_future.count).to eq 0 } + end + + context 'when starting in the future' do + before { create(:study_room_presence, start_time: 1.second.from_now) } + + it { expect(described_class.current_and_future.count).to eq 1 } + end + end +end diff --git a/spec/requests/v1/study_room_presence_controller/create_spec.rb b/spec/requests/v1/study_room_presence_controller/create_spec.rb new file mode 100644 index 00000000..862833a9 --- /dev/null +++ b/spec/requests/v1/study_room_presence_controller/create_spec.rb @@ -0,0 +1,12 @@ +require 'rails_helper' + +describe V1::StudyRoomPresencesController do + describe 'POST /study_room_presences/:id', version: 1 do + it_behaves_like 'a creatable and permissible model' do + let(:record) { build(:study_room_presence) } + let(:record_url) { '/v1/study_room_presences' } + let(:record_permission) { 'study_room_presence.create' } + let(:invalid_attributes) { { status: '' } } + end + end +end diff --git a/spec/requests/v1/study_room_presence_controller/destroy_spec.rb b/spec/requests/v1/study_room_presence_controller/destroy_spec.rb new file mode 100644 index 00000000..ef01b7cf --- /dev/null +++ b/spec/requests/v1/study_room_presence_controller/destroy_spec.rb @@ -0,0 +1,11 @@ +require 'rails_helper' + +describe V1::StudyRoomPresencesController do + describe 'DELETE /study_room_presences/:id', version: 1 do + it_behaves_like 'a destroyable and permissible model' do + let(:record) { create(:study_room_presence) } + let(:record_url) { "/v1/study_room_presences/#{record.id}" } + let(:record_permission) { 'study_room_presence.destroy' } + end + end +end diff --git a/spec/requests/v1/study_room_presence_controller/index_spec.rb b/spec/requests/v1/study_room_presence_controller/index_spec.rb new file mode 100644 index 00000000..4c7ae825 --- /dev/null +++ b/spec/requests/v1/study_room_presence_controller/index_spec.rb @@ -0,0 +1,13 @@ +require 'rails_helper' + +describe V1::StudyRoomPresencesController do + describe 'GET /study_room_presences', version: 1 do + let(:records) { create_list(:study_room_presence, 3) } + let(:record_url) { '/v1/study_room_presences' } + let(:record_permission) { 'study_room_presence.read' } + let(:request) { get(record_url) } + + it_behaves_like 'a permissible model' + it_behaves_like 'an indexable model' + end +end diff --git a/spec/requests/v1/study_room_presence_controller/show_spec.rb b/spec/requests/v1/study_room_presence_controller/show_spec.rb new file mode 100644 index 00000000..19342149 --- /dev/null +++ b/spec/requests/v1/study_room_presence_controller/show_spec.rb @@ -0,0 +1,12 @@ +require 'rails_helper' + +describe V1::StudyRoomPresencesController do + describe 'GET /study_room_presences/:id', version: 1 do + it_behaves_like 'a permissible model' do + let(:record) { create(:study_room_presence) } + let(:record_url) { "/v1/study_room_presences/#{record.id}" } + let(:record_permission) { 'study_room_presence.read' } + let(:valid_request) { get(record_url) } + end + end +end diff --git a/spec/requests/v1/study_room_presence_controller/update_spec.rb b/spec/requests/v1/study_room_presence_controller/update_spec.rb new file mode 100644 index 00000000..34b06c95 --- /dev/null +++ b/spec/requests/v1/study_room_presence_controller/update_spec.rb @@ -0,0 +1,12 @@ +require 'rails_helper' + +describe V1::StudyRoomPresencesController do + describe 'PUT /study_room_presences/:id', version: 1 do + it_behaves_like 'an updatable and permissible model' do + let(:record) { create(:study_room_presence) } + let(:record_url) { "/v1/study_room_presences/#{record.id}" } + let(:record_permission) { 'study_room_presence.update' } + let(:invalid_attributes) { { status: '' } } + end + end +end From 7eafcf6760633c0c3f104f3b50ec12a2378f6aab Mon Sep 17 00:00:00 2001 From: lodewiges <131907615+lodewiges@users.noreply.github.com> Date: Thu, 21 Nov 2024 23:28:53 +0100 Subject: [PATCH 2/9] Extract mailadress to .env file (#460) * edited gemfile * update format * Intitial Commit * edit application.rb * Update Gemfile * Update Gemfile.lock * Update Gemfile.lock * Update Gemfile.lock * fixed lint & tests * fixed lint * fixed lint final * edited .env to @csvalpha.nl adresses --- app/jobs/user_archive_job.rb | 2 +- app/mailers/application_mailer.rb | 2 +- app/mailers/mail_smtp_mailer.rb | 4 ++-- app/mailers/user_cleanup_mailer.rb | 2 +- app/mailers/user_export_mailer.rb | 3 ++- app/views/mail_bounce_mailer/address_unknown.html.erb | 2 +- app/views/mail_bounce_mailer/mail_bounced.html.erb | 3 ++- app/views/user_cleanup_mailer/cleanup_email.erb | 2 +- config/application.rb | 5 +++++ spec/jobs/smtp_job_spec.rb | 4 ++-- spec/jobs/user_cleanup_job_spec.rb | 3 +-- spec/jobs/user_export_mailer_job_spec.rb | 2 +- 12 files changed, 20 insertions(+), 14 deletions(-) diff --git a/app/jobs/user_archive_job.rb b/app/jobs/user_archive_job.rb index ca30af5c..06b27632 100644 --- a/app/jobs/user_archive_job.rb +++ b/app/jobs/user_archive_job.rb @@ -20,7 +20,7 @@ def create_global_archive_user User.create!(id: ARCHIVE_USER_ID, username: 'archived.user', - email: 'ict@csvalpha.nl', + email: Rails.application.config.x.ict_email, first_name: 'Gearchiveerde', last_name: 'Gebruiker', address: 'Onbekend', diff --git a/app/mailers/application_mailer.rb b/app/mailers/application_mailer.rb index 529e5da1..7c76a405 100644 --- a/app/mailers/application_mailer.rb +++ b/app/mailers/application_mailer.rb @@ -1,4 +1,4 @@ class ApplicationMailer < ActionMailer::Base - default from: 'no-reply@csvalpha.nl' + default from: Rails.application.config.x.noreply_email layout 'mailer' end diff --git a/app/mailers/mail_smtp_mailer.rb b/app/mailers/mail_smtp_mailer.rb index de9035ef..81643706 100644 --- a/app/mailers/mail_smtp_mailer.rb +++ b/app/mailers/mail_smtp_mailer.rb @@ -12,14 +12,14 @@ def enabled_email(mail_alias, password) # since we do not want to send the password to mail management def notify_management_enable_email(mail_alias) @mail_alias = mail_alias - mail to: 'mailbeheer@csvalpha.nl', + mail to: Rails.application.config.x.mailbeheer_email, subject: "SMTP account voor #{mail_alias.email} aangemaakt" end # Mail to notify the user and mail management that their SMTP is removed def disabled_email(mail_alias) @mail_alias = mail_alias - mail to: 'mailbeheer@csvalpha.nl', bcc: mail_alias.mail_addresses, + mail to: Rails.application.config.x.mailbeheer_email, bcc: mail_alias.mail_addresses, subject: "SMTP account voor #{mail_alias.email} opgeheven" end end diff --git a/app/mailers/user_cleanup_mailer.rb b/app/mailers/user_cleanup_mailer.rb index 54b29b37..c4dc77de 100644 --- a/app/mailers/user_cleanup_mailer.rb +++ b/app/mailers/user_cleanup_mailer.rb @@ -6,6 +6,6 @@ def cleanup_email(will_archive_users, archived_users) ' staan op het punt gearchiveerd te worden' subject = 'Er zijn gebruikers gearchiveerd!' if @will_archive_users.empty? - mail to: 'ict@csvalpha.nl;bestuur@csvalpha.nl', subject: + mail to: Rails.application.config.x.privacy_email, subject: end end diff --git a/app/mailers/user_export_mailer.rb b/app/mailers/user_export_mailer.rb index abed5cbd..9f1d53de 100644 --- a/app/mailers/user_export_mailer.rb +++ b/app/mailers/user_export_mailer.rb @@ -4,6 +4,7 @@ def privacy_notification_email(exporting_user, group, fields, description) @group = group @fields = fields @description = description - mail to: 'privacy@csvalpha.nl', subject: '[Privacy] Er is een database-export gemaakt' # rubocop:disable Rails/I18nLocaleTexts + mail to: Rails.application.config.x.privacy_email, + subject: '[Privacy] Er is een database-export gemaakt' # rubocop:disable Rails/I18nLocaleTexts end end diff --git a/app/views/mail_bounce_mailer/address_unknown.html.erb b/app/views/mail_bounce_mailer/address_unknown.html.erb index ab441ae7..c8e5e6e2 100644 --- a/app/views/mail_bounce_mailer/address_unknown.html.erb +++ b/app/views/mail_bounce_mailer/address_unknown.html.erb @@ -1,4 +1,4 @@ U heeft geprobeerd een mail te versturen naar een @csvalpha.nl mailadres. Deze kan helaas niet bezorgd worden. Het gebruikte mailadres <%= @to %> is namelijk niet in gebruik. Controleer het mailadres nogmaals.

-Mocht u zeker zijn dat het mailadres klopt of niet weten welk mailadres u moet gebruiken kunt u mailen naar abactis@csvalpha.nl +Mocht u zeker zijn dat het mailadres klopt of niet weten welk mailadres u moet gebruiken kunt u mailen naar <%= Rails.application.config.x.ict_email %> diff --git a/app/views/mail_bounce_mailer/mail_bounced.html.erb b/app/views/mail_bounce_mailer/mail_bounced.html.erb index e7b4ce67..daad768b 100644 --- a/app/views/mail_bounce_mailer/mail_bounced.html.erb +++ b/app/views/mail_bounce_mailer/mail_bounced.html.erb @@ -1,4 +1,5 @@ Uw bericht met als onderwerp "<%= @subject %>" aan "<%= @to %>" is helaas niet succesvol afgeleverd.
De reden hiervoor is: <%= @reason %>. Mocht dit een bericht aan een mailgroep zijn kan het ook zijn dat het bericht maar bij één ontvanger niet is aangekomen.

-Voor meer vragen kunt u mailen naar mailbeheer@csvalpha.nl +Voor meer vragen kunt u mailen naar <%= Rails.application.config.x.ict_email %> + diff --git a/app/views/user_cleanup_mailer/cleanup_email.erb b/app/views/user_cleanup_mailer/cleanup_email.erb index d1af789b..235c96e5 100644 --- a/app/views/user_cleanup_mailer/cleanup_email.erb +++ b/app/views/user_cleanup_mailer/cleanup_email.erb @@ -8,7 +8,7 @@ - <%= user.full_name %> <% end %>

- Vergeet niet de lidmaatschapsformulieren van deze leden te vernietigd. Als dit gebeurd is zouden we dan op de hoogte kunnen worden gebracht door middel van een mailtje naar privacy@csvalpha.nl. + Vergeet niet de lidmaatschapsformulieren van deze leden te vernietigd. Als dit gebeurd is zouden we dan op de hoogte kunnen worden gebracht door middel van een mailtje naar <%= Rails.application.config.x.privacy_email %>. <% end %>
diff --git a/config/application.rb b/config/application.rb index 18efd06c..7158b5ae 100644 --- a/config/application.rb +++ b/config/application.rb @@ -81,5 +81,10 @@ class Application < Rails::Application config.x.google_api_key = credentials.dig(Rails.env.to_sym, :google_api_key) config.x.healthcheck_ids = credentials.dig(Rails.env.to_sym, :healthcheck_ids) + + config.x.noreply_email = ENV.fetch('NOREPLY_EMAIL', 'no-reply@csvalpha.com') + config.x.ict_email = ENV.fetch('ICT_EMAIL', 'ict@csvalpha.com') + config.x.privacy_email = ENV.fetch('PRIVACY_EMAIL', 'privacy@csvalpha.com') + config.x.mailbeheer_email = ENV.fetch('PRIVACY_EMAIL', 'mailbeheer@csvalpha.com') end end diff --git a/spec/jobs/smtp_job_spec.rb b/spec/jobs/smtp_job_spec.rb index 247b798f..37867317 100644 --- a/spec/jobs/smtp_job_spec.rb +++ b/spec/jobs/smtp_job_spec.rb @@ -25,7 +25,7 @@ it { expect(mail.bcc).to eq mail_alias.mail_addresses } it { expect(mail.subject).to eq "Je kunt nu mail versturen vanaf #{mail_alias.email}!" } - it { expect(management_mail.to).to eq ['mailbeheer@csvalpha.nl'] } + it { expect(management_mail.to).to eq [Rails.application.config.x.mailbeheer_email] } it { expect(management_mail.subject).to eq "SMTP account voor #{mail_alias.email} aangemaakt" @@ -47,7 +47,7 @@ it { expect(client).to have_received(:delete_smtp) } it { expect(mail.bcc).to eq mail_alias.mail_addresses } - it { expect(mail.to).to eq ['mailbeheer@csvalpha.nl'] } + it { expect(mail.to).to eq [Rails.application.config.x.mailbeheer_email] } it { expect(mail.subject).to eq "SMTP account voor #{mail_alias.email} opgeheven" } end end diff --git a/spec/jobs/user_cleanup_job_spec.rb b/spec/jobs/user_cleanup_job_spec.rb index e86fd21f..97d49b68 100644 --- a/spec/jobs/user_cleanup_job_spec.rb +++ b/spec/jobs/user_cleanup_job_spec.rb @@ -35,8 +35,7 @@ context 'when with will archive and archived users' do it { expect(ActionMailer::Base.deliveries.count).to eq 1 } - it { expect(email.to).to include 'bestuur@csvalpha.nl' } - it { expect(email.to).to include 'ict@csvalpha.nl' } + it { expect(email.to).to include Rails.application.config.x.privacy_email } it { expect(email.body.to_s).to include(almost_archive_user.full_name) } it { expect(email.body.to_s).not_to include(user.full_name) } it { expect(email.body.to_s).to include('Er is 1 gebruiker gearchiveerd.') } diff --git a/spec/jobs/user_export_mailer_job_spec.rb b/spec/jobs/user_export_mailer_job_spec.rb index 908c9992..a82f6ecc 100644 --- a/spec/jobs/user_export_mailer_job_spec.rb +++ b/spec/jobs/user_export_mailer_job_spec.rb @@ -18,7 +18,7 @@ end it { expect(ActionMailer::Base.deliveries.count).to eq 1 } - it { expect(privacy_notification_email.to.first).to eq 'privacy@csvalpha.nl' } + it { expect(privacy_notification_email.to).to eq [Rails.application.config.x.privacy_email] } it { expect(privacy_notification_email.body.to_s).to include(exporting_user.full_name) } it { expect(privacy_notification_email.body.to_s).to include(group.name) } it { expect(privacy_notification_email.body.to_s).to include(fields.join(', ')) } From 40039994772448e34d30330696d3d2b6449426c7 Mon Sep 17 00:00:00 2001 From: lodewiges <131907615+lodewiges@users.noreply.github.com> Date: Fri, 22 Nov 2024 00:40:03 +0100 Subject: [PATCH 3/9] Fixed studyroomMigration (#462) * fixed studyroomMigration * added qp again * 1/2 edited migration * 2/2 fixed schema.rb * improved migration --- .../20241027103012_create_study_room_presence.rb | 10 +++++----- db/schema.rb | 3 ++- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/db/migrate/20241027103012_create_study_room_presence.rb b/db/migrate/20241027103012_create_study_room_presence.rb index d7133dc2..1d385f8e 100644 --- a/db/migrate/20241027103012_create_study_room_presence.rb +++ b/db/migrate/20241027103012_create_study_room_presence.rb @@ -8,10 +8,10 @@ def change t.datetime :deleted_at t.timestamps end - end - Permission.create(name: 'study_room_presence.create') - Permission.create(name: 'study_room_presence.read') - Permission.create(name: 'study_room_presence.update') - Permission.create(name: 'study_room_presence.destroy') + Permission.find_or_create_by!(name: 'study_room_presence.create') + Permission.find_or_create_by!(name: 'study_room_presence.read') + Permission.find_or_create_by!(name: 'study_room_presence.update') + Permission.find_or_create_by!(name: 'study_room_presence.destroy') + end end diff --git a/db/schema.rb b/db/schema.rb index 726dbcaf..6c71396d 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -9,6 +9,7 @@ # migrations use external dependencies or application code. # # It's strongly recommended that you check this file into your version control system. + ActiveRecord::Schema[7.0].define(version: 2024_10_27_103012) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -484,7 +485,7 @@ t.index ["datetime"], name: "index_quickpost_messages_on_datetime" t.index ["deleted_at"], name: "index_quickpost_messages_on_deleted_at" end - + create_table "room_adverts", force: :cascade do |t| t.string "house_name", null: false t.string "contact", null: false From d481402791a0a7a2ed31e7d58de5fd6ed39121c3 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Fri, 22 Nov 2024 00:57:02 +0100 Subject: [PATCH 4/9] chore(deps): update dependency vpim to v24 (#406) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- Gemfile | 2 +- Gemfile.lock | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Gemfile b/Gemfile index c05a2892..c2649b4a 100644 --- a/Gemfile +++ b/Gemfile @@ -44,7 +44,7 @@ gem 'sidekiq', '~> 6.0' gem 'sidekiq-scheduler', '~> 5.0', '>= 5.0.2' gem 'slack-notifier', '~> 2.0' gem 'validates_timeliness', '~> 7.0.0.beta2' -gem 'vpim', '~> 13.11' +gem 'vpim', '~> 24.2', '>= 24.2.20' group :development, :test do gem 'awesome_print' diff --git a/Gemfile.lock b/Gemfile.lock index ffc816f9..25d14e63 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -511,7 +511,7 @@ GEM timeliness (>= 0.3.10, < 1) vcard_parser (0.0.9) vcr (6.1.0) - vpim (13.11.11) + vpim (24.2.20) webmock (3.14.0) addressable (>= 2.8.0) crack (>= 0.3.2) @@ -607,7 +607,7 @@ DEPENDENCIES tzinfo-data validates_timeliness (~> 7.0.0.beta2) vcr - vpim (~> 13.11) + vpim (~> 24.2, >= 24.2.20) webmock BUNDLED WITH From 5470a10df8def5bb4488f028187689ce20f7a31e Mon Sep 17 00:00:00 2001 From: lodewiges <131907615+lodewiges@users.noreply.github.com> Date: Fri, 22 Nov 2024 00:57:50 +0100 Subject: [PATCH 5/9] Removing quickpost (#461) * intial commit * edited migration * Fixed Lint * added permissions to migration * Fixed Lint * Updated migration --- .../v1/quickpost_messages_controller.rb | 2 - app/jobs/user_archive_job.rb | 1 - app/models/quickpost_message.rb | 14 ------ app/policies/quickpost_message_policy.rb | 2 - .../v1/quickpost_message_resource.rb | 17 -------- config/routes.rb | 1 - db/migrate/20241113091607_remove_quickpost.rb | 10 +++++ db/schema.rb | 15 +------ db/seeds/content.rb | 4 -- db/seeds/permissions.rb | 3 -- spec/factories/quickpost_messages.rb | 6 --- spec/jobs/user_archive_job_spec.rb | 2 - spec/models/quickpost_message_spec.rb | 43 ------------------- .../create_spec.rb | 15 ------- .../destroy_spec.rb | 11 ----- .../index_spec.rb | 15 ------- .../show_spec.rb | 11 ----- 17 files changed, 12 insertions(+), 160 deletions(-) delete mode 100644 app/controllers/v1/quickpost_messages_controller.rb delete mode 100644 app/models/quickpost_message.rb delete mode 100644 app/policies/quickpost_message_policy.rb delete mode 100644 app/resources/v1/quickpost_message_resource.rb create mode 100644 db/migrate/20241113091607_remove_quickpost.rb delete mode 100644 spec/factories/quickpost_messages.rb delete mode 100644 spec/models/quickpost_message_spec.rb delete mode 100644 spec/requests/v1/quickpost_messages_controller/create_spec.rb delete mode 100644 spec/requests/v1/quickpost_messages_controller/destroy_spec.rb delete mode 100644 spec/requests/v1/quickpost_messages_controller/index_spec.rb delete mode 100644 spec/requests/v1/quickpost_messages_controller/show_spec.rb diff --git a/app/controllers/v1/quickpost_messages_controller.rb b/app/controllers/v1/quickpost_messages_controller.rb deleted file mode 100644 index d679a2ce..00000000 --- a/app/controllers/v1/quickpost_messages_controller.rb +++ /dev/null @@ -1,2 +0,0 @@ -class V1::QuickpostMessagesController < V1::ApplicationController -end diff --git a/app/jobs/user_archive_job.rb b/app/jobs/user_archive_job.rb index 06b27632..68fbe04d 100644 --- a/app/jobs/user_archive_job.rb +++ b/app/jobs/user_archive_job.rb @@ -61,7 +61,6 @@ def keep_entities # rubocop:disable Metrics/MethodLength PhotoAlbum, PhotoTag, Poll, - QuickpostMessage, Form::Form, Form::Response, Forum::Post, diff --git a/app/models/quickpost_message.rb b/app/models/quickpost_message.rb deleted file mode 100644 index 4afe4785..00000000 --- a/app/models/quickpost_message.rb +++ /dev/null @@ -1,14 +0,0 @@ -class QuickpostMessage < ApplicationRecord - belongs_to :author, class_name: 'User' - - validates :message, presence: true, length: { minimum: 1, maximum: 500 } - - after_create :publish_to_message_bus - - private - - def publish_to_message_bus - attributes = { id:, author_id: author.id, message:, created_at: } - MessageBus.publish('/quickpost_messages', attributes.to_json, group_ids: [0]) - end -end diff --git a/app/policies/quickpost_message_policy.rb b/app/policies/quickpost_message_policy.rb deleted file mode 100644 index 2e0e2290..00000000 --- a/app/policies/quickpost_message_policy.rb +++ /dev/null @@ -1,2 +0,0 @@ -class QuickpostMessagePolicy < ApplicationPolicy -end diff --git a/app/resources/v1/quickpost_message_resource.rb b/app/resources/v1/quickpost_message_resource.rb deleted file mode 100644 index 6e1412c7..00000000 --- a/app/resources/v1/quickpost_message_resource.rb +++ /dev/null @@ -1,17 +0,0 @@ -class V1::QuickpostMessageResource < V1::ApplicationResource - attributes :message - - has_one :author, always_include_linkage_data: true - - before_create do - @model.author_id = current_user.id - end - - def self.creatable_fields(_context) - [:message] - end - - def self.searchable_fields - %i[message] - end -end diff --git a/config/routes.rb b/config/routes.rb index d0299850..03c964d5 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -73,7 +73,6 @@ end get 'users/me/nextcloud', to: 'users#nextcloud' - jsonapi_resources :quickpost_messages jsonapi_resources :vacancies namespace :debit do diff --git a/db/migrate/20241113091607_remove_quickpost.rb b/db/migrate/20241113091607_remove_quickpost.rb new file mode 100644 index 00000000..db94291c --- /dev/null +++ b/db/migrate/20241113091607_remove_quickpost.rb @@ -0,0 +1,10 @@ +class RemoveQuickpost < ActiveRecord::Migration[7.0] + def change + drop_table :quickpost_messages + + Permission.find_by(name: 'quickpost_message.create')&.destroy + Permission.find_by(name: 'quickpost_message.read')&.destroy + Permission.find_by(name: 'quickpost_message.update')&.destroy + Permission.find_by(name: 'quickpost_message.destroy')&.destroy + end +end diff --git a/db/schema.rb b/db/schema.rb index 6c71396d..3c73c96e 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema[7.0].define(version: 2024_10_27_103012) do +ActiveRecord::Schema[7.0].define(version: 2024_11_13_091607) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -474,18 +474,7 @@ t.index ["author_id"], name: "index_polls_on_author_id" t.index ["form_id"], name: "index_polls_on_form_id" end - - create_table "quickpost_messages", id: :serial, force: :cascade do |t| - t.integer "author_id" - t.text "message" - t.datetime "created_at", precision: nil, null: false - t.datetime "updated_at", precision: nil, null: false - t.datetime "deleted_at", precision: nil - t.datetime "datetime", precision: nil - t.index ["datetime"], name: "index_quickpost_messages_on_datetime" - t.index ["deleted_at"], name: "index_quickpost_messages_on_deleted_at" - end - +3 create_table "room_adverts", force: :cascade do |t| t.string "house_name", null: false t.string "contact", null: false diff --git a/db/seeds/content.rb b/db/seeds/content.rb index 2667adc2..d0a6f27a 100644 --- a/db/seeds/content.rb +++ b/db/seeds/content.rb @@ -45,10 +45,6 @@ end end -members.sample(80).each { |user| FactoryBot.create(:quickpost_message, author: user) } -# To ensure at least one user creating (more than) two quickpost messages -members.sample(30).each { |user| FactoryBot.create(:quickpost_message, author: user) } - members.sample(4).each do |user| FactoryBot.create(:activity, author: user) end diff --git a/db/seeds/permissions.rb b/db/seeds/permissions.rb index 2ecc1586..8a20026d 100644 --- a/db/seeds/permissions.rb +++ b/db/seeds/permissions.rb @@ -34,7 +34,6 @@ def create_permissions(permission_map) 'photo' => %i[create read update destroy], 'photo_comment' => %i[create read update destroy], 'photo_tag' => %i[create read update destroy], - 'quickpost_message' => %i[create read update destroy], 'room_advert' => %i[create read update destroy], 'stored_mail' => %i[read destroy], 'forum/category' => %i[create read update destroy], @@ -76,7 +75,6 @@ def create_permissions(permission_map) 'photo' => %i[create read], 'photo_comment' => %i[create read], 'photo_tag' => %i[create read], - 'quickpost_message' => %i[create read], 'room_advert' => %i[create read], 'forum/category' => %i[read], 'forum/thread' => %i[create read], @@ -111,7 +109,6 @@ def create_permissions(permission_map) 'photo' => %i[read], 'photo_comment' => %i[create read], 'photo_tag' => %i[create read], - 'quickpost_message' => %i[create read], 'room_advert' => %i[], 'forum/category' => %i[read], 'forum/thread' => %i[create read], diff --git a/spec/factories/quickpost_messages.rb b/spec/factories/quickpost_messages.rb deleted file mode 100644 index b5bf61ef..00000000 --- a/spec/factories/quickpost_messages.rb +++ /dev/null @@ -1,6 +0,0 @@ -FactoryBot.define do - factory :quickpost_message do - message { Faker::Lorem.sentence } - association :author, factory: :user - end -end diff --git a/spec/jobs/user_archive_job_spec.rb b/spec/jobs/user_archive_job_spec.rb index 9eb639df..a4d8abaf 100644 --- a/spec/jobs/user_archive_job_spec.rb +++ b/spec/jobs/user_archive_job_spec.rb @@ -17,7 +17,6 @@ create(:photo, uploader: user) create(:photo_album, author: user) create(:poll, author: user) - create(:quickpost_message, author: user) create(:response, user:) create(:form, author: user) create(:post, author: user) @@ -33,7 +32,6 @@ it { expect { job }.to change { Photo.last.uploader }.from(user).to(archive_user) } it { expect { job }.to change { PhotoAlbum.last.author }.from(user).to(archive_user) } it { expect { job }.to change { Poll.last.author }.from(user).to(archive_user) } - it { expect { job }.to change { QuickpostMessage.last.author }.from(user).to(archive_user) } it { expect { job }.to change { Form::Response.last.user }.from(user).to(archive_user) } it { expect { job }.to change { Form::Form.last.author }.from(user).to(archive_user) } it { expect { job }.to change { Forum::Post.last.author }.from(user).to(archive_user) } diff --git a/spec/models/quickpost_message_spec.rb b/spec/models/quickpost_message_spec.rb deleted file mode 100644 index ef68a501..00000000 --- a/spec/models/quickpost_message_spec.rb +++ /dev/null @@ -1,43 +0,0 @@ -require 'rails_helper' - -RSpec.describe QuickpostMessage, type: :model do - subject(:quickpost_message) { build(:quickpost_message) } - - describe '#valid?' do - it { expect(quickpost_message.valid?).to be true } - - context 'when with an empty message' do - subject(:quickpost_message) { build(:quickpost_message, message: '') } - - it { expect(quickpost_message.valid?).to be false } - end - - context 'when with a too long message' do - subject(:quickpost_message) do - build(:quickpost_message, message: Faker::Lorem.characters(number: 501)) - end - - it { expect(quickpost_message.valid?).to be false } - end - - context 'when without a user' do - subject(:quickpost_message) { build(:quickpost_message, author: nil) } - - it { expect(quickpost_message.valid?).to be false } - end - end - - describe '#save' do - context 'when it is new' do - it do # rubocop:disable RSpec/ExampleLength - allow(MessageBus).to receive(:publish) - quickpost_message.save - expect(MessageBus).to have_received(:publish).with( - '/quickpost_messages', a_string_including(quickpost_message.author_id.to_s, - quickpost_message.message), - group_ids: [0] - ) - end - end - end -end diff --git a/spec/requests/v1/quickpost_messages_controller/create_spec.rb b/spec/requests/v1/quickpost_messages_controller/create_spec.rb deleted file mode 100644 index 0eccec31..00000000 --- a/spec/requests/v1/quickpost_messages_controller/create_spec.rb +++ /dev/null @@ -1,15 +0,0 @@ -require 'rails_helper' - -describe V1::QuickpostMessagesController do - describe 'POST /quickpost_messages', version: 1 do - let(:record) { build_stubbed(:quickpost_message) } - let(:record_url) { '/v1/quickpost_messages' } - let(:record_permission) { 'quickpost_message.create' } - - it_behaves_like 'a creatable and permissible model' do - let(:invalid_attributes) { { message: '' } } - end - - it_behaves_like 'a creatable model with author' - end -end diff --git a/spec/requests/v1/quickpost_messages_controller/destroy_spec.rb b/spec/requests/v1/quickpost_messages_controller/destroy_spec.rb deleted file mode 100644 index 1a28dff2..00000000 --- a/spec/requests/v1/quickpost_messages_controller/destroy_spec.rb +++ /dev/null @@ -1,11 +0,0 @@ -require 'rails_helper' - -describe V1::QuickpostMessagesController do - describe 'DELETE /quickpost_messages/:id', version: 1 do - it_behaves_like 'a destroyable and permissible model' do - let(:record) { create(:quickpost_message) } - let(:record_url) { "/v1/quickpost_messages/#{record.id}" } - let(:record_permission) { 'quickpost_message.destroy' } - end - end -end diff --git a/spec/requests/v1/quickpost_messages_controller/index_spec.rb b/spec/requests/v1/quickpost_messages_controller/index_spec.rb deleted file mode 100644 index 52cb583e..00000000 --- a/spec/requests/v1/quickpost_messages_controller/index_spec.rb +++ /dev/null @@ -1,15 +0,0 @@ -require 'rails_helper' - -describe V1::QuickpostMessagesController do - describe 'GET /quickpost_messages', version: 1 do - let(:records) { create_list(:quickpost_message, 7) } - let(:record_url) { '/v1/quickpost_messages' } - let(:record_permission) { 'quickpost_message.read' } - - subject(:request) { get(record_url) } - - it_behaves_like 'a permissible model' - it_behaves_like 'an indexable model' - it_behaves_like 'a searchable model', %i[message] - end -end diff --git a/spec/requests/v1/quickpost_messages_controller/show_spec.rb b/spec/requests/v1/quickpost_messages_controller/show_spec.rb deleted file mode 100644 index 01ad41cb..00000000 --- a/spec/requests/v1/quickpost_messages_controller/show_spec.rb +++ /dev/null @@ -1,11 +0,0 @@ -require 'rails_helper' - -describe V1::QuickpostMessagesController do - describe 'GET /quickpost_messages/:id', version: 1 do - it_behaves_like 'a permissible model' do - let(:record) { create(:quickpost_message) } - let(:record_url) { "/v1/quickpost_messages/#{record.id}" } - let(:record_permission) { 'quickpost_message.read' } - end - end -end From 5429b49f004e4e7a47215cb9fad5060310301644 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Fri, 22 Nov 2024 01:00:42 +0100 Subject: [PATCH 6/9] chore(deps): update docker/build-push-action action to v6 (#416) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- .github/workflows/publish-image.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/publish-image.yml b/.github/workflows/publish-image.yml index da946c77..11ac7bb1 100644 --- a/.github/workflows/publish-image.yml +++ b/.github/workflows/publish-image.yml @@ -64,7 +64,7 @@ jobs: password: ${{ secrets.GITHUB_TOKEN }} - name: Build and push image - uses: docker/build-push-action@ca052bb54ab0790a636c9b5f226502c73d547a25 # v5.4.0 + uses: docker/build-push-action@4f58ea79222b3b9dc2c8bbdd6debcef730109a75 # v6.9.0 with: push: true context: . From 40cd931b4e115f91173b56ca4f08404fffd98e0a Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Fri, 22 Nov 2024 01:29:04 +0100 Subject: [PATCH 7/9] chore(deps): update appleboy/ssh-action action to v1.2.0 (#464) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- .github/workflows/continuous-delivery.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/continuous-delivery.yml b/.github/workflows/continuous-delivery.yml index 68a521df..bd9f8856 100644 --- a/.github/workflows/continuous-delivery.yml +++ b/.github/workflows/continuous-delivery.yml @@ -150,7 +150,7 @@ jobs: env: ${{ needs.metadata.outputs.stage }} - name: Deploy - uses: appleboy/ssh-action@25ce8cbbcb08177468c7ff7ec5cbfa236f9341e1 # v1.1.0 + uses: appleboy/ssh-action@7eaf76671a0d7eec5d98ee897acda4f968735a17 # v1.2.0 env: STAGE: ${{ needs.metadata.outputs.stage }} with: From ae509a8e77431c6c1d6c07feac0c67f5c4024e88 Mon Sep 17 00:00:00 2001 From: Ellen Wittingen <101463776+Ellen-Wittingen@users.noreply.github.com> Date: Fri, 22 Nov 2024 01:45:15 +0100 Subject: [PATCH 8/9] Feature: A group and user for each SOFIA role in the database seed (#412) * Added groups for SOFIA roles * Fixed members and groups for sofia * Fixed Lint --------- Co-authored-by: lodewiges <131907615+lodewiges@users.noreply.github.com> --- db/seeds/users_and_groups.rb | 40 ++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/db/seeds/users_and_groups.rb b/db/seeds/users_and_groups.rb index 818d63c6..dd9c6f07 100644 --- a/db/seeds/users_and_groups.rb +++ b/db/seeds/users_and_groups.rb @@ -7,6 +7,14 @@ bestuur = Group.create!(name: 'Bestuur', kind: 'bestuur', description: 'Wij zijn de echte bazen', recognized_at_gma: 'ALV 21', rejected_at_gma: 'ALV 218') +sofia_treasurers = Group.create!(name: 'SOFIA Penningmeester', kind: 'bestuur', + administrative: true) + +sofia_renting_managers = Group.create!(name: 'SOFIA Verhuur Manager', kind: 'bestuur', + administrative: true) + +sofia_main_bartenders = Group.create!(name: 'SOFIA Hoofdtappers', kind: 'groep') + old_members_group = Group.create!(name: 'Oud-Leden', kind: 'groep', description: 'Oud-Alphanen, verenigt u!') @@ -25,6 +33,21 @@ password: 'password1234', password_confirmation: 'password1234') +sofia_treasurer = FactoryBot.create(:user, activated_at: Time.zone.now) +sofia_treasurer.update(username: 'sofia_treasurer', + password: 'password1234', + password_confirmation: 'password1234') + +sofia_renting_manager = FactoryBot.create(:user, activated_at: Time.zone.now) +sofia_renting_manager.update(username: 'sofia_renting_manager', + password: 'password1234', + password_confirmation: 'password1234') + +sofia_bartenders = FactoryBot.create_list(:user, 6, activated_at: Time.zone.now) +sofia_bartenders.first.update(username: 'sofia_main_bartender', + password: 'password1234', + password_confirmation: 'password1234') + old_members = FactoryBot.create_list(:user, 8, activated_at: Time.zone.now) old_members.first.update(username: 'oudlid', password: 'password1234', @@ -49,6 +72,23 @@ function: Faker::Job.title) end +Membership.create(user: sofia_treasurer, group: sofia_treasurers, + start_date: Date.current.months_ago(10)) +Membership.create(user: sofia_treasurer, group: member_group, + start_date: Date.current.months_ago(4), function: Faker::Job.title) + +Membership.create(user: sofia_renting_manager, group: sofia_renting_managers, + start_date: Date.current.months_ago(10)) +Membership.create(user: sofia_renting_manager, group: member_group, + start_date: Date.current.months_ago(4), function: Faker::Job.title) + +sofia_bartenders.each do |user| + Membership.create(user:, group: sofia_main_bartenders, + start_date: Date.current.months_ago(10), function: Faker::Job.title) + Membership.create(user:, group: member_group, start_date: Date.current.months_ago(4), + function: Faker::Job.title) +end + old_members.each do |user| Membership.create(user:, group: old_members_group, start_date: Date.current.months_ago(10), function: Faker::Job.title) From cfd197a2746a2dfada54534c18fd938998674bcc Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Fri, 22 Nov 2024 01:49:38 +0100 Subject: [PATCH 9/9] chore(deps): update all non-major bundler dependencies (#304) * chore(deps): update all non-major bundler dependencies * artifact fix? * artifact fix? v2 * Fixed faker and update gemfile.lock --------- Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: lodewiges <131907615+lodewiges@users.noreply.github.com> Co-authored-by: Jorai Geertsema --- Gemfile | 62 +++++++------- Gemfile.lock | 142 ++++++++++++++++---------------- spec/factories/inbound_email.rb | 2 +- spec/factories/users.rb | 2 +- 4 files changed, 105 insertions(+), 103 deletions(-) diff --git a/Gemfile b/Gemfile index c2649b4a..3d9c3724 100644 --- a/Gemfile +++ b/Gemfile @@ -3,46 +3,46 @@ source 'https://rubygems.org' gem 'active_model_otp', git: 'https://github.com/heapsource/active_model_otp.git', ref: '6ed9927' gem 'dav4rack', git: 'https://github.com/csvalpha/dav4rack.git', ref: '8541e53' -gem 'bcrypt', '~> 3.1' -gem 'bootsnap', '~> 1.4' +gem 'bcrypt', '~> 3.1', '>= 3.1.20' +gem 'bootsnap', '~> 1.18', '>= 1.18.4' gem 'carrierwave', '~> 2.1' -gem 'carrierwave-base64', '~> 2.5' -gem 'carrierwave-bombshelter', '~> 0.2' +gem 'carrierwave-base64', '~> 2.11' +gem 'carrierwave-bombshelter', '~> 0.2', '>= 0.2.2' gem 'case_transform', '~> 0.2' -gem 'counter_culture', '~> 3.0' +gem 'counter_culture', '~> 3.8', '>= 3.8.2' gem 'dav4rack_ext', '~> 1.0' gem 'doorkeeper', '~> 5.2' -gem 'doorkeeper-i18n', '~> 5.2' -gem 'exifr', '~> 1.3' -gem 'friendly_id', '~> 5.2' -gem 'http', '~> 5.0' -gem 'iban-tools', '~> 1.1.0' -gem 'icalendar', '~> 2.4' +gem 'doorkeeper-i18n', '~> 5.2', '>= 5.2.7' +gem 'exifr', '~> 1.4' +gem 'friendly_id', '~> 5.5', '>= 5.5.1' +gem 'http', '~> 5.2' +gem 'iban-tools', '~> 1.2.1' +gem 'icalendar', '~> 2.10', '>= 2.10.3' gem 'improvmx', '~> 0.2.1' -gem 'isbn_validation', '~> 1.2' -gem 'jsonapi-authorization', '~> 3.0' -gem 'jsonapi-resources', '~> 0.9.1.beta2' -gem 'message_bus', '~> 4.0' -gem 'mini_magick', '~> 4.6' +gem 'isbn_validation', '~> 1.2', '>= 1.2.2' +gem 'jsonapi-authorization', '~> 3.0', '>= 3.0.2' +gem 'jsonapi-resources', '~> 0.9.1' +gem 'message_bus', '~> 4.3', '>= 4.3.8' +gem 'mini_magick', '~> 4.13', '>= 4.13.2' gem 'paper_trail', '~> 14.0' gem 'paranoia', '~> 3.0' -gem 'pg', '~> 1.0' +gem 'pg', '~> 1.5', '>= 1.5.9' gem 'phonelib' gem 'puma', '~> 6.0' -gem 'pundit', '~> 2.0' -gem 'rack-attack', '~> 6.0' -gem 'rack-cors', '~> 2.0', '>= 2.0.1', require: 'rack/cors' +gem 'pundit', '~> 2.4' +gem 'rack-attack', '~> 6.7' +gem 'rack-cors', '~> 2.0', '>= 2.0.2', require: 'rack/cors' gem 'rails', '~> 7.0', '>= 7.0.4.3' -gem 'rails-i18n', '~> 7.0' -gem 'redis', '~> 4.0' -gem 'roo', '~> 2.9' -gem 'ruby-filemagic', '~> 0.7' -gem 'rubyzip', '~> 2.0' -gem 'sentry-raven', '~> 3.0' -gem 'sepa_king', '~> 0.11' -gem 'sidekiq', '~> 6.0' -gem 'sidekiq-scheduler', '~> 5.0', '>= 5.0.2' -gem 'slack-notifier', '~> 2.0' +gem 'rails-i18n', '~> 7.0', '>= 7.0.10' +gem 'redis', '~> 4.8', '>= 4.8.1' +gem 'roo', '~> 2.10', '>= 2.10.1' +gem 'ruby-filemagic', '~> 0.7', '>= 0.7.3' +gem 'rubyzip', '~> 2.3', '>= 2.3.2' +gem 'sentry-raven', '~> 3.1', '>= 3.1.2' +gem 'sepa_king', '~> 0.14' +gem 'sidekiq', '~> 6.5', '>= 6.5.12' +gem 'sidekiq-scheduler', '~> 5.0', '>= 5.0.6' +gem 'slack-notifier', '~> 2.4' gem 'validates_timeliness', '~> 7.0.0.beta2' gem 'vpim', '~> 24.2', '>= 24.2.20' @@ -54,7 +54,7 @@ group :development, :test do gem 'consistency_fail' gem 'dotenv-rails' gem 'factory_bot_rails' - gem 'faker', '~> 3.0' + gem 'faker', '~> 3.5', '>= 3.5.1' gem 'fuubar' gem 'pry-byebug', require: false gem 'pry-rails' diff --git a/Gemfile.lock b/Gemfile.lock index 25d14e63..91d1eb57 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -91,15 +91,16 @@ GEM public_suffix (>= 2.0.2, < 5.0) ast (2.4.2) awesome_print (1.9.2) - bcrypt (3.1.17) - bcrypt (3.1.17-java) + base64 (0.2.0) + bcrypt (3.1.20) + bcrypt (3.1.20-java) better_errors (2.9.1) coderay (>= 1.0.0) erubi (>= 1.0.0) rack (>= 0.9.0) binding_of_caller (1.0.0) debug_inspector (>= 0.0.1) - bootsnap (1.11.1) + bootsnap (1.18.4) msgpack (~> 1.2) brakeman (5.2.3) builder (3.2.4) @@ -115,7 +116,7 @@ GEM marcel (~> 1.0.0) mini_mime (>= 0.1.3) ssrf_filter (~> 1.0) - carrierwave-base64 (2.10.0) + carrierwave-base64 (2.11.0) carrierwave (>= 2.2.1) marcel (~> 1.0.0) mime-types (~> 3.0) @@ -130,7 +131,7 @@ GEM concurrent-ruby (1.3.4) connection_pool (2.3.0) consistency_fail (0.3.7) - counter_culture (3.2.1) + counter_culture (3.8.2) activerecord (>= 4.2) activesupport (>= 4.2) crack (0.4.5) @@ -149,22 +150,22 @@ GEM unf (>= 0.0.5, < 1.0.0) doorkeeper (5.5.4) railties (>= 5) - doorkeeper-i18n (5.2.3) + doorkeeper-i18n (5.2.7) doorkeeper (>= 5.2) dotenv (2.7.6) dotenv-rails (2.7.6) dotenv (= 2.7.6) railties (>= 3.2) erubi (1.12.0) - et-orbi (1.2.7) + et-orbi (1.2.11) tzinfo - exifr (1.3.9) + exifr (1.4.0) factory_bot (6.2.1) activesupport (>= 5.0.0) factory_bot_rails (6.2.0) factory_bot (~> 6.2.0) railties (>= 5.0.0) - faker (3.0.0) + faker (3.5.1) i18n (>= 1.8.11, < 2) faraday (2.2.0) faraday-net_http (~> 2.0) @@ -175,14 +176,14 @@ GEM ffi (1.15.5-java) ffi (1.15.5-x64-mingw32) ffi (1.15.5-x86-mingw32) - ffi-compiler (1.0.1) - ffi (>= 1.0.0) + ffi-compiler (1.3.2) + ffi (>= 1.15.5) rake formatador (1.1.0) - friendly_id (5.4.2) + friendly_id (5.5.1) activerecord (>= 4.0.0) - fugit (1.8.1) - et-orbi (~> 1, >= 1.2.7) + fugit (1.11.1) + et-orbi (~> 1, >= 1.2.11) raabro (~> 1.4) fuubar (2.5.1) rspec-core (~> 3.0) @@ -204,11 +205,12 @@ GEM guard-compat (~> 1.1) rspec (>= 2.99.0, < 4.0) hashdiff (1.0.1) - http (5.0.4) + http (5.2.0) addressable (~> 2.8) + base64 (~> 0.1) http-cookie (~> 1.0) http-form_data (~> 2.2) - llhttp-ffi (~> 0.4.0) + llhttp-ffi (~> 0.5.0) http-accept (1.7.0) http-cookie (1.0.4) domain_name (~> 0.5) @@ -218,10 +220,11 @@ GEM url_mount (~> 0.2.1) i18n (1.14.5) concurrent-ruby (~> 1.0) - iban-tools (1.1.0) - icalendar (2.7.1) + iban-tools (1.2.1) + icalendar (2.10.3) ice_cube (~> 0.16) - ice_cube (0.16.4) + ostruct + ice_cube (0.17.0) image_processing (1.12.2) mini_magick (>= 4.9.5, < 5) ruby-vips (>= 2.0.17, < 3) @@ -239,7 +242,7 @@ GEM listen (3.7.1) rb-fsevent (~> 0.10, >= 0.10.3) rb-inotify (~> 0.9, >= 0.9.10) - llhttp-ffi (0.4.0) + llhttp-ffi (0.5.0) ffi-compiler (~> 1.0) rake (~> 13.0) loofah (2.20.0) @@ -252,7 +255,7 @@ GEM net-pop net-smtp marcel (1.0.2) - message_bus (4.2.0) + message_bus (4.3.8) rack (>= 1.1.3) method_source (1.0.0) mime-types (3.4.1) @@ -261,12 +264,12 @@ GEM mina (1.2.4) open4 (~> 1.3.4) rake - mini_magick (4.11.0) + mini_magick (4.13.2) mini_mime (1.1.2) mini_portile2 (2.8.2) minitest (5.24.1) - msgpack (1.4.5) - msgpack (1.4.5-java) + msgpack (1.7.5) + msgpack (1.7.5-java) nenv (0.3.0) net-imap (0.3.4) date @@ -293,6 +296,7 @@ GEM nenv (~> 0.1) shellany (~> 0.0) open4 (1.3.4) + ostruct (0.6.1) paper_trail (14.0.0) activerecord (>= 6.0) request_store (~> 1.4) @@ -301,9 +305,7 @@ GEM activerecord (>= 6, < 8.1) parser (3.1.1.0) ast (~> 2.4.1) - pg (1.3.5) - pg (1.3.5-x64-mingw32) - pg (1.3.5-x86-mingw32) + pg (1.5.9) phonelib (0.6.58) pry (0.13.1) coderay (~> 1.1) @@ -322,14 +324,14 @@ GEM nio4r (~> 2.0) puma (6.4.3-java) nio4r (~> 2.0) - pundit (2.2.0) + pundit (2.4.0) activesupport (>= 3.0.0) raabro (1.4.0) racc (1.6.2) racc (1.6.2-java) rack (2.2.10) - rack-attack (6.6.0) - rack (>= 1.0, < 3) + rack-attack (6.7.0) + rack (>= 1.0, < 4) rack-cors (2.0.2) rack (>= 2.0.0) rack-mini-profiler (3.0.0) @@ -355,7 +357,7 @@ GEM nokogiri (>= 1.6) rails-html-sanitizer (1.5.0) loofah (~> 2.19, >= 2.19.1) - rails-i18n (7.0.3) + rails-i18n (7.0.10) i18n (>= 0.7, < 2) railties (>= 6.0.0, < 8) railties (7.0.4.3) @@ -399,7 +401,7 @@ GEM mime-types (>= 1.16, < 4.0) netrc (~> 0.8) rexml (3.2.5) - roo (2.9.0) + roo (2.10.1) nokogiri (~> 1) rubyzip (>= 1.3.0, < 3.0.0) rotp (4.0.2) @@ -451,12 +453,12 @@ GEM ffi (~> 1.12) ruby2_keywords (0.0.5) rubyzip (2.3.2) - rufus-scheduler (3.8.2) - fugit (~> 1.1, >= 1.1.6) + rufus-scheduler (3.9.2) + fugit (~> 1.1, >= 1.11.1) sentry-raven (3.1.2) faraday (>= 1.0) - sepa_king (0.12.0) - activemodel (>= 3.1) + sepa_king (0.14.0) + activemodel (>= 4.2) iban-tools nokogiri shellany (0.0.1) @@ -464,10 +466,10 @@ GEM connection_pool (>= 2.2.5, < 3) rack (~> 2.0) redis (>= 4.5.0, < 5) - sidekiq-scheduler (5.0.2) + sidekiq-scheduler (5.0.6) rufus-scheduler (~> 3.2) sidekiq (>= 6, < 8) - tilt (>= 1.4.0) + tilt (>= 1.4.0, < 3) simplecov (0.21.2) docile (~> 1.1) simplecov-html (~> 0.11) @@ -487,7 +489,7 @@ GEM ssrf_filter (1.0.7) terminal-notifier-guard (1.7.0) thor (1.2.1) - tilt (2.1.0) + tilt (2.4.0) timecop (0.9.5) timeliness (0.4.5) timeout (0.3.2) @@ -534,71 +536,71 @@ PLATFORMS DEPENDENCIES active_model_otp! awesome_print - bcrypt (~> 3.1) + bcrypt (~> 3.1, >= 3.1.20) better_errors binding_of_caller - bootsnap (~> 1.4) + bootsnap (~> 1.18, >= 1.18.4) brakeman bullet carrierwave (~> 2.1) - carrierwave-base64 (~> 2.5) - carrierwave-bombshelter (~> 0.2) + carrierwave-base64 (~> 2.11) + carrierwave-bombshelter (~> 0.2, >= 0.2.2) case_transform (~> 0.2) colorize consistency_fail - counter_culture (~> 3.0) + counter_culture (~> 3.8, >= 3.8.2) dav4rack! dav4rack_ext (~> 1.0) doorkeeper (~> 5.2) - doorkeeper-i18n (~> 5.2) + doorkeeper-i18n (~> 5.2, >= 5.2.7) dotenv-rails - exifr (~> 1.3) + exifr (~> 1.4) factory_bot_rails - faker (~> 3.0) - friendly_id (~> 5.2) + faker (~> 3.5, >= 3.5.1) + friendly_id (~> 5.5, >= 5.5.1) fuubar guard-rspec - http (~> 5.0) - iban-tools (~> 1.1.0) - icalendar (~> 2.4) + http (~> 5.2) + iban-tools (~> 1.2.1) + icalendar (~> 2.10, >= 2.10.3) improvmx (~> 0.2.1) - isbn_validation (~> 1.2) - jsonapi-authorization (~> 3.0) - jsonapi-resources (~> 0.9.1.beta2) + isbn_validation (~> 1.2, >= 1.2.2) + jsonapi-authorization (~> 3.0, >= 3.0.2) + jsonapi-resources (~> 0.9.1) listen - message_bus (~> 4.0) + message_bus (~> 4.3, >= 4.3.8) mina - mini_magick (~> 4.6) + mini_magick (~> 4.13, >= 4.13.2) paper_trail (~> 14.0) paranoia (~> 3.0) - pg (~> 1.0) + pg (~> 1.5, >= 1.5.9) phonelib pry-byebug pry-rails puma (~> 6.0) - pundit (~> 2.0) - rack-attack (~> 6.0) - rack-cors (~> 2.0, >= 2.0.1) + pundit (~> 2.4) + rack-attack (~> 6.7) + rack-cors (~> 2.0, >= 2.0.2) rack-mini-profiler rails (~> 7.0, >= 7.0.4.3) - rails-i18n (~> 7.0) + rails-i18n (~> 7.0, >= 7.0.10) rb-readline - redis (~> 4.0) - roo (~> 2.9) + redis (~> 4.8, >= 4.8.1) + roo (~> 2.10, >= 2.10.1) rspec-rails rubocop rubocop-performance rubocop-rails rubocop-rspec - ruby-filemagic (~> 0.7) - rubyzip (~> 2.0) - sentry-raven (~> 3.0) - sepa_king (~> 0.11) - sidekiq (~> 6.0) - sidekiq-scheduler (~> 5.0, >= 5.0.2) + ruby-filemagic (~> 0.7, >= 0.7.3) + rubyzip (~> 2.3, >= 2.3.2) + sentry-raven (~> 3.1, >= 3.1.2) + sepa_king (~> 0.14) + sidekiq (~> 6.5, >= 6.5.12) + sidekiq-scheduler (~> 5.0, >= 5.0.6) simplecov simplecov-lcov (~> 0.8.0) - slack-notifier (~> 2.0) + slack-notifier (~> 2.4) spring spring-commands-rspec spring-watcher-listen diff --git a/spec/factories/inbound_email.rb b/spec/factories/inbound_email.rb index 8b856a51..9a6a0aeb 100644 --- a/spec/factories/inbound_email.rb +++ b/spec/factories/inbound_email.rb @@ -1,6 +1,6 @@ FactoryBot.define do factory :inbound_email, class: 'ActionMailbox::InboundEmail' do - from { "#{Faker::Name.first_name} <#{Faker::Internet.safe_email}>" } + from { "#{Faker::Name.first_name} <#{Faker::Internet.email}>" } to { "#{Faker::Internet.user_name}@test.csvalpha.nl" } subject { Faker::Book.title } diff --git a/spec/factories/users.rb b/spec/factories/users.rb index 6e05bf3d..96f8a32e 100644 --- a/spec/factories/users.rb +++ b/spec/factories/users.rb @@ -23,7 +23,7 @@ user_details_sharing_preference { %w[all_users members_only hidden].sample } username { nil } - sequence(:email) { |n| Faker::Internet.safe_email(name: "#{Faker::Internet.user_name}#{n}") } + sequence(:email) { |n| Faker::Internet.email(name: "#{Faker::Internet.user_name}#{n}") } password = Faker::Internet.password(min_length: 12) password { password }