mumuki-laboratory 9.10.0 → 9.11.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (59) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/stylesheets/mumuki_laboratory/application/modules/_dropdown.scss +11 -0
  3. data/app/assets/stylesheets/mumuki_laboratory/application/modules/_faqs.scss +1 -1
  4. data/app/controllers/application_controller.rb +1 -1
  5. data/app/controllers/users_controller.rb +33 -0
  6. data/app/helpers/application_helper.rb +2 -2
  7. data/app/helpers/icons_helper.rb +1 -1
  8. data/app/helpers/menu_bar_helper.rb +6 -2
  9. data/app/helpers/notifications_helper.rb +13 -0
  10. data/app/helpers/user_menu_helper.rb +4 -0
  11. data/app/mailers/user_mailer.rb +9 -1
  12. data/app/views/layouts/_user_menu.html.erb +1 -0
  13. data/app/views/layouts/exercise_inputs/read_only_editors/_code.html.erb +1 -1
  14. data/app/views/layouts/exercise_inputs/read_only_editors/_multiple_files.html.erb +4 -4
  15. data/app/views/layouts/mailer.html.erb +7 -1
  16. data/app/views/notifications/_custom.html.erb +1 -0
  17. data/app/views/notifications/_dropdown.html.erb +2 -2
  18. data/app/views/notifications/_exam_authorization_request_updated.html.erb +2 -0
  19. data/app/views/notifications/_exam_registration.html.erb +2 -1
  20. data/app/views/notifications/previews/_custom.html.erb +1 -0
  21. data/app/views/notifications/previews/_discussion.html.erb +2 -0
  22. data/app/views/notifications/previews/_exam_authorization_request_updated.html.erb +2 -0
  23. data/app/views/notifications/previews/_exam_registration.html.erb +2 -0
  24. data/app/views/notifications/previews/_message.html.erb +2 -0
  25. data/app/views/user_mailer/1st_reminder.html.erb +7 -349
  26. data/app/views/user_mailer/1st_reminder.text.erb +0 -4
  27. data/app/views/user_mailer/2nd_reminder.html.erb +7 -349
  28. data/app/views/user_mailer/2nd_reminder.text.erb +0 -4
  29. data/app/views/user_mailer/3rd_reminder.html.erb +7 -349
  30. data/app/views/user_mailer/3rd_reminder.text.erb +0 -4
  31. data/app/views/user_mailer/_mail_template.erb +336 -0
  32. data/app/views/user_mailer/certificate.html.erb +7 -335
  33. data/app/views/user_mailer/certificate.text.erb +0 -3
  34. data/app/views/user_mailer/no_submissions_reminder.html.erb +7 -349
  35. data/app/views/user_mailer/no_submissions_reminder.text.erb +0 -4
  36. data/app/views/user_mailer/notification.html.erb +1 -0
  37. data/app/views/user_mailer/notification.text.erb +6 -0
  38. data/app/views/user_mailer/notifications/_custom.html.erb +11 -0
  39. data/app/views/user_mailer/notifications/_exam_authorization_request_updated.html.erb +1 -0
  40. data/app/views/user_mailer/notifications/_exam_registration.html.erb +7 -0
  41. data/app/views/user_mailer/notifications/exam_authorization_request_updated/_approved.html.erb +7 -0
  42. data/app/views/user_mailer/notifications/exam_authorization_request_updated/_rejected.html.erb +7 -0
  43. data/app/views/users/manage_notifications.html.erb +26 -0
  44. data/app/views/users/notifications.html.erb +54 -0
  45. data/config/routes.rb +4 -0
  46. data/lib/mumuki/laboratory/controllers/notifications.rb +2 -2
  47. data/lib/mumuki/laboratory/locales/en.yml +34 -1
  48. data/lib/mumuki/laboratory/locales/es-CL.yml +34 -1
  49. data/lib/mumuki/laboratory/locales/es.yml +35 -2
  50. data/lib/mumuki/laboratory/locales/pt.yml +34 -1
  51. data/lib/mumuki/laboratory/version.rb +1 -1
  52. data/spec/controllers/users_controller_spec.rb +48 -0
  53. data/spec/dummy/db/schema.rb +7 -1
  54. data/spec/features/notifications_flow_spec.rb +2 -1
  55. data/spec/mailers/previews/user_mailer_preview.rb +45 -1
  56. metadata +24 -9
  57. data/app/views/notifications/_discussion.html.erb +0 -1
  58. data/app/views/notifications/_exam_authorization_request.html.erb +0 -1
  59. data/app/views/notifications/_message.html.erb +0 -1
