File tree Expand file tree Collapse file tree 1 file changed +26
-0
lines changed
Expand file tree Collapse file tree 1 file changed +26
-0
lines changed Original file line number Diff line number Diff line change @@ -109,4 +109,30 @@ class SubscriptionsControllerTest < ActionController::TestCase
109109 assert_valid_json_response
110110 assert_equal 'success' , JSON . parse ( response . body ) [ 'status' ]
111111 end
112+
113+ test 'qualifiers should correctly return available items based on type' do
114+ sign_in users ( :admin )
115+
116+ Subscription ::TYPES . each do |type |
117+ try_subscription_qualifiers ( type )
118+
119+ assert_response ( :success )
120+ assert_valid_json_response
121+
122+ items = JSON . parse ( response . body )
123+
124+ if Subscription ::QUALIFIED_TYPES . include? ( type )
125+ assert_not items . empty?
126+ assert ( items . all? { |i | i [ 'id' ] . present? && i [ 'text' ] . present? } )
127+ else
128+ assert items . empty?
129+ end
130+ end
131+ end
132+
133+ private
134+
135+ def try_subscription_qualifiers ( type , search : nil )
136+ get :qualifiers , params : { type : type , q : search }
137+ end
112138end
You can’t perform that action at this time.
0 commit comments