A controller method that processes a joined signup calls upon a model method that creates a value for activation_token
for the user. But how can I access that value in an integration test such as the one below?
The controller method basically comes down to if everything saved
@user.create_token
end
. And the model method is:
def create_token
self.activation_token = User.new_token
self.activation_digest = User.digest(activation_token)
update_attribute(:activation_digest, self.activation_digest)
update_columns(activation_sent_at: Time.zone.now)
end
The above works but how can I access the activation_token
in an integration test:
assert_difference ['Organization.count', 'User.count'], 1 do
post organizations_path,
organization: { name: "Abc1",
users_attributes: { "0" => { email: "adef1@uniqu.br",
username: "adef111",
admin: true,
password: "foobar",
password_confirmation: "foobar"} } }
end
assert_equal 1, ActionMailer::Base.deliveries.size
organization = assigns(:organization)
user = organization.users.first
# how can I then here access the activation_token? user.activation_token does not work.
Aucun commentaire:
Enregistrer un commentaire