-
Notifications
You must be signed in to change notification settings - Fork 71
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
提出物一覧のページの各タブの並びを昇順にした #4399
提出物一覧のページの各タブの並びを昇順にした #4399
Changes from all commits
cdf3797
ae73152
0ed0cb3
f01b98d
6b88d11
b5e759b
5628bce
7c83e5b
f0e0c0e
7f26a74
1a5550e
77168be
a500580
23845aa
e04d24d
46cbf32
43d5a94
3a52d85
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -49,8 +49,8 @@ class Product < ApplicationRecord | |
{ checks: { user: { avatar_attachment: :blob } } }) | ||
} | ||
scope :order_for_list, -> { order(created_at: :desc, id: :desc) } | ||
scope :order_for_not_wip_list, -> { order(published_at: :desc, id: :desc) } | ||
scope :order_for_self_assigned_list, -> { order(commented_at: :desc, published_at: :desc) } | ||
scope :ascending_by_date_of_publishing_and_id, -> { order(published_at: :asc, id: :asc) } | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. idは昇順がいいのか、降順がいいのかわからなかったのですが、 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 並び替えはこのように、
idは、昇順(上から見た並び順)に付与されたほうが、私も違和感がないと思いましたので、良いと思います〜 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @komagata |
||
scope :order_for_self_assigned_list, -> { order('commented_at asc nulls first, published_at asc') } | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
|
||
def self.add_latest_commented_at | ||
Product.all.includes(:comments).find_each do |product| | ||
|
@@ -122,13 +122,13 @@ def self.unchecked_no_replied_products_ids(current_user_id) | |
def self.self_assigned_no_replied_products(current_user_id) | ||
no_replied_product_ids = self_assigned_no_replied_product_ids(current_user_id) | ||
Product.where(id: no_replied_product_ids) | ||
.order(commented_at: :desc, published_at: :desc) | ||
.order(published_at: :asc, id: :asc) | ||
end | ||
Comment on lines
124
to
126
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 「自分の担当」の未返信で使われているのですが、未返信の時点で |
||
|
||
def self.unchecked_no_replied_products(current_user_id) | ||
no_replied_products_ids = unchecked_no_replied_products_ids(current_user_id) | ||
Product.where(id: no_replied_products_ids) | ||
.order(created_at: :desc) | ||
.order(published_at: :asc, id: :asc) | ||
end | ||
|
||
def completed?(user) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -356,20 +356,29 @@ product62: | |
practice: practice45 | ||
user: kimura | ||
body: 「自分の担当」かつ「未返信」の提出物 | ||
created_at: <%= 1.day.ago %> | ||
updated_at: <%= 1.day.ago %> | ||
published_at: <%= 1.day.ago %> | ||
wip: false | ||
checker_id: <%= ActiveRecord::FixtureSet.identify(:machida) %> | ||
|
||
product63: | ||
practice: practice46 | ||
user: kimura | ||
body: 「自分の担当」かつ「返信済み」の提出物 | ||
created_at: <%= 2.day.ago %> | ||
updated_at: <%= 2.day.ago %> | ||
published_at: <%= 2.day.ago %> | ||
wip: false | ||
checker_id: <%= ActiveRecord::FixtureSet.identify(:machida) %> | ||
|
||
product64: | ||
practice: practice10 | ||
user: kimura | ||
body: 担当者のいる提出物です。 | ||
created_at: <%= Time.current %> | ||
updated_at: <%= Time.current %> | ||
published_at: <%= Time.current %> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 日時の違う提出物が必要だったため、新たに定義 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ペアプロで、テスト実行時に必要だったため追記したとご説明いただきました:+1: |
||
checker_id: "<%= ActiveRecord::FixtureSet.identify(:machida) %>" | ||
|
||
product65: | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,8 @@ | |
require 'test_helper' | ||
|
||
class API::ProductsTest < ActionDispatch::IntegrationTest | ||
fixtures :products | ||
|
||
test 'GET /api/products.json' do | ||
get api_products_path(format: :json) | ||
assert_response :unauthorized | ||
|
@@ -42,4 +44,14 @@ class API::ProductsTest < ActionDispatch::IntegrationTest | |
headers: { 'Authorization' => "Bearer #{token}" } | ||
assert_response :ok | ||
end | ||
|
||
test 'should return products in order ' do | ||
token = create_token('machida', 'testtest') | ||
get api_products_self_assigned_index_path(format: :json), | ||
headers: { 'Authorization' => "Bearer #{token}" } | ||
|
||
expected = products(:product15, :product63, :product62, :product64).map { |product| product.practice.title } | ||
actual = response.parsed_body['products'].map { |product| product['practice']['title'] } | ||
assert_equal expected, actual | ||
Comment on lines
+53
to
+55
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. いでさんより、こちらのテストが何を検証しているかペアプロでご説明いただいたので書いておきます🙏
|
||
end | ||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,28 +28,20 @@ class Product::UnassignedTest < ApplicationSystemTestCase | |
.unassigned | ||
.unchecked | ||
.not_wip | ||
.order_for_not_wip_list | ||
.ascending_by_date_of_publishing_and_id | ||
.first | ||
assert_text newest_product.body | ||
end | ||
end | ||
|
||
test 'products order on unassigned tab' do | ||
# id順で並べたときの最初と最後の提出物を、提出日順で見たときに最新と最古になるように入れ替える | ||
Product.update_all(created_at: 1.day.ago, published_at: 1.day.ago) # rubocop:disable Rails/SkipsModelValidations | ||
newest_product = Product.unassigned.unchecked.not_wip.reorder(:id).first | ||
newest_product.update(published_at: Time.current) | ||
oldest_product = Product.unassigned.unchecked.not_wip.reorder(:id).last | ||
oldest_product.update(published_at: 2.days.ago) | ||
oldest_product = products(:product14) | ||
newest_product = products(:product26) | ||
|
||
visit_with_auth '/products/unassigned', 'komagata' | ||
|
||
# 提出日の降順で並んでいることを検証する | ||
titles = all('.thread-list-item-title__title').map { |t| t.text.gsub('★', '') } | ||
names = all('.thread-list-item-meta .a-user-name').map(&:text) | ||
assert_equal "#{newest_product.practice.title}の提出物", titles.first | ||
assert_equal newest_product.user.login_name, names.first | ||
assert_equal "#{oldest_product.practice.title}の提出物", titles.last | ||
assert_equal oldest_product.user.login_name, names.last | ||
# 提出日の昇順で並んでいることを検証する | ||
assert_equal 'OS X Mountain Lionをクリーンインストールする', oldest_product.practice.title | ||
assert_equal 'sshdでパスワード認証を禁止にする', newest_product.practice.title | ||
end | ||
end | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,31 +27,22 @@ class Product::UncheckedTest < ApplicationSystemTestCase | |
newest_product = Product | ||
.unchecked | ||
.not_wip | ||
.order_for_not_wip_list | ||
.ascending_by_date_of_publishing_and_id | ||
.first | ||
assert_text newest_product.body | ||
end | ||
end | ||
|
||
test 'products order on unchecked tab' do | ||
# id順で並べたときの最初と最後の提出物を、提出日順で見たときに最新と最古になるように入れ替える | ||
Product.update_all(created_at: 1.day.ago, published_at: 1.day.ago) # rubocop:disable Rails/SkipsModelValidations | ||
# 最古の提出物を画面上で判定するため、提出物を1ページ内に収める | ||
Product.unchecked.not_wip.limit(Product.count - Product.default_per_page).delete_all | ||
newest_product = Product.unchecked.not_wip.reorder(:id).first | ||
newest_product.update(published_at: Time.current) | ||
oldest_product = Product.unchecked.not_wip.reorder(:id).last | ||
oldest_product.update(published_at: 2.days.ago) | ||
oldest_product = products(:product14) | ||
newest_product = products(:product26) | ||
|
||
# 提出日の昇順で並んでいることを検証する | ||
visit_with_auth '/products/unchecked', 'komagata' | ||
assert_equal 'OS X Mountain Lionをクリーンインストールする', oldest_product.practice.title | ||
|
||
# 提出日の降順で並んでいることを検証する | ||
titles = all('.thread-list-item-title__title').map { |t| t.text.gsub('★', '') } | ||
names = all('.thread-list-item-meta .a-user-name').map(&:text) | ||
assert_equal "#{newest_product.practice.title}の提出物", titles.first | ||
assert_equal newest_product.user.login_name, names.first | ||
assert_equal "#{oldest_product.practice.title}の提出物", titles.last | ||
assert_equal oldest_product.user.login_name, names.last | ||
visit_with_auth '/products/unchecked?page=2', 'komagata' | ||
assert_equal 'sshdでパスワード認証を禁止にする', newest_product.practice.title | ||
end | ||
|
||
test 'not display products in listing unchecked if unchecked products all checked' do | ||
|
@@ -89,15 +80,7 @@ class Product::UncheckedTest < ApplicationSystemTestCase | |
end | ||
|
||
test 'display no-replied products if click on no-replied-button' do | ||
checker = users(:komagata) | ||
practice = practices(:practice47) | ||
user = users(:kimura) | ||
product = Product.create!( | ||
body: 'test', | ||
user: user, | ||
practice: practice, | ||
checker_id: checker.id | ||
) | ||
product = products(:product8) | ||
visit_with_auth "/products/#{product.id}", 'kimura' | ||
fill_in('new_comment[description]', with: 'test') | ||
click_button 'コメントする' | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. いでさんとペアプロしていただいた際にこちらのテストの意図を教えていただきましたので、メモしておきます〜
|
||
|
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.
created_at
をpublishe_at: :asc
に変更していただけますと幸いです。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.
こちら、自分の勘違いでした。
order_for_list
を提出物一覧ページで使っている部分はascending_by_date_of_publishing_and_id
に置き換えているのでここのcreated_at
は変更不要でした。