diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 5989654ac..50b8f700b 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -15,8 +15,7 @@ module ApplicationHelper def parse_sender_object_from_xml(xml) sender_id = parse_sender_id_from_xml(xml) Friend.where(:email => sender_id).first - - end + end def parse_body_contents_from_xml(xml) doc = Nokogiri::XML(xml) { |cfg| cfg.noblanks } diff --git a/app/models/post.rb b/app/models/post.rb index 73ee295ce..dfcabc805 100644 --- a/app/models/post.rb +++ b/app/models/post.rb @@ -1,22 +1,21 @@ class Post require 'lib/common' include ApplicationHelper - - # XML accessors must always preceed mongo field tags - include MongoMapper::Document include ROXML include Diaspora::Webhooks key :person_id, ObjectId - belongs_to :person, :class_name => 'Person' - timestamps! + + after_save :send_to_view - after_save :print + + + def self.stream Post.sort(:created_at.desc).all @@ -28,7 +27,7 @@ class Post def self.newest(person = nil) return self.last if person.nil? - self.where(:person_id => person.id).sort(:created_at.desc) + self.where(:person_id => person.id).last end def self.my_newest diff --git a/app/models/status_message.rb b/app/models/status_message.rb index ee7e696aa..195d5a73e 100644 --- a/app/models/status_message.rb +++ b/app/models/status_message.rb @@ -9,6 +9,7 @@ class StatusMessage < Post validates_presence_of :message + def ==(other) (self.message == other.message) && (self.person.email == other.person.email) end diff --git a/spec/helpers/parser_spec.rb b/spec/helpers/parser_spec.rb index 7130ed5fa..eae4ce7fd 100644 --- a/spec/helpers/parser_spec.rb +++ b/spec/helpers/parser_spec.rb @@ -2,7 +2,7 @@ require File.dirname(__FILE__) + '/../spec_helper' include ApplicationHelper -describe ApplicationHelper do +describe "parser in application helper" do before do @user = Factory.create(:user, :email => "bob@aol.com") @friend =Factory.create(:friend, :email => "bill@gates.com") diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index c69c5850c..1c76dd26f 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -12,9 +12,7 @@ include Devise::TestHelpers Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f} Rspec.configure do |config| - #config.mock_with :mocha - # config.mock_with :flexmock - # config.mock_with :rr + config.mock_with :rspec DatabaseCleaner.strategy = :truncation @@ -34,9 +32,4 @@ Rspec.configure do |config| #Factory.sequences.each{ |s| s.reset} end - - # If you're not using ActiveRecord, or you'd prefer not to run each of your - # examples within a transaction, comment the following line or assign false - # instead of true. -# config.use_transactional_fixtures = true end