docbrown/spec/serializers/search/user_serializer_spec.rb
Molly Struve 385e167f74
Clear Elasticsearch Data Instead of Resetting Entire Index for Specs (#7602)
* Clear Elasticsearch Data Instead of Resetting Entire Index for Specs

* only reset for specs that are messing with index creation and deletion, recreate indexes before and after those

* add back elasticsearch meta info to specs and update data update specs

* update serializer specs

* update search and rest of specs with new meta data tag
2020-04-30 11:59:10 -04:00

16 lines
560 B
Ruby

require "rails_helper"
RSpec.describe Search::UserSerializer do
let(:user) { create(:user) }
it "serializes a user" do
data_hash = described_class.new(user).serializable_hash.dig(:data, :attributes)
expect(data_hash.keys).to include(:id, :name, :path, :username, :roles)
end
it "creates valid json for Elasticsearch", elasticsearch: "User" do
data_hash = described_class.new(user).serializable_hash.dig(:data, :attributes)
result = User::SEARCH_CLASS.index(user.id, data_hash)
expect(result["result"]).to eq("created")
end
end