@@ -18,10 +18,7 @@ class ActiveStorage::Representations::ProxyControllerWithVariantsTest < ActionDi
18
18
19
19
assert_response :ok
20
20
assert_match ( /^attachment/ , response . headers [ "Content-Disposition" ] )
21
-
22
- image = read_image ( @blob . variant ( @transformations ) )
23
- assert_equal 100 , image . width
24
- assert_equal 67 , image . height
21
+ assert_equal @blob . variant ( @transformations ) . download , response . body
25
22
end
26
23
27
24
test "showing variant inline" do
@@ -32,10 +29,7 @@ class ActiveStorage::Representations::ProxyControllerWithVariantsTest < ActionDi
32
29
33
30
assert_response :ok
34
31
assert_match ( /^inline/ , response . headers [ "Content-Disposition" ] )
35
-
36
- image = read_image ( @blob . variant ( @transformations ) )
37
- assert_equal 100 , image . width
38
- assert_equal 67 , image . height
32
+ assert_equal @blob . variant ( @transformations ) . download , response . body
39
33
end
40
34
41
35
test "showing untracked variant" do
@@ -48,7 +42,7 @@ class ActiveStorage::Representations::ProxyControllerWithVariantsTest < ActionDi
48
42
49
43
assert_response :ok
50
44
assert_match ( /^attachment/ , response . headers [ "Content-Disposition" ] )
51
- assert_equal @blob . representation ( @transformations ) . download , response . body
45
+ assert_equal @blob . variant ( @transformations ) . download , response . body
52
46
end
53
47
end
54
48
@@ -74,52 +68,46 @@ class ActiveStorage::Representations::ProxyControllerWithVariantsTest < ActionDi
74
68
class ActiveStorage ::Representations ::ProxyControllerWithVariantsWithStrictLoadingTest < ActionDispatch ::IntegrationTest
75
69
setup do
76
70
@blob = create_file_blob filename : "racecar.jpg"
77
- @blob . variant ( resize_to_limit : [ 100 , 100 ] ) . processed
71
+ @transformations = { resize_to_limit : [ 100 , 100 ] }
72
+ @blob . variant ( @transformations ) . processed
78
73
end
79
74
80
75
test "showing existing variant record" do
81
76
with_strict_loading_by_default do
82
77
get rails_blob_representation_proxy_url (
83
78
filename : @blob . filename ,
84
79
signed_blob_id : @blob . signed_id ,
85
- variation_key : ActiveStorage ::Variation . encode ( resize_to_limit : [ 100 , 100 ] ) )
80
+ variation_key : ActiveStorage ::Variation . encode ( @transformations ) )
86
81
end
82
+
87
83
assert_response :ok
88
84
assert_match ( /^inline/ , response . headers [ "Content-Disposition" ] )
89
-
90
- @blob . reload # became free of strict_loading?
91
- image = read_image ( @blob . variant ( resize_to_limit : [ 100 , 100 ] ) )
92
- assert_equal 100 , image . width
93
- assert_equal 67 , image . height
85
+ assert_equal @blob . variant ( @transformations ) . download , response . body
94
86
end
95
87
end
96
88
97
89
class ActiveStorage ::Representations ::ProxyControllerWithPreviewsTest < ActionDispatch ::IntegrationTest
98
90
setup do
99
91
@blob = create_file_blob filename : "report.pdf" , content_type : "application/pdf"
92
+ @transformations = { resize_to_limit : [ 100 , 100 ] }
100
93
end
101
94
102
95
test "showing preview inline" do
103
96
get rails_blob_representation_proxy_url (
104
97
filename : @blob . filename ,
105
98
signed_blob_id : @blob . signed_id ,
106
- variation_key : ActiveStorage ::Variation . encode ( resize_to_limit : [ 100 , 100 ] ) )
99
+ variation_key : ActiveStorage ::Variation . encode ( @transformations ) )
107
100
108
101
assert_response :ok
109
102
assert_match ( /^inline/ , response . headers [ "Content-Disposition" ] )
110
-
111
- assert_predicate @blob . preview_image , :attached?
112
-
113
- image = read_image ( @blob . preview_image . variant ( resize_to_limit : [ 100 , 100 ] ) . processed )
114
- assert_equal 77 , image . width
115
- assert_equal 100 , image . height
103
+ assert_equal @blob . preview ( @transformations ) . download , response . body
116
104
end
117
105
118
106
test "showing preview with invalid signed blob ID" do
119
107
get rails_blob_representation_proxy_url (
120
108
filename : @blob . filename ,
121
109
signed_blob_id : "invalid" ,
122
- variation_key : ActiveStorage ::Variation . encode ( resize_to_limit : [ 100 , 100 ] ) )
110
+ variation_key : ActiveStorage ::Variation . encode ( @transformations ) )
123
111
124
112
assert_response :not_found
125
113
end
@@ -137,24 +125,20 @@ class ActiveStorage::Representations::ProxyControllerWithPreviewsTest < ActionDi
137
125
class ActiveStorage ::Representations ::ProxyControllerWithPreviewsWithStrictLoadingTest < ActionDispatch ::IntegrationTest
138
126
setup do
139
127
@blob = create_file_blob filename : "report.pdf" , content_type : "application/pdf"
140
- @blob . preview ( resize_to_limit : [ 100 , 100 ] ) . processed
128
+ @transformations = { resize_to_limit : [ 100 , 100 ] }
129
+ @blob . preview ( @transformations ) . processed
141
130
end
142
131
143
132
test "showing existing preview record" do
144
133
with_strict_loading_by_default do
145
134
get rails_blob_representation_proxy_url (
146
135
filename : @blob . filename ,
147
136
signed_blob_id : @blob . signed_id ,
148
- variation_key : ActiveStorage ::Variation . encode ( resize_to_limit : [ 100 , 100 ] ) )
137
+ variation_key : ActiveStorage ::Variation . encode ( @transformations ) )
149
138
end
150
139
151
140
assert_response :ok
152
141
assert_match ( /^inline/ , response . headers [ "Content-Disposition" ] )
153
- @blob . reload # became free of strict_loading?
154
- assert_predicate @blob . preview_image , :attached?
155
-
156
- image = read_image ( @blob . preview_image . variant ( resize_to_limit : [ 100 , 100 ] ) . processed )
157
- assert_equal 77 , image . width
158
- assert_equal 100 , image . height
142
+ assert_equal @blob . preview ( @transformations ) . download , response . body
159
143
end
160
144
end
0 commit comments