Stricter validations for Enigma problem tags

pull/1163/head
Rick Carlino 2019-04-18 17:10:45 -07:00
parent fb37b00af4
commit 12806e849f
2 changed files with 7 additions and 2 deletions

View File

@ -6,4 +6,5 @@ class Enigma < ApplicationRecord
USER = "api.user.not_welcomed",
DOCUMENTATION = "api.documentation.unread"
]
validates_inclusion_of :problem_tag, in: PROBLEM_TAGS
end

View File

@ -130,8 +130,12 @@ describe Api::UsersController do
expect(user.name).to eq("Frank")
expect(user.email).to eq(email)
expect(user.valid_password?("Password123")).to be_truthy
expect(user.device.enigmas.count).to eq(1)
expect(user.device.enigmas.first.problem_tag).to eq(Enigma::SEED_DATA)
expect(user.device.enigmas.count).to eq(4)
tags = user.device.enigmas.pluck(:problem_tag)
expect(tags).to include(Enigma::SEED_DATA)
expect(tags).to include(Enigma::TOUR)
expect(tags).to include(Enigma::USER)
expect(tags).to include(Enigma::DOCUMENTATION)
end
end
end