diff --git a/yaraneba/.rubocop.yml b/yaraneba/.rubocop.yml index 419e08c7ef..0feb553e28 100644 --- a/yaraneba/.rubocop.yml +++ b/yaraneba/.rubocop.yml @@ -2,6 +2,10 @@ inherit_gem: fablicop: - "config/.base_rubocop.yml" +Rails/DynamicFindBy: + Exclude: + - 'spec/system/*' + Style/FrozenStringLiteralComment: Exclude: - 'db/**/*' diff --git a/yaraneba/app/controllers/tasks_controller.rb b/yaraneba/app/controllers/tasks_controller.rb index c9c3094002..064f98566f 100644 --- a/yaraneba/app/controllers/tasks_controller.rb +++ b/yaraneba/app/controllers/tasks_controller.rb @@ -5,7 +5,7 @@ class TasksController < ApplicationController # GET /tasks or /tasks.json def index - @tasks = Task.all + @tasks = Task.all.order(created_at: :desc) end # GET /tasks/1 or /tasks/1.json diff --git a/yaraneba/app/views/tasks/index.html.erb b/yaraneba/app/views/tasks/index.html.erb index 0289791e08..b53c85aeb9 100644 --- a/yaraneba/app/views/tasks/index.html.erb +++ b/yaraneba/app/views/tasks/index.html.erb @@ -10,18 +10,20 @@ <%= I18n.t('tasks.common.status') %> <%= I18n.t('tasks.common.priority') %> <%= I18n.t('tasks.common.end_date') %> + <%= I18n.t('tasks.common.created_at') %> - <% @tasks.each do |task| %> + <% @tasks.each_with_index do |task, i| %> - <%= task.title %> - <%= task.detail %> - <%= task.status %> - <%= task.priority %> - <%= task.end_date %> + <%= task.title %> + <%= task.detail %> + <%= task.status %> + <%= task.priority %> + <%= task.end_date %> + <%= task.created_at%> <%= link_to I18n.t('tasks.common.show'), task %> <%= link_to I18n.t('tasks.common.edit'), edit_task_path(task) %> <%= link_to I18n.t('tasks.common.destroy'), task, method: :delete, data: { confirm: I18n.t('tasks.index.confirm') } %> diff --git a/yaraneba/config/locales/views/ja.yml b/yaraneba/config/locales/views/ja.yml index d35d7f2d3e..b696a20063 100644 --- a/yaraneba/config/locales/views/ja.yml +++ b/yaraneba/config/locales/views/ja.yml @@ -6,6 +6,7 @@ ja: status: 'ステータス' priority: '優先順位' end_date: '終了予定日' + created_at: '作成日時' show: '詳細' edit: '編集' destroy: '削除' diff --git a/yaraneba/spec/factories/tasks.rb b/yaraneba/spec/factories/tasks.rb index 069dfff005..77479502a9 100644 --- a/yaraneba/spec/factories/tasks.rb +++ b/yaraneba/spec/factories/tasks.rb @@ -6,5 +6,6 @@ status { '1' } end_date { Date.yesterday } deleted_at { nil } + sequence(:created_at) { |n| Time.zone.now.since(n.day) } end end diff --git a/yaraneba/spec/system/tasks_spec.rb b/yaraneba/spec/system/tasks_spec.rb index ce4c58090d..36e515a9bc 100644 --- a/yaraneba/spec/system/tasks_spec.rb +++ b/yaraneba/spec/system/tasks_spec.rb @@ -3,7 +3,17 @@ require 'rails_helper' RSpec.describe 'Tasks', type: :system do + let!(:task) { create_list(:task, 10) } + describe '#task' do + it 'index task' do + visit root_path + + 9.times do |i| + expect(page.find_by_id("created_at-#{i}").text).to be > page.find_by_id("created_at-#{i + 1}").text + end + end + it 'create task' do visit new_task_path fill_in 'task_title', with: 'title'