You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi, first thanks for the great work on this, it's very easy to setup.
I am using this on a devise model with rails 5 and so far it's all working fine, the only issue is when I try to create/save a record on the specs.
This is what I have: schema
create_table "users", force: :cascade do |t|
...
t.string "encrypted_session", default: "", null: false
t.string "encrypted_session_iv"
end
model
class User < ApplicationRecord
attr_encrypted :session, key: Rails.application.secrets.secret_key_attr_encrypt
validates :session, presence: true
end
spec
require "rails_helper"
RSpec.describe User, type: :model do
it { is_expected.to validate_presence_of(:session) }
describe ".session encryption" do
# this is fine
it "assigns an encrypted value to encrypted_session and encrypted_session_iv" do
user = User.new(session: Faker::Internet.password)
expect(user.encrypted_session).not_to be_empty
expect(user.encrypted_session_iv).not_to be_empty
end
it "returns the correct value after save" do
session = Faker::Internet.password
user = build(:user, session: session)
binding.pry
user.save
expect(user.session).to eq(session)
end
end
end
Hi, first thanks for the great work on this, it's very easy to setup.
I am using this on a devise model with rails 5 and so far it's all working fine, the only issue is when I try to create/save a record on the specs.
This is what I have:
schema
model
spec
the pry inspection
The error
The console and controller creation is fine
I've tried to put
attribute :session
at the model, but no successThanks for the help
The text was updated successfully, but these errors were encountered: