@@ -15,14 +15,19 @@ class BookmarksControllerTest < ActionDispatch::IntegrationTest
15
15
assert_nil flash [ :alert ]
16
16
end
17
17
18
+ test 'should not find bookmark' do
19
+ get user_bookmark_url ( users ( 'visitor_1' ) , bookmarks ( :one ) , format : :html )
20
+ assert_redirected_to user_bookmark_url ( users ( 'visitor_0' ) , Bookmark . last )
21
+ end
22
+
18
23
test 'should get new' do
19
- sign_in accounts 'maintainer_0 '
24
+ sign_in accounts 'visitor_0 '
20
25
get new_bookmark_url
21
26
assert_response :success
22
27
end
23
28
24
29
test 'should preview bookmark' do
25
- sign_in accounts 'maintainer_0 '
30
+ sign_in accounts 'visitor_0 '
26
31
assert_no_difference ( 'Bookmark.count' ) do
27
32
post bookmarks_url ,
28
33
params : {
@@ -38,7 +43,7 @@ class BookmarksControllerTest < ActionDispatch::IntegrationTest
38
43
end
39
44
40
45
test 'should create bookmark' do
41
- sign_in accounts 'maintainer_0 '
46
+ sign_in accounts 'visitor_0 '
42
47
assert_difference ( 'Bookmark.count' ) do
43
48
post bookmarks_url ,
44
49
params : {
@@ -50,7 +55,7 @@ class BookmarksControllerTest < ActionDispatch::IntegrationTest
50
55
tags : 'foo, bar'
51
56
}
52
57
end
53
- assert_redirected_to user_bookmark_url ( users ( 'maintainer_0 ' ) , Bookmark . last )
58
+ assert_redirected_to user_bookmark_url ( users ( 'visitor_0 ' ) , Bookmark . last )
54
59
end
55
60
56
61
test 'should get edit' do
@@ -59,6 +64,18 @@ class BookmarksControllerTest < ActionDispatch::IntegrationTest
59
64
assert_response :success
60
65
end
61
66
67
+ test 'should preview update' do
68
+ sign_in accounts 'admin_0'
69
+ patch user_bookmark_url ( users ( 'visitor_0' ) , bookmarks ( :one ) ) ,
70
+ params : {
71
+ bookmark : {
72
+ link : 'http://example.com'
73
+ } ,
74
+ commit : 'Prévisualiser'
75
+ }
76
+ assert_response :success
77
+ end
78
+
62
79
test 'should update bookmark' do
63
80
sign_in accounts 'admin_0'
64
81
patch user_bookmark_url ( users ( 'visitor_0' ) , bookmarks ( :one ) ) ,
@@ -70,6 +87,17 @@ class BookmarksControllerTest < ActionDispatch::IntegrationTest
70
87
assert_redirected_to user_bookmark_url ( users ( 'visitor_0' ) , bookmarks ( :one ) )
71
88
end
72
89
90
+ test 'should not update bookmark' do
91
+ sign_in accounts 'admin_0'
92
+ patch user_bookmark_url ( users ( 'visitor_0' ) , bookmarks ( :one ) ) ,
93
+ params : {
94
+ bookmark : {
95
+ title : ''
96
+ }
97
+ }
98
+ assert_response :success
99
+ end
100
+
73
101
test 'should destroy bookmark' do
74
102
sign_in accounts 'admin_0'
75
103
delete user_bookmark_url ( users ( 'visitor_0' ) , bookmarks ( :one ) )
0 commit comments