@@ -1,5 +1,5 @@
1
1
  module Mumuki
2
2
  module Laboratory
3
- VERSION = '9.10.0'
3
+ VERSION = '9.11.0'
4
4
  end
5
5
  end
@@ -19,4 +19,52 @@ describe UsersController, type: :controller, organization_workspace: :test do
19
19
  it { expect(User.last.verified_first_name).to be_nil }
20
20
  end
21
21
 
22
+ context 'notifications' do
23
+ context 'get' do
24
+ context 'when logged in' do
25
+ before { set_current_user! user }
26
+ before { get :notifications }
27
+
28
+ it { expect(response.status).to eq 200 }
29
+ end
30
+
31
+ context 'when not logged in' do
32
+ before { get :notifications }
33
+
34
+ it { expect(response.status).to eq 302 }
35
+ end
36
+ end
37
+
38
+ context 'toggle_read' do
39
+ before { set_current_user! user }
40
+ before { post :toggle_read, params: { id: notification.id } }
41
+
42
+ context 'on toggling own notification read' do
43
+ let(:notification) { create :notification, user: user }
44
+
45
+ it { expect(response.status).to eq 302 }
46
+ it { expect(notification.reload.read?).to be true }
47
+ end
48
+
49
+ context 'on toggling someone else\'s notification read' do
50
+ let(:notification) { create :notification, user: create(:user) }
51
+
52
+ it { expect(response.status).to eq 404 }
53
+ it { expect(notification.reload.read?).to be false }
54
+ end
55
+ end
56
+
57
+ context 'notifications/manage' do
58
+ context 'post' do
59
+ let(:user) { create :user, ignored_notifications: [] }
60
+
61
+ before { set_current_user! user }
62
+ before { post :manage_notifications, params: { notifications: {'custom' => 1, 'exam_registrations' => 0 } } }
63
+
64
+ it { expect(response.status).to eq 302 }
65
+ it { expect(flash.notice).to eq 'Preferences updated successfully' }
66
+ it { expect(user.reload.ignored_notifications).to eq ['exam_registrations'] }
67
+ end
68
+ end
69
+ end
22
70
  end
@@ -10,7 +10,7 @@
10
10
  #
11
11
  # It's strongly recommended that you check this file into your version control system.
12
12
 
13
- ActiveRecord::Schema.define(version: 20210707143002) do
13
+ ActiveRecord::Schema.define(version: 20210803175124) do
14
14
 
15
15
  # These are extensions that must be enabled in order to support this database
16
16
  enable_extension "plpgsql"
@@ -193,6 +193,7 @@ ActiveRecord::Schema.define(version: 20210707143002) do
193
193
  t.bigint "organization_id"
194
194
  t.datetime "created_at", null: false
195
195
  t.datetime "updated_at", null: false
196
+ t.boolean "processed", default: false
196
197
  t.index ["organization_id"], name: "index_exam_registrations_on_organization_id"
197
198
  end
198
199
 
@@ -399,6 +400,10 @@ ActiveRecord::Schema.define(version: 20210707143002) do
399
400
  t.bigint "organization_id"
400
401
  t.datetime "created_at", null: false
401
402
  t.datetime "updated_at", null: false
403
+ t.integer "subject"
404
+ t.text "custom_title"
405
+ t.text "custom_content_plain_text"
406
+ t.text "custom_content_html"
402
407
  t.index ["organization_id"], name: "index_notifications_on_organization_id"
403
408
  t.index ["target_type", "target_id"], name: "index_notifications_on_target_type_and_target_id"
404
409
  t.index ["user_id"], name: "index_notifications_on_user_id"
