Files
Maikel Linke dcb6f4676d Remove all unnecessary spec_helper require statements
The `.rspec` file is doing this for us.
2026-01-21 12:35:34 +11:00

46 lines
1.5 KiB
Ruby

# frozen_string_literal: true
module PermittedAttributes
RSpec.describe User do
describe "simple usage" do
let(:user_permitted_attributes) { PermittedAttributes::User.new(params) }
describe "permits basic attributes" do
let(:params) {
ActionController::Parameters.new(user: { name: "John",
email: "email@example.com" } )
}
it "keeps permitted and removes not permitted" do
permitted_attributes = user_permitted_attributes.call
expect(permitted_attributes[:name]).to be nil
expect(permitted_attributes[:email]).to eq "email@example.com"
end
it "keeps extra permitted attributes" do
permitted_attributes = user_permitted_attributes.call([:name])
expect(permitted_attributes[:name]).to eq "John"
expect(permitted_attributes[:email]).to eq "email@example.com"
end
end
end
describe "with custom resource_name" do
let(:user_permitted_attributes) { PermittedAttributes::User.new(params, :spree_user) }
let(:params) {
ActionController::Parameters.new(spree_user: { name: "John",
email: "email@example.com" } )
}
it "keeps permitted and removes not permitted" do
permitted_attributes = user_permitted_attributes.call
expect(permitted_attributes[:name]).to be nil
expect(permitted_attributes[:email]).to eq "email@example.com"
end
end
end
end