Skip to content

Commit 39d530b

Browse files
author
RTLcoil
authored
Add test for context metadata as user variables
1 parent b8971df commit 39d530b

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

spec/utils_spec.rb

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1089,6 +1089,18 @@
10891089
t = Cloudinary::Utils.generate_transformation_string options, true
10901090
expect(t).to eq("$aheight_300,$mywidth_100/h_3_mul_ih_add_$aheight,w_3_add_$mywidth_mul_3_add_4_div_2_mul_iw_mul_$mywidth")
10911091
end
1092+
1093+
it "should use context value as user variables" do
1094+
options = {
1095+
:variables => [["$xpos", "ctx:!x_pos!_to_f"], ["$ypos", "ctx:!y_pos!_to_f"]],
1096+
:crop => "crop",
1097+
:x => "$xpos * w",
1098+
:y => "$ypos * h"
1099+
}
1100+
1101+
t = Cloudinary::Utils.generate_transformation_string options
1102+
expect(t).to eq("$xpos_ctx:!x_pos!_to_f,$ypos_ctx:!y_pos!_to_f,c_crop,x_$xpos_mul_w,y_$ypos_mul_h")
1103+
end
10921104
end
10931105

10941106
describe "context" do

0 commit comments

Comments
 (0)