Skip to content

Commit

Permalink
Merge pull request #7505 from fjordllc/feature/display-latest-10-noti…
Browse files Browse the repository at this point in the history
…fications-on-individual-notification-page

お知らせの個別ページに最新のお知らせを10件表示するようにした
  • Loading branch information
komagata authored Apr 20, 2024
2 parents 2b3bc4d + e62e677 commit 3e8699a
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 5 deletions.
4 changes: 3 additions & 1 deletion app/controllers/announcements_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ class AnnouncementsController < ApplicationController

def index; end

def show; end
def show
@announcements = Announcement.with_avatar.where(wip: false).order(published_at: :desc).limit(10)
end

def new
@announcement = Announcement.new(target: 'students')
Expand Down
13 changes: 13 additions & 0 deletions app/views/announcements/_recent_announcements.html.slim
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
.a-side-nav
.a-side-nav__inner
header.a-side-nav__header
h2.a-side-nav__title
| 最新のお知らせ
hr.a-border
.a-side-nav__body
.card-list
= render partial: 'home/announcement', collection: @announcements, as: :announcement
hr.a-border
footer.a-side-nav__footer
= link_to announcements_path, class: 'a-side-nav__footer-link' do
| 全てのお知らせ
10 changes: 6 additions & 4 deletions app/views/announcements/show.html.slim
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ header.page-header
| お知らせ一覧へ
hr.a-border
.page-body
.container.is-md
= render 'announcement', announcement: @announcement
#js-comments(data-commentable-id="#{@announcement.id}" data-commentable-type='Announcement' data-current-user-id="#{current_user.id}")
div(data-vue='Footprints' data-vue-footprintable-id="#{@announcement.id}" data-vue-footprintable-type='Announcement')
.page-body__inner.has-side-nav
.container.is-md
= render 'announcement', announcement: @announcement
#js-comments(data-commentable-id="#{@announcement.id}" data-commentable-type='Announcement' data-current-user-id="#{current_user.id}")
div(data-vue='Footprints' data-vue-footprintable-id="#{@announcement.id}" data-vue-footprintable-type='Announcement')
= render partial: 'recent_announcements'
5 changes: 5 additions & 0 deletions test/system/announcements_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -268,4 +268,9 @@ class AnnouncementsTest < ApplicationSystemTestCase
end
assert_equal '.file-input', find('textarea.a-text-input')['data-input']
end

test 'show the latest announcements' do
visit_with_auth "/announcements/#{announcements(:announcement1).id}", 'kimura'
assert_text '最新のお知らせ'
end
end

0 comments on commit 3e8699a

Please sign in to comment.