Sha256: c2d0c594e93cf8a7737b3d7a3615994dfc85161e6397b2fae328a20c54bfbc1d

Contents?: true

Size: 836 Bytes

Versions: 1

Compression:

Stored size: 836 Bytes

Contents

require 'mongoid'

Mongoid.configure do |config|
  config.master = Mongo::Connection.new.db("activity_feed_gem_test")
end

DatabaseCleaner[:mongoid].strategy = :truncation

module ActivityFeed
  module Mongoid
    class Item
      include ::Mongoid::Document
      include ::Mongoid::Timestamps

      field :user_id, :type => String
      validates_presence_of :user_id

      field :nickname, :type => String
      field :type, :type => String
      field :title, :type => String
      field :text, :type => String
      field :url, :type => String
      field :icon, :type=> String
      field :sticky, :type=> Boolean

      index :user_id

      after_save :update_activity_feed

      private

      def update_activity_feed
        ActivityFeed.update_item(self.user_id, self.id, self.created_at.to_i)
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
activity_feed-2.2.2 spec/support/mongoid.rb