Skip to content

Instantly share code, notes, and snippets.

@katienreed
Created April 28, 2017 17:24
Show Gist options
  • Save katienreed/a58837d618d3946192ca99131a0417a7 to your computer and use it in GitHub Desktop.
Save katienreed/a58837d618d3946192ca99131a0417a7 to your computer and use it in GitHub Desktop.
require 'spec_helper'
describe Queries::EventsFilter do
describe '.filtered_relation' do
let!(:company) { create(:company,
use_at_mentions: true, enable_at_mentions_in_feed: true,
use_appreciations: true, enable_appreciations_in_feed: true)
}
let!(:user) { create(:user, :with_profile, :as_super, company: company) }
let!(:profile) { create(:profile, user: user, company: company) }
let!(:token) { 'e542c3ce-5614-4210-b4af-2d4814d04ecb' }
let!(:announcement) { create(:announcement_event, company: company, related: profile) }
let!(:birthday) { create(:birthday_event, company: company, related: profile) }
# before do
# host! "#{company.permalink}.example.com"
# stub_validate_user_guid(guid: user.guid, token: access_token)
# end
context 'when specifying a filter type' do
it 'filters events by type' do
# before do
# get '/api/v1/events.json?filter[type]=anniversary', format: :json, access_token: token
# end
filter_query = {"type"=>"announcement"}
relation = Queries::EventsFilter.filtered_relation(filter_query, Event.all)
expect(relation).to be_kind_of(ActiveRecord::Relation)
expect(relation).to include(announcement)
expect(relation).to_not include(birthday)
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment