-
Notifications
You must be signed in to change notification settings - Fork 132
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
「7. 言及している日報を表示する」の差分 / 「8. Railsでテストを書く」のスタート地点 #5
Open
JunichiIto
wants to merge
20
commits into
07-report_mention
Choose a base branch
from
08-testing
base: 07-report_mention
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
35b8225
日報のメンション機能を実装
JunichiIto d110f7b
同じレポートへの言及はメンション対象外とする
JunichiIto 2638604
Merge branch '07-report_mention' into 08-testing
JunichiIto b0a817f
Merge branch '07-report_mention' into 08-testing
JunichiIto 398d331
Merge branch '07-report_mention' into 08-testing
JunichiIto ad354b9
Merge branch '07-report_mention' into 08-testing
JunichiIto 8fb87c0
Merge branch '07-report_mention' into 08-testing
JunichiIto e0fab4b
Refactor Report#save_mentions
JunichiIto 49c9140
Merge branch '07-report_mention' into 08-testing
JunichiIto e35545f
Merge branch '07-report_mention' into 08-testing
JunichiIto cbbbcde
Add mentions.css
JunichiIto 28b2197
Refactor save_mentions
JunichiIto 088baaa
Merge branch '07-report_mention' into 08-testing
JunichiIto e39a702
Merge branch '07-report_mention' into 08-testing
JunichiIto fb3d277
bundle install
JunichiIto c2809ac
Merge branch '07-report_mention' into 08-testing
JunichiIto bf2b4e2
関連の定義を修正
JunichiIto 0e60331
Merge branch '07-report_mention' into 08-testing
JunichiIto 492ef02
Install missing gems
JunichiIto 8e04440
関連の名称をわかりやすい名前に改善
JunichiIto File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -86,3 +86,4 @@ gem 'carrierwave' | |
gem 'devise' | ||
gem 'devise-i18n' | ||
gem 'kaminari' | ||
gem 'rails_autolink' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/**************** | ||
mentions-container | ||
****************/ | ||
|
||
.mentions-container { | ||
margin-top: 32px; | ||
max-width: var(--single-column-w); | ||
} | ||
|
||
.mentions-container p { | ||
font-size: var(--global-fz-md); | ||
line-height: 1.8; | ||
} | ||
|
||
.mentions-container ul { | ||
margin: 12px 0 0; | ||
padding-inline-start: 0; | ||
list-style: none; | ||
} | ||
|
||
.mentions-container li { | ||
padding-bottom: 12px; | ||
font-size: var(--global-fz-md); | ||
line-height: 1.8; | ||
} | ||
|
||
.mentions-container li:not(:first-of-type) { | ||
border-top: solid var(--global-bw) var(--global-bc-muted); | ||
padding-top: 12px; | ||
} | ||
|
||
.mentions-container li:last-of-type { | ||
padding-bottom: 0; | ||
} | ||
|
||
.mentions-container li small { | ||
display: block; | ||
font-size: 12px; | ||
margin-top: 8px; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# frozen_string_literal: true | ||
|
||
class ReportMention < ApplicationRecord | ||
belongs_to :mentioning, class_name: 'Report' | ||
belongs_to :mentioned, class_name: 'Report' | ||
|
||
validates :mentioned_id, uniqueness: { scope: :mentioning_id } | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<div class="mentions-container"> | ||
<strong><%= t('.title') %>:</strong> | ||
<% if mentioned_reports = report.mentioned_reports.includes(mentioned_reports: :user).order(id: :desc).presence %> | ||
<ul> | ||
<% mentioned_reports.each do |mentioned_report| %> | ||
<li> | ||
<%= link_to mentioned_report.title, mentioned_report %> | ||
<small> | ||
(<%= link_to mentioned_report.user.name_or_email, mentioned_report.user %> - <%= l mentioned_report.created_on %>) | ||
</small> | ||
</li> | ||
<% end %> | ||
</ul> | ||
<% else %> | ||
<p>(<%= t('.no_mentions') %>)</p> | ||
<% end %> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
class CreateReportMentions < ActiveRecord::Migration[7.0] | ||
def change | ||
create_table :report_mentions do |t| | ||
t.references :mention_to, null: false, foreign_key: { to_table: 'reports' }, index: false | ||
t.references :mentioned_by, null: false, foreign_key: { to_table: 'reports' } | ||
|
||
t.timestamps | ||
end | ||
add_index :report_mentions, %i[mention_to_id mentioned_by_id], unique: true | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
class RenameReportMentionsColumns < ActiveRecord::Migration[7.0] | ||
def change | ||
rename_column :report_mentions, :mention_to_id, :mentioning_id | ||
rename_column :report_mentions, :mentioned_by_id, :mentioned_id | ||
end | ||
end |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# Read about fixtures at https://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html | ||
|
||
# This model initially had no columns defined. If you add columns to the | ||
# model remove the "{}" from the fixture names and add the columns immediately | ||
# below each fixture, per the syntax in the comments below | ||
# | ||
one: {} | ||
# column: value | ||
# | ||
two: {} | ||
# column: value |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'test_helper' | ||
|
||
class ReportMentionTest < ActiveSupport::TestCase | ||
# test "the truth" do | ||
# assert true | ||
# end | ||
end |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(別解)後読みを使うと31行目の
flatten
をなくせます。