@@ -7,16 +7,29 @@ defmodule CF.VideosTest do
77
88 defp test_url , do: "https://www.youtube.com/watch?v=#{ DB.Utils.TokenGenerator . generate ( 11 ) } "
99
10- describe "Add video" do
11- test "without enough reputation" do
10+ describe "Add" do
11+ test "video as unlisted without enough reputation" do
12+ user = insert ( :user , reputation: 0 , is_publisher: false )
13+
14+ assert_raise PermissionsError , fn ->
15+ Videos . create! ( user , test_url ( ) , unlisted: true )
16+ end
17+ end
18+
19+ test "video as unlisted with enough reputation" do
20+ user = insert ( :user , reputation: 15 )
21+ { :ok , _video } = Videos . create! ( user , test_url ( ) , unlisted: true )
22+ end
23+
24+ test "video as listed without enough reputation" do
1225 user = insert ( :user , reputation: 0 , is_publisher: false )
1326
1427 assert_raise PermissionsError , fn ->
1528 Videos . create! ( user , test_url ( ) )
1629 end
1730 end
1831
19- test "with enough reputation" do
32+ test "video as listed with enough reputation" do
2033 user = insert ( :user , reputation: 50_000 )
2134 { :ok , _video } = Videos . create! ( user , test_url ( ) )
2235 end
@@ -57,6 +70,40 @@ defmodule CF.VideosTest do
5770 end
5871 end
5972
73+ describe "Update" do
74+ test "an unlisted video without enough reputation" do
75+ user = insert ( :user , reputation: 50_000 )
76+ user2 = insert ( :user , reputation: 0 )
77+ { :ok , video } = Videos . create! ( user , test_url ( ) , unlisted: true )
78+
79+ assert_raise PermissionsError , fn ->
80+ Videos . shift_statements ( user2 , video . id , % { youtube_offset: 42 } )
81+ end
82+ end
83+
84+ test "an unlisted video with enough reputation" do
85+ user = insert ( :user , reputation: 15 )
86+ { :ok , video } = Videos . create! ( user , test_url ( ) , unlisted: true )
87+ { :ok , _video } = Videos . shift_statements ( user , video . id , % { youtube_offset: 42 } )
88+ end
89+
90+ test "a listed video without enough reputation" do
91+ user = insert ( :user , reputation: 50_000 )
92+ user2 = insert ( :user , reputation: 0 )
93+ { :ok , video } = Videos . create! ( user , test_url ( ) )
94+
95+ assert_raise PermissionsError , fn ->
96+ Videos . shift_statements ( user2 , video . id , % { youtube_offset: 42 } )
97+ end
98+ end
99+
100+ test "a listed video with enough reputation" do
101+ user = insert ( :user , reputation: 50_000 )
102+ { :ok , video } = Videos . create! ( user , test_url ( ) )
103+ { :ok , _video } = Videos . shift_statements ( user , video . id , % { youtube_offset: 42 } )
104+ end
105+ end
106+
60107 describe "Fetch captions" do
61108 test "fetch captions" do
62109 video =
0 commit comments