Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement