@@ -54,6 +54,39 @@ def setup
54
54
assert ( session . valid? )
55
55
end
56
56
57
+ test "be valid with nil access_scopes" do
58
+ session = ShopifyAPI ::Session . new (
59
+ domain : "testshop.myshopify.com" ,
60
+ token : "any-token" ,
61
+ api_version : any_api_version ,
62
+ access_scopes : nil
63
+ )
64
+
65
+ assert ( session . valid? )
66
+ end
67
+
68
+ test "be valid with string of access_scopes" do
69
+ session = ShopifyAPI ::Session . new (
70
+ domain : "testshop.myshopify.com" ,
71
+ token : "any-token" ,
72
+ api_version : any_api_version ,
73
+ access_scopes : "read_products, write_orders"
74
+ )
75
+
76
+ assert ( session . valid? )
77
+ end
78
+
79
+ test "be valid with a collection of access_scopes" do
80
+ session = ShopifyAPI ::Session . new (
81
+ domain : "testshop.myshopify.com" ,
82
+ token : "any-token" ,
83
+ api_version : any_api_version ,
84
+ access_scopes : %w( read_products write_orders )
85
+ )
86
+
87
+ assert ( session . valid? )
88
+ end
89
+
57
90
test "not raise error without params" do
58
91
assert_nothing_raised do
59
92
ShopifyAPI ::Session . new ( domain : "testshop.myshopify.com" , token : "any-token" , api_version : any_api_version )
@@ -84,6 +117,36 @@ def setup
84
117
end
85
118
end
86
119
120
+ test "provides default nil access_scopes attribute" do
121
+ session = ShopifyAPI ::Session . new (
122
+ domain : "testshop.myshopify.com" ,
123
+ token : "any-token" ,
124
+ api_version : any_api_version
125
+ )
126
+ assert_nil session . access_scopes
127
+ end
128
+
129
+ test "provides specified nil access_scopes attribute" do
130
+ session = ShopifyAPI ::Session . new (
131
+ domain : "testshop.myshopify.com" ,
132
+ token : "any-token" ,
133
+ access_scopes : "read_products" ,
134
+ api_version : any_api_version
135
+ )
136
+ assert_equal "read_products" , session . access_scopes . to_s
137
+ end
138
+
139
+ test "session instantiation raises error if bad access scopes are provided" do
140
+ assert_raises do
141
+ ShopifyAPI ::Session . new (
142
+ domain : "testshop.myshopify.com" ,
143
+ token : "any-token" ,
144
+ access_scopes : { bad_input : "bad_input" } ,
145
+ api_version : any_api_version
146
+ )
147
+ end
148
+ end
149
+
87
150
test "raise error if params passed but signature omitted" do
88
151
assert_raises ( ShopifyAPI ::ValidationException ) do
89
152
session = ShopifyAPI ::Session . new ( domain : "testshop.myshopify.com" , token : nil , api_version : any_api_version )
0 commit comments