require 'rails_helper'

describe Dunlop::UserModel do
  let(:time) { '1981-03-09T13:33:04Z'.to_time }
  let(:model) { User }
  before { Timecop.freeze time }
  after  { Timecop.return      }
  subject { create :user }
  describe 'basics' do
    it 'exists' do
      subject.should be_present
      subject.id.should be_present
    end
  end

  describe 'has_many user_filters' do
    it "creates" do
      expect { subject.user_filters.create(scope_key: 'dunlop:test1', filters: {a: 3, b: 8}) }.to change { Dunlop::UserFilter.count }.by 1
      filters = Dunlop::UserFilter.last
      filters.user.should eq subject
      filters.filters.should eq('a' => 3, 'b' => 8)
    end

  end
end
