diff --git a/: b/: deleted file mode 100644 index 44fea5b..0000000 --- a/: +++ /dev/null @@ -1,22 +0,0 @@ -require 'rails_helper' - -RSpec.describe Character, type: :model do - describe 'ルック' do - let(:luc_records) { Character.where(name: 'ルック') } - - it '名前があること' do - expect(luc_records).to be_present - end - - # FIXME: 直す - xit '名前は一つだけ存在すること' do - expect(luc_records.size).to eq 1 - end - end - - xdescribe '"アビズボア,フェザー,ジークフリート"' do - it '分割されて記録されていること' do - expect(1 + 1).to eq 2 - end - end -end diff --git a/app/service/import_service/character.rb b/app/service/import_service/character.rb index 170ca77..f8e324a 100644 --- a/app/service/import_service/character.rb +++ b/app/service/import_service/character.rb @@ -69,7 +69,14 @@ def rows # rubocop:disable Metrics/AbcSize rows << [woven_star_foreign_key_id, woven_character, woven_yomi, woven_en] end - rows + # 複数作品に出ているキャラをまとめる + # 基準は [1] の要素である「キャラ名」になる + # group_by で key に row[1] 、 value に row を持つハッシュを作る + # そして map で value の最初の要素を取り出す(全ての value が等しいという前提) + # #first なのでその時点で uniq と同等になる + rows.group_by { |row| row[1] }.map do |_, row| + row.first + end end end end diff --git a/db/csv_on_sheet/characters/bases.csv b/db/csv_on_sheet/characters/bases.csv index 2040c67..7b54c1a 100644 --- a/db/csv_on_sheet/characters/bases.csv +++ b/db/csv_on_sheet/characters/bases.csv @@ -23,7 +23,7 @@ id,star_attr,s1,s1_yomi,s1_en,s2,s2_yomi,s2_en,s3,s3_yomi,s3_en,s4,s4_yomi,s4_en 22,天殺星,フー・スー・ルー,"","",ハンナ,"","",ハレック,"","",ゴー,"","",エルンスト,"","",ボッシュ,"","",ウッツェ,"","",李逵 23,天微星,キルキス,"","",キリィ,"","",クリス・ライトフェロー,"","",グレッチェン,"","",キリィ,"","",スフィール,"","",ニド,"","",史進 24,天究星,ミルイヒ・オッペンハイマー,"","",アニタ,"","",エステラ,"","",コンラッド,"","",シュラ・ヴァルヤ,"","",セレン,"","",ヤンセン,"","",穆弘 -25,天退星,パーン,"","","アビズボア,フェザー,ジークフリート","","",セシル,"","",ジュエル,"","",シュン,"","",ジェイル,"","",ジーノ,"","",雷横 +25,天退星,パーン,"","","アビズボア,フェザー,ジークフリード","","",セシル,"","",ジュエル,"","",シュン,"","",ジェイル,"","",ジーノ,"","",雷横 26,天寿星,ソニア・シューレン,"","",ナナミ,"","",ゲド,"","",カタリナ,"","",ベルナデット・イーガン,"","",ラジム,"","",イリア,"","",李俊 27,天剣星,アンジー,"","",リィナ,"","",メルヴィル,"","",ロウセン,"","",ヴォリガ,"","",ドロモン,"","",スニル,"","",阮小二 28,天平星,タイ・ホー,"","",タイ・ホー,"","",エース,"","",シラミネ,"","",ランス,"","",クロデキルド,"","",グワイニー,"","",張横 diff --git a/db/csv_on_sheet/gss_hq_characters_section/web_format_data.csv b/db/csv_on_sheet/gss_hq_characters_section/web_format_data.csv index 51791e6..023ade3 100644 --- a/db/csv_on_sheet/gss_hq_characters_section/web_format_data.csv +++ b/db/csv_on_sheet/gss_hq_characters_section/web_format_data.csv @@ -201,3 +201,4 @@ id,is_available,product_name,character_name,facility_or_position_name,role_of_hq 181,TRUE,紡時,ユディエラ & ゴンボスレン,鎧鍛冶,"","",7 182,TRUE,紡時,リュセリ,ハンティング,"","",7 183,TRUE,紡時,ルルサ & シャルフ & ビョルン & ヌミストロ,厨房,"","",7 +"",TRUE,幻水IV,ターニャ,図書室,"","",4 diff --git a/spec/models/character_spec.rb b/spec/models/character_spec.rb index 44fea5b..fbf8c65 100644 --- a/spec/models/character_spec.rb +++ b/spec/models/character_spec.rb @@ -8,15 +8,39 @@ expect(luc_records).to be_present end - # FIXME: 直す - xit '名前は一つだけ存在すること' do + it '名前は一つだけ存在すること' do expect(luc_records.size).to eq 1 end end - xdescribe '"アビズボア,フェザー,ジークフリート"' do - it '分割されて記録されていること' do - expect(1 + 1).to eq 2 + describe '間違えやすいキャラ' do + it '"ジークフリート" は存在しないこと' do + expect(Character.where(name: 'ジークフリート')).to be_blank + end + + it '"ウインドウ" が存在すること' do + expect(Character.where(name: 'ウインドウ')).to be_present + end + end + + describe '"アビズボア,フェザー,ジークフリード"' do + it 'まとめたレコードが記録されていないこと' do + expect(Character.where(name: 'アビズボア,フェザー,ジークフリード')).to be_blank + end + + it 'アビズボア が一つのレコードとして記録されていること' do + expect(Character.find_by(name: 'アビズボア')).to be_present + expect(Character.where(name: 'アビズボア').size).to eq 1 + end + + it 'フェザー が一つのレコードとして記録されていること' do + expect(Character.find_by(name: 'フェザー')).to be_present + expect(Character.where(name: 'フェザー').size).to eq 1 + end + + it 'ジークフリード が一つのレコードとして記録されていること' do + expect(Character.find_by(name: 'ジークフリード')).to be_present + expect(Character.where(name: 'ジークフリード').size).to eq 1 end end end diff --git a/spec/models/star_spec.rb b/spec/models/star_spec.rb index 134020b..59bb159 100644 --- a/spec/models/star_spec.rb +++ b/spec/models/star_spec.rb @@ -2,7 +2,7 @@ RSpec.describe Star, type: :model do describe 'Star クラス' do - xit 'レコードの数が 108 であること' do + it 'レコードの数が 108 であること' do stars = Star.all expect(stars.count).to eq 108 diff --git a/spec/service/download_csv_service_spec.rb b/spec/service/download_csv_service_spec.rb index 2279d17..e925dfa 100644 --- a/spec/service/download_csv_service_spec.rb +++ b/spec/service/download_csv_service_spec.rb @@ -22,7 +22,7 @@ expect( File.open('tmp/vault_test_check_first_row.csv').readline.chomp - ).to eq 'id,seating_order,category,name,name_kana,name_en' + ).to eq 'id,seating_order,category,name,yomi,name_en' end it '二行目(内容の行の一行目)の内容が期待どおりであること' do