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
validates :label, uniqueness: { scope: :account_id, message: "already exists for this account", allow_nil: true }
validates :label, uniqueness: { scope: :user_id, message: "already exists for this user", allow_nil: true }
And the following spec
describe "validations" do
subject { FactoryGirl.build(:access_token) }
it { FactoryGirl.create(:user_access_token, label: "Existing")
is_expected.to validate_uniqueness_of(:label).scoped_to(:user_id).with_message("already exists for this user").allow_nil }
it { FactoryGirl.create(:account_access_token, label: "Existing")
is_expected.to validate_uniqueness_of(:label).scoped_to(:account_id).with_message("already exists for this account").allow_nil }
end
With 2.x the spec was passing. With 3.x the spec is no longer passing with this error
Failure/Error: is_expected.to validate_uniqueness_of(:label).scoped_to(:user_id).with_message("already exists for this user").allow_nil }
Expected validation to be scoped to [:user_id], but it was scoped to [:account_id].
It looks like 3.x doesn't properly understand multiple uniqueness with different scopes on the same attribute.
The text was updated successfully, but these errors were encountered:
We have the following code in a model
And the following spec
With 2.x the spec was passing. With 3.x the spec is no longer passing with this error
It looks like 3.x doesn't properly understand multiple uniqueness with different scopes on the same attribute.
The text was updated successfully, but these errors were encountered: