diff --git a/backend/app/controllers/tags_controller.rb b/backend/app/controllers/tags_controller.rb index ffa3527..baf0e7e 100644 --- a/backend/app/controllers/tags_controller.rb +++ b/backend/app/controllers/tags_controller.rb @@ -26,7 +26,11 @@ class TagsController < ApplicationController def show 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 def show_by_name diff --git a/backend/config/application.rb b/backend/config/application.rb index 14b74b9..24390bd 100644 --- a/backend/config/application.rb +++ b/backend/config/application.rb @@ -11,6 +11,7 @@ module Backend # Initialize configuration defaults for originally generated Rails version. config.load_defaults 8.0 + config.i18n.available_locales = [:ja, :en] config.i18n.default_locale = :ja # Please, add to the `ignore` list any other `lib` subdirectories that do diff --git a/backend/config/locales/ja.yml b/backend/config/locales/ja.yml new file mode 100644 index 0000000..47cf834 --- /dev/null +++ b/backend/config/locales/ja.yml @@ -0,0 +1,2 @@ +ja: + hello: 'ぬ゛〜゛ん゛' diff --git a/backend/spec/factories/wiki_pages.rb b/backend/spec/factories/wiki_pages.rb new file mode 100644 index 0000000..b4f1496 --- /dev/null +++ b/backend/spec/factories/wiki_pages.rb @@ -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 diff --git a/backend/spec/rails_helper.rb b/backend/spec/rails_helper.rb index 22122cb..480f4cb 100644 --- a/backend/spec/rails_helper.rb +++ b/backend/spec/rails_helper.rb @@ -39,6 +39,10 @@ rescue ActiveRecord::PendingMigrationError => e abort e.to_s.strip end RSpec.configure do |config| + config.before do + I18n.locale = :en + end + config.include TestRecords # FactoryBot の create / create_list を使へるやぅにする