@@ -529,6 +534,7 @@ ActiveRecord::Schema.define(version: 20210707143002) do
529
534
  t.boolean "uppercase_mode"
530
535
  t.string "delete_account_token"
531
536
  t.datetime "delete_account_token_expiration_date"
537
+ t.text "ignored_notifications"
532
538
  t.index ["avatar_type", "avatar_id"], name: "index_users_on_avatar_type_and_avatar_id"
533
539
  t.index ["disabled_at"], name: "index_users_on_disabled_at"
534
540
  t.index ["last_organization_id"], name: "index_users_on_last_organization_id"
@@ -22,7 +22,8 @@ feature 'Notifications Flow', organization_workspace: :test do
22
22
  let(:exam_authorization_request) { create(:exam_authorization_request, exam_registration: exam_registration, user: user) }
23
23
 
24
24
  let!(:notifications) do
25
- [exam_registration, exam_authorization_request].map { |target| create(:notification, user: user, target: target ) }
25
+ create(:notification, user: user, target: exam_registration, subject: :exam_registration )
26
+ create(:notification, user: user, target: exam_authorization_request, subject: :exam_authorization_request_updated )
26
27
  end
27
28
 
28
29
  before { visit '/' }
@@ -3,7 +3,51 @@ class UserMailerPreview < ActionMailer::Preview
3
3
 
4
4
  # Preview this email at http://localhost:3000/rails/mailers/user_mailer/we_miss_you_notification
5
5
  def we_miss_you_reminder
6
- UserMailer.we_miss_you_reminder(User.new, 1)
6
+ UserMailer.we_miss_you_reminder user, 1
7
7
  end
8
8
 
9
+ def custom_content_plain_text_notification
10
+ UserMailer.notification notification
11
+ end
12
+
13
+ def custom_content_html_notification
14
+ UserMailer.notification notification(custom_content_html: 'This is <em>the text</em> of the mail. <strong>Awesome!</strong>')
15
+ end
16
+
17
+ def certificate_preview
18
+ UserMailer.certificate certificate
19
+ end
20
+
21
+ private
22
+
23
+ def user
24
+ User.new uid: 'some_user@gmail.com',
25
+ first_name: 'Some',
26
+ last_name: 'User',
27
+ verified_first_name: 'Jane',
28
+ verified_last_name: 'Doe',
29
+ last_organization: organization
30
+ end
31
+
32
+ def organization
33
+ Organization.central
34
+ end
35
+
36
+ def certificate
37
+ certificate_program = CertificateProgram.find_or_create_by!(title: 'Mumuki Certificate',
38
+ description: 'Functional Programming',
39
+ organization: organization,
40
+ start_date: 1.minute.ago,
41
+ end_date: 1.hour.since)
42
+
43
+ Certificate.new user: user, certificate_program: certificate_program
44
+ end
45
+
46
+ def notification(**hash)
47
+ Notification.new({user: user,
48
+ organization: organization,
49
+ subject: :custom,
50
+ custom_content_plain_text: 'This is the text of the mail. Awesome!',
51
+ custom_title: 'This is the title!'}.merge hash)
52
+ end
9
53
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mumuki-laboratory
3
3
  version: !ruby/object:Gem::Version
4
- version: 9.10.0
4
+ version: 9.11.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Franco Bulgarelli
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-07-29 00:00:00.000000000 Z
11
+ date: 2021-08-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -30,14 +30,14 @@ dependencies:
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: 9.10.0
33
+ version: 9.11.0
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: 9.10.0
40
+ version: 9.11.0
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: mumukit-bridge
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -114,14 +114,14 @@ dependencies:
114
114
  requirements:
115
115
  - - "~>"
116
116
  - !ruby/object:Gem::Version
117
- version: 3.0.2.2
117
+ version: '3.0'
118
118
  type: :runtime
119
119
  prerelease: false
120
120
  version_requirements: !ruby/object:Gem::Requirement
121
121
  requirements:
122
122
  - - "~>"
123
123
  - !ruby/object:Gem::Version
124
- version: 3.0.2.2
124
+ version: '3.0'
125
125
  - !ruby/object:Gem::Dependency
