Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # new validation method in ConSub.rb
- def mobile_number_validate
- if new_record? && (subscription_type == "web_subscription" || subscription_type == 'mobile_subcription')
- user.phone2 = self.mobile_phone
- if user.save
- @qmobile_notification = QmobileNotifier.new
- @qmobile_notification.user = user
- @qmobile_notification.request_type = "carrier_lookup"
- @qmobile_notification.save
- @qmobile_notification.carrier_request
- unless @qmobile_notification.status == "completed_successfully"
- errors.add(:mobile_phone, "number could not be matched with a carrier. Please contact [email protected]")
- end
- else
- errors.add(:mobile_phone, "your number could not be saved. Please contact [email protected]")
- end
- else
- true
- end
- end
- # test for this method
- def test_should_display_error_message_if_already_subscribed_phone_number_is_used_for_a_new_subscription
- setup_subscription_with_associations
- @alice = create_user
- @alices_notifier = create_qmobile_notifier( :resource => @bobs_image,
- :user => @alice,
- :sms_text => "max",
- :created_at => " 2008-04-13 02:16:54")
- @alices_sub = @alice.content_subscriptions.new( :qmobile_notifier => @alices_notifier,
- :mobile_phone => @bob.phone2,
- :content => @bobs_image,
- :created_at => " 2008-04-13 02:16:55")
- deny @alices_sub.valid?, "Alice's consub should be invalid:\n#{@alices_sub.to_yaml}"
- end
- # error
- 1) [33mError[0m:
- test_should_display_error_message_if_already_subscribed_phone_number_is_used_for_a_new_subscription(ContentSubscriptionTest):
- NoMethodError: You have a nil object when you didn't expect it!
- The error occurred while evaluating nil.phone2=
- method mobile_number_validate in content_subscription.rb at line 218
- method send in validations.rb at line 818
- method run_validations in validations.rb at line 818
- method each in validations.rb at line 816
- method run_validations in validations.rb at line 816
- method valid_without_callbacks? in validations.rb at line 780
- method valid? in callbacks.rb at line 299
- method test_should_display_error_message_if_already_subscribed_phone_number_is_used_for_a_new_subscription in content_subscription_test.rb at line 73
- [31m1 tests, 0 assertions, 0 failures, 1 errors[0m
Add Comment
Please, Sign In to add comment