diff --git a/app/views/movies/show.html.slim b/app/views/movies/show.html.slim index 6d354371988..c224661d46e 100644 --- a/app/views/movies/show.html.slim +++ b/app/views/movies/show.html.slim @@ -1,4 +1,4 @@ -- title '動画' +- title "動画: #{@movie.title}" - set_meta_tags description: '動画「#{@movie.title}」ページです。' header.page-header diff --git a/test/fixtures/active_storage/attachments.yml b/test/fixtures/active_storage/attachments.yml index fe637dcb6e5..1927c4951d9 100644 --- a/test/fixtures/active_storage/attachments.yml +++ b/test/fixtures/active_storage/attachments.yml @@ -69,3 +69,24 @@ kimuramitai_profile_image: name: profile_image record: kimuramitai (User) blob: kimuramitai_profile_image_blob + +mp4_movie: + name: movie_data + record: movie1 (Movie) + blob: mp4_movie_blob + +mp4_thumbnail: + name: thumbnail + record: movie1 (Movie) + blob: mp4_thumbnail_blob + +mov_movie: + name: movie_data + record: movie2 (Movie) + blob: mov_movie_blob + + +mov_thumbnail: + name: thumbnail + record: movie2 (Movie) + blob: mov_thumbnail_blob diff --git a/test/fixtures/active_storage/blobs.yml b/test/fixtures/active_storage/blobs.yml index f1f541fc9bf..1eb6bea39c4 100644 --- a/test/fixtures/active_storage/blobs.yml +++ b/test/fixtures/active_storage/blobs.yml @@ -30,3 +30,11 @@ komagata_profile_image_blob: <%= ActiveStorage::Blob.fixture filename: "users/av machida_profile_image_blob: <%= ActiveStorage::Blob.fixture filename: "users/avatars/machida.jpg" %> kimuramitai_profile_image_blob: <%= ActiveStorage::Blob.fixture filename: "users/avatars/default.jpg" %> + +mp4_movie_blob: <%= ActiveStorage::Blob.fixture filename: "movies/sample.mp4" %> + +mp4_thumbnail_blob: <%= ActiveStorage::Blob.fixture filename: "movies/thumbnail_mp4.png" %> + +mov_movie_blob: <%= ActiveStorage::Blob.fixture filename: "movies/sample.mov" %> + +mov_thumbnail_blob: <%= ActiveStorage::Blob.fixture filename: "movies/thumbnail_mov.png" %> diff --git a/test/fixtures/files/movies/sample.mov b/test/fixtures/files/movies/sample.mov new file mode 100644 index 00000000000..138d88213e1 Binary files /dev/null and b/test/fixtures/files/movies/sample.mov differ diff --git a/test/fixtures/files/movies/sample.mp4 b/test/fixtures/files/movies/sample.mp4 new file mode 100644 index 00000000000..df70ba2d5d0 Binary files /dev/null and b/test/fixtures/files/movies/sample.mp4 differ diff --git a/test/fixtures/files/movies/thumbnail_mov.png b/test/fixtures/files/movies/thumbnail_mov.png new file mode 100644 index 00000000000..f014a755e1e Binary files /dev/null and b/test/fixtures/files/movies/thumbnail_mov.png differ diff --git a/test/fixtures/files/movies/thumbnail_mp4.png b/test/fixtures/files/movies/thumbnail_mp4.png new file mode 100644 index 00000000000..079b16e4f8d Binary files /dev/null and b/test/fixtures/files/movies/thumbnail_mp4.png differ diff --git a/test/fixtures/movies.yml b/test/fixtures/movies.yml index fe4e6894593..1c47caf1db1 100644 --- a/test/fixtures/movies.yml +++ b/test/fixtures/movies.yml @@ -1,13 +1,9 @@ -# Read about fixtures at https://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html +movie1: + title: mp4動画 + description: mp4の動画です + user: kimura -one: - title: MyString - description: MyText - tags: MyString - public_scope: 1 - -two: - title: MyString - description: MyText - tags: MyString - public_scope: 1 +movie2: + title: mov動画 + description: movの動画です + user: kimura diff --git a/test/system/movies_test.rb b/test/system/movies_test.rb new file mode 100644 index 00000000000..c79ddc5c12e --- /dev/null +++ b/test/system/movies_test.rb @@ -0,0 +1,63 @@ +# frozen_string_literal: true + +require 'application_system_test_case' + +class MoviesTest < ApplicationSystemTestCase + + test 'GET /movies' do + visit_with_auth '/movies', 'kimura' + assert_equal '動画 | FBC', title + end + + test 'show movie' do + visit_with_auth "/movies/#{movies(:movie1).id}", 'kimura' + assert_equal '動画: mp4動画 | FBC', title + end + + test 'page has a comment form ' do + visit_with_auth "/movies/#{movies(:movie1).id}", 'kimura' + assert_selector '.thread-comment-form' + end + + test 'add new mp4 movie' do + visit_with_auth new_movie_path, 'kimura' + assert_equal new_movie_path, current_path + fill_in 'movie[title]', with: '新規動画を作成する' + fill_in 'movie[description]', with: '新規動画を作成する本文です' + attach_file 'movie[movie_data]', 'test/fixtures/files/movies/sample.mp4' + click_button '動画を追加する' + assert_text '動画を追加しました' + end + + test 'add new mov movie' do + visit_with_auth new_movie_path, 'kimura' + assert_equal new_movie_path, current_path + fill_in 'movie[title]', with: '新規動画を作成する' + fill_in 'movie[description]', with: '新規動画を作成する本文です' + attach_file 'movie[movie_data]', 'test/fixtures/files/movies/sample.mov' + click_button '動画を追加する' + assert_text '動画を追加しました' + end + + test 'doc can relate practice' do + visit_with_auth new_movie_path, 'kimura' + fill_in 'movie[title]', with: '動画に関連プラクティスを指定' + fill_in 'movie[description]', with: '動画に関連プラクティスを指定' + first('.choices__inner').click + find('.choices__item--choice', text: '[UNIX] Linuxのファイル操作の基礎を覚える').click + attach_file 'movie[movie_data]', 'test/fixtures/files/movies/sample.mp4' + click_button '動画を追加する' + assert_text 'Linuxのファイル操作の基礎を覚える' + end + + test 'show comment count' do + visit_with_auth "/movies/#{movies(:movie1).id}", 'kimura' + assert_selector '#comment_count', text: 0 + + fill_in 'new_comment[description]', with: 'コメント数表示のテストです。' + click_button 'コメントする' + + visit current_path + assert_selector '#comment_count', text: 1 + end +end