Browse Source

#215 テスト・ケース追加

pull/219/head
みてるぞ 1 month ago
parent
commit
9e51fa7d34
5 changed files with 19 additions and 1 deletions
  1. +5
    -1
      backend/app/controllers/tags_controller.rb
  2. +1
    -0
      backend/config/application.rb
  3. +2
    -0
      backend/config/locales/ja.yml
  4. +7
    -0
      backend/spec/factories/wiki_pages.rb
  5. +4
    -0
      backend/spec/rails_helper.rb

+ 5
- 1
backend/app/controllers/tags_controller.rb View File

@@ -26,7 +26,11 @@ class TagsController < ApplicationController


def show def show
tag = Tag.find_by(id: params[:id]) tag = Tag.find_by(id: params[:id])
render json: tag.as_json(only: [:id, :category, :post_count], methods: [:name, :has_wiki])
if tag
render json: tag.as_json(only: [:id, :category, :post_count], methods: [:name, :has_wiki])
else
head :not_found
end
end end


def show_by_name def show_by_name


+ 1
- 0
backend/config/application.rb View File

@@ -11,6 +11,7 @@ module Backend
# Initialize configuration defaults for originally generated Rails version. # Initialize configuration defaults for originally generated Rails version.
config.load_defaults 8.0 config.load_defaults 8.0


config.i18n.available_locales = [:ja, :en]
config.i18n.default_locale = :ja config.i18n.default_locale = :ja


# Please, add to the `ignore` list any other `lib` subdirectories that do # Please, add to the `ignore` list any other `lib` subdirectories that do


+ 2
- 0
backend/config/locales/ja.yml View File

@@ -0,0 +1,2 @@
ja:
hello: 'ぬ゛〜゛ん゛'

+ 7
- 0
backend/spec/factories/wiki_pages.rb View File

@@ -0,0 +1,7 @@
FactoryBot.define do
factory :wiki_page do
title { "TestPage" }
association :created_user, factory: :user
association :updated_user, factory: :user
end
end

+ 4
- 0
backend/spec/rails_helper.rb View File

@@ -39,6 +39,10 @@ rescue ActiveRecord::PendingMigrationError => e
abort e.to_s.strip abort e.to_s.strip
end end
RSpec.configure do |config| RSpec.configure do |config|
config.before do
I18n.locale = :en
end

config.include TestRecords config.include TestRecords


# FactoryBot の create / create_list を使へるやぅにする # FactoryBot の create / create_list を使へるやぅにする


Loading…
Cancel
Save