Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

卒業生に通知がいかないように修正 & テストの修正 #4141

Merged
merged 8 commits into from
Feb 14, 2022
4 changes: 2 additions & 2 deletions app/javascript/notifications.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<template lang="pug">
.container.is-md(v-if='!loaded')
#notifications.container.is-md.loaing(v-if='!loaded')
loadingListPlaceholder
.container(v-else-if='notifications.length === 0')
.o-empty-message
Expand All @@ -9,7 +9,7 @@
| 未読の通知はありません
p.o-empty-message__text(v-else)
| 通知はありません
.container.is-md(v-else)
#notifications.container.is-md.loaded(v-else)
nav.pagination(v-if='totalPages > 1')
pager(v-bind='pagerProps')
.thread-list.a-card
Expand Down
2 changes: 1 addition & 1 deletion app/models/notification_facade.rb
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ def self.came_question(question, receiver)
end

def self.first_report(report, receiver)
Notification.first_report(report, receiver) if receiver.student_or_trainee? || receiver.admin_or_mentor?
Notification.first_report(report, receiver) if receiver.current_student? || receiver.admin_or_mentor?
return unless receiver.mail_notification? && !receiver.retired?

NotificationMailer.with(
Expand Down
4 changes: 4 additions & 0 deletions app/models/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -459,6 +459,10 @@ def student?
!admin? && !adviser? && !mentor? && !trainee?
end

def current_student?
!admin? && !adviser? && !mentor? && !graduated? && !retired?
end

def staff?
admin? || mentor? || adviser?
end
Expand Down
2 changes: 1 addition & 1 deletion app/views/application/_header.html.slim
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ header.header
.header__start
= link_to root_path, class: 'header__title' do
= image_tag('pjord-face.svg', alt: 'プログラミングスクール', class: 'header__title-image')
- unless current_user.student_or_trainee?
- unless current_user.current_student?
.a-user-role.is-header
- if current_user.graduated_on?
span.a-user-role__label(class='is-graduate') 卒業生
Expand Down
10 changes: 7 additions & 3 deletions test/system/notification/reports_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
class Notification::ReportsTest < ApplicationSystemTestCase
test 'the first daily report notification is sent only to current students and mentors' do
report = users(:muryou).reports.create!(
title: 'test title',
description: 'test',
title: '初日報です',
description: '初日報の内容です',
reported_on: Date.current
)

Expand All @@ -20,16 +20,20 @@ class Notification::ReportsTest < ApplicationSystemTestCase
)

notification_message = 'muryouさんがはじめての日報を書きました!'
visit_with_auth '/notifications', 'komagata'
visit_with_auth '/notifications', 'machida'
find('#notifications.loaded', wait: 10)
assert_text notification_message

visit_with_auth '/notifications', 'kimura'
find('#notifications.loaded', wait: 10)
assert_text notification_message

visit_with_auth '/notifications', 'advijirou'
find('#notifications.loaded', wait: 10)
assert_no_text notification_message

visit_with_auth '/notifications', 'sotugyou'
find('#notifications.loaded', wait: 10)
assert_no_text notification_message
end

Expand Down