@@ -209,54 +209,4 @@ def valid_attributes
209209 end
210210 end
211211 end
212-
213- describe "CustomFieldSymbolProxy" do
214- let ( :field_metadata ) do
215- [
216- { id : 1 , title : "foo" } ,
217- { id : 2 , title : "bar" }
218- ]
219- end
220- let ( :client ) do
221- double ( "Client" , instance_variable_get : field_metadata )
222- end
223- let ( :ticket ) do
224- t = ZendeskAPI ::Ticket . allocate
225- t . instance_variable_set ( :@client , client )
226- t . instance_variable_set ( :@custom_fields , [ { id : 1 , value : "abc" } ] )
227- t
228- end
229- let ( :proxy ) { ZendeskAPI ::Ticket ::CustomFieldSymbolProxy . new ( ticket ) }
230-
231- it "reads a custom field by symbol" do
232- expect ( proxy [ "foo" ] ) . to eq ( "abc" )
233- end
234-
235- it "raises error for missing field" do
236- expect { proxy [ "baz" ] } . to raise_error ( /Cannot find custom field/ )
237- end
238-
239- it "writes a custom field by symbol" do
240- proxy [ "bar" ] = "def"
241- expect ( ticket . custom_fields . find { |h | h [ :id ] == 2 } [ :value ] ) . to eq ( "def" )
242- end
243-
244- it "delegates to_a" do
245- expect ( proxy . to_a ) . to eq ( ticket . custom_fields )
246- end
247-
248- it "delegates method_missing and respond_to_missing?" do
249- expect ( proxy . respond_to? ( :each ) ) . to be true
250- expect ( proxy . map { |h | h [ :id ] } ) . to eq ( [ 1 ] )
251- end
252-
253- describe "integration with Ticket methods" do
254- it "returns proxy from custom_field_symbol accessor" do
255- t = ZendeskAPI ::Ticket . allocate
256- t . instance_variable_set ( :@client , client )
257- t . instance_variable_set ( :@custom_fields , [ { id : 1 , value : "abc" } ] )
258- expect ( t . custom_field_symbol [ "foo" ] ) . to eq ( "abc" )
259- end
260- end
261- end
262212end
0 commit comments