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

/sponsorshipsページの新規作成 #8338

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
Open
19 changes: 19 additions & 0 deletions app/controllers/articles/sponsorships_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# frozen_string_literal: true

class Articles::SponsorshipsController < ApplicationController
skip_before_action :require_active_user_login, raise: false, only: %i[index]
PAGER_NUMBER = 12

layout 'lp'

def index
@articles = sponsorships_articles.per(PAGER_NUMBER)
end

private

def sponsorships_articles
Article.with_attached_thumbnail.includes(user: { avatar_attachment: :blob })
.where(thumbnail_type: :sponsorship, wip: false).order(published_at: :desc).page(params[:page])
end
end
5 changes: 5 additions & 0 deletions app/views/articles/sponsorships/index.html.slim
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
ruby:
title 'ブログ'
set_meta_tags(site: 'FJORD BOOT CAMP(フィヨルドブートキャンプ)')
description 'オンラインプログラミングフィヨルドブートキャンプのスポンサーに関するブログ記事一覧ページです。'
= render '/articles/articles', { articles: @articles, is_published: true }
3 changes: 3 additions & 0 deletions app/views/shared/_not_logged_in_footer.html.slim
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ footer.not-logged-in-footer
li.not-logged-in-footer__nav-item
= link_to press_kit_path, class: 'not-logged-in-footer__nav-item-link' do
| プレスキット
li.not-logged-in-footer__nav-item
= link_to sponsorships_path, class: 'not-logged-in-footer__nav-item-link' do
| スポンサー実績
- if admin_login?
// TODO リスキル講座 公開したら if を外す
li.not-logged-in-footer__nav-item
Expand Down
1 change: 1 addition & 0 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@
resource :billing_portal, only: :create, controller: "billing_portal"
resources :external_entries, only: %i(index)
get "articles/tags/:tag", to: "articles#index", as: :tag, tag: /.+/
get 'sponsorships', to: 'articles/sponsorships#index'
get "pages/tags/:tag", to: "pages#index", as: :pages_tag, tag: /.+/, format: "html"
get "questions/tags/:tag", to: "questions#index", as: :questions_tag, tag: /.+/, format: "html"
get "login" => "user_sessions#new", as: :login
Expand Down
11 changes: 11 additions & 0 deletions db/fixtures/articles.yml
Original file line number Diff line number Diff line change
Expand Up @@ -90,3 +90,14 @@ article<%= id %>:
wip: false
published_at: "2022-03-14 00:00:00"
<% end %>

<% (41..55).each do |id| %>
article<%= id %>:
title: test title<%= id %>
body: |-
test body<%= id %>
user: komagata
wip: false
published_at: "2022-03-14 00:00:00"
thumbnail_type: :sponsorship
<% end %>
12 changes: 10 additions & 2 deletions test/fixtures/articles.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ article1:
body: サムネイルは「/public/ogp/」配下にある画像を使っています。
user: komagata
wip: false
published_at: "2022-01-01 00:00:00"
published_at: '2022-01-01 00:00:00'
thumbnail_type: :ruby_on_rails

article2:
title: タイトル2
body: サムネイルにはデフォルトの画像を使います。
user: machida
wip: false
published_at: "2022-01-02 00:00:00"
published_at: '2022-01-02 00:00:00'
thumbnail_type: :prepared_thumbnail

article3:
Expand All @@ -21,3 +21,11 @@ article3:
wip: true
thumbnail_type: :prepared_thumbnail
token: abcdef123456

article4:
title: タイトル4
body: sponsorshipページに表示される記事です。
user: komagata
wip: false
published_at: '2022-01-01 00:00:00'
thumbnail_type: :sponsorship
12 changes: 12 additions & 0 deletions test/system/article/sponsorships_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# frozen_string_literal: true

require 'application_system_test_case'

class Article::SponsorshipsTest < ApplicationSystemTestCase
test 'show listing sponsorship articles' do
visit_with_auth sponsorships_path, 'komagata'
assert_selector '.thumbnail-card__inner', count: 1
click_link_or_button 'ブログ記事のブランクアイキャッチ画像'
assert_text 'sponsorshipページに表示される記事です。'
end
end