126
126
  name: muvment
127
127
  requirement: !ruby/object:Gem::Requirement
@@ -564,6 +564,7 @@ files:
564
564
  - app/helpers/menu_bar_helper.rb
565
565
  - app/helpers/messages_helper.rb
566
566
  - app/helpers/multiple_file_editor_helper.rb
567
+ - app/helpers/notifications_helper.rb
567
568
  - app/helpers/open_graph_helper.rb
568
569
  - app/helpers/organization_breadcrumbs_helper.rb
569
570
  - app/helpers/overlapped_buttons_helper.rb
@@ -694,21 +695,33 @@ files:
694
695
  - app/views/layouts/modals/_level_up.html.erb
695
696
  - app/views/layouts/modals/_new_message.html.erb
696
697
  - app/views/lessons/show.html.erb
697
- - app/views/notifications/_discussion.html.erb
698
+ - app/views/notifications/_custom.html.erb
698
699
  - app/views/notifications/_dropdown.html.erb
699
- - app/views/notifications/_exam_authorization_request.html.erb
700
+ - app/views/notifications/_exam_authorization_request_updated.html.erb
700
701
  - app/views/notifications/_exam_registration.html.erb
701
- - app/views/notifications/_message.html.erb
702
+ - app/views/notifications/previews/_custom.html.erb
703
+ - app/views/notifications/previews/_discussion.html.erb
704
+ - app/views/notifications/previews/_exam_authorization_request_updated.html.erb
705
+ - app/views/notifications/previews/_exam_registration.html.erb
706
+ - app/views/notifications/previews/_message.html.erb
702
707
  - app/views/user_mailer/1st_reminder.html.erb
703
708
  - app/views/user_mailer/1st_reminder.text.erb
704
709
  - app/views/user_mailer/2nd_reminder.html.erb
705
710
  - app/views/user_mailer/2nd_reminder.text.erb
706
711
  - app/views/user_mailer/3rd_reminder.html.erb
707
712
  - app/views/user_mailer/3rd_reminder.text.erb
713
+ - app/views/user_mailer/_mail_template.erb
708
714
  - app/views/user_mailer/certificate.html.erb
709
715
  - app/views/user_mailer/certificate.text.erb
710
716
  - app/views/user_mailer/no_submissions_reminder.html.erb
711
717
  - app/views/user_mailer/no_submissions_reminder.text.erb
718
+ - app/views/user_mailer/notification.html.erb
719
+ - app/views/user_mailer/notification.text.erb
720
+ - app/views/user_mailer/notifications/_custom.html.erb
721
+ - app/views/user_mailer/notifications/_exam_authorization_request_updated.html.erb
722
+ - app/views/user_mailer/notifications/_exam_registration.html.erb
723
+ - app/views/user_mailer/notifications/exam_authorization_request_updated/_approved.html.erb
724
+ - app/views/user_mailer/notifications/exam_authorization_request_updated/_rejected.html.erb
712
725
  - app/views/users/_activity_indicator.html.erb
713
726
  - app/views/users/_avatar_list.html.erb
714
727
  - app/views/users/_basic_profile_fields.html.erb
@@ -721,7 +734,9 @@ files:
721
734
  - app/views/users/discussions.html.erb
722
735
  - app/views/users/edit.html.erb
723
736
  - app/views/users/exam_authorizations.html.erb
737
+ - app/views/users/manage_notifications.html.erb
724
738
  - app/views/users/messages.html.erb
739
+ - app/views/users/notifications.html.erb
725
740
  - app/views/users/show.html.erb
726
741
  - app/views/users/terms.html.erb
727
742
  - config/i18n-tasks.yml
@@ -1 +0,0 @@
1
- <%= menu_item :comments, :new_discussion_message, url_for([target.item, target]), { title: target.item.name.truncate_words(3) } %>
@@ -1 +0,0 @@
1
- <%= menu_item :book_open, :exam_authorization_request_updated, exam_authorizations_user_path, { description: target.exam_registration.description } %>
@@ -1 +0,0 @@
1
- <%= menu_item :envelope, :new_message_received, url_for(target.exercise), { sender: target.sender } %>