merged my socket changes
This commit is contained in:
commit
d9a6bb7ba2
13 changed files with 237 additions and 258 deletions
|
|
@ -1,4 +1,6 @@
|
|||
module ApplicationHelper
|
||||
require 'lib/common'
|
||||
include Diaspora::XMLParser
|
||||
def object_path(object)
|
||||
eval("#{object.class.to_s.underscore}_path(object)")
|
||||
end
|
||||
|
|
@ -7,46 +9,6 @@ module ApplicationHelper
|
|||
object.attributes.keys
|
||||
end
|
||||
|
||||
def parse_sender_id_from_xml(xml)
|
||||
doc = Nokogiri::XML(xml) { |cfg| cfg.noblanks }
|
||||
doc.xpath("/XML/head/sender/email").text.to_s
|
||||
end
|
||||
|
||||
def parse_sender_object_from_xml(xml)
|
||||
sender_id = parse_sender_id_from_xml(xml)
|
||||
Friend.where(:email => sender_id).first
|
||||
end
|
||||
|
||||
def parse_body_contents_from_xml(xml)
|
||||
doc = Nokogiri::XML(xml) { |cfg| cfg.noblanks }
|
||||
doc.xpath("/XML/posts/post")
|
||||
end
|
||||
|
||||
def parse_objects_from_xml(xml)
|
||||
objects = []
|
||||
sender = parse_sender_object_from_xml(xml)
|
||||
body = parse_body_contents_from_xml(xml)
|
||||
body.children.each do |post|
|
||||
begin
|
||||
object = post.name.camelize.constantize.from_xml post.to_s
|
||||
object.person = sender if object.is_a? Post
|
||||
objects << object
|
||||
rescue
|
||||
puts "Not a real type: #{object.to_s}"
|
||||
end
|
||||
end
|
||||
objects
|
||||
end
|
||||
|
||||
def store_objects_from_xml(xml)
|
||||
objects = parse_objects_from_xml(xml)
|
||||
|
||||
objects.each do |p|
|
||||
p.save if p.respond_to?(:person) && !(p.person.nil?) #WTF
|
||||
#p.save if p.respond_to?(:person) && !(p.person == nil) #WTF
|
||||
end
|
||||
end
|
||||
|
||||
def mine?(post)
|
||||
post.person == User.first
|
||||
end
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ class Post
|
|||
include ROXML
|
||||
include Diaspora::Webhooks
|
||||
|
||||
xml_accessor :_id
|
||||
|
||||
key :person_id, ObjectId
|
||||
belongs_to :person, :class_name => 'Person'
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
%li.message{:class => ("mine" if mine?(post))}
|
||||
%li.message{:id => post.id, :class => ("mine" if mine?(post))}
|
||||
%span.from
|
||||
= link_to_person post.person
|
||||
%b wrote a new blog post
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
%li.message{:class => ("mine" if mine?(post))}
|
||||
%li.message{:id => post.id, :class => ("mine" if mine?(post))}
|
||||
%span.from
|
||||
= link_to_person post.person
|
||||
%b shared a link
|
||||
|
|
|
|||
|
|
@ -1,4 +1,6 @@
|
|||
%li.comment
|
||||
%li.comment{:id => comment.id}
|
||||
%span.from
|
||||
= link_to_person comment.person
|
||||
= comment.text
|
||||
\---
|
||||
= comment.person.real_name
|
||||
%div.time
|
||||
= "#{time_ago_in_words(comment.updated_at)} ago"
|
||||
|
|
|
|||
|
|
@ -25,7 +25,6 @@
|
|||
- if user_signed_in?
|
||||
:javascript
|
||||
$(document).ready(function(){
|
||||
|
||||
function debug(str){ $("#debug").append("<p>" + str); };
|
||||
|
||||
ws = new WebSocket("ws://#{request.host}:8080/");
|
||||
|
|
@ -34,7 +33,7 @@
|
|||
if((location.href.indexOf(obj['class']) != -1 ) || (location.pathname == '/')) {
|
||||
$("#stream").prepend($(obj['html']).fadeIn("fast"));
|
||||
};
|
||||
}
|
||||
};
|
||||
ws.onclose = function() { debug("socket closed"); };
|
||||
ws.onopen = function() {
|
||||
ws.send(location.pathname);
|
||||
|
|
@ -42,11 +41,11 @@
|
|||
};
|
||||
});
|
||||
%body
|
||||
|
||||
- flash.each do |name, msg|
|
||||
= content_tag :div, msg, :id => "flash_#{name}"
|
||||
|
||||
%header
|
||||
.container
|
||||
%a#diaspora_text{:href => root_path}
|
||||
%img{:src => '/images/diaspora_white.png'}
|
||||
|
||||
|
|
@ -59,15 +58,17 @@
|
|||
= link_to "login", new_user_session_path
|
||||
|
||||
#header_below
|
||||
|
||||
.container
|
||||
- if user_signed_in?
|
||||
%h1#user_name
|
||||
= link_to User.first.real_name, root_url
|
||||
%span.description
|
||||
= my_latest_message
|
||||
|
||||
%nav
|
||||
%ul.nav
|
||||
.container
|
||||
#content.span-24.last
|
||||
.span-3.append-1.last
|
||||
%ul#stream_filters
|
||||
%a{ :href => root_path, :title => "Your network stream."}
|
||||
%li home
|
||||
%a{ :href => status_messages_path, :title => "Recent status messages."}
|
||||
|
|
@ -78,11 +79,8 @@
|
|||
%li blogs
|
||||
%a{ :href => friends_path, :title => "Your list of connections with other seeds."}
|
||||
%li friends
|
||||
|
||||
|
||||
#content
|
||||
#main
|
||||
.span-15.append-1.last
|
||||
= yield
|
||||
= render "posts/debug"
|
||||
#friends_list
|
||||
.span-3.last
|
||||
= render 'friends/sidebar' if user_signed_in?
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
%li.message{:class => ("mine" if mine?(post))}
|
||||
%li.message{:id => post.id, :class => ("mine" if mine?(post))}
|
||||
%span.from
|
||||
= link_to_person post.person
|
||||
= post.message
|
||||
|
|
|
|||
|
|
@ -16,10 +16,9 @@ module WebSocket
|
|||
|
||||
EventMachine::WebSocket.start(:host => "0.0.0.0", :port => 8080, :debug =>false) do |ws|
|
||||
ws.onopen {
|
||||
puts ws.request['Cookie']
|
||||
sid = @channel.subscribe { |msg| ws.send msg }
|
||||
|
||||
ws.onmessage { |msg| puts msg}#@channel.push msg; puts msg}
|
||||
ws.onmessage { |msg|}#@channel.push msg; puts msg}
|
||||
|
||||
ws.onclose { @channel.unsubscribe(sid) }
|
||||
}
|
||||
|
|
@ -39,6 +38,7 @@ module WebSocket
|
|||
puts "in failzord " + v .inspect
|
||||
raise "i suck"
|
||||
end
|
||||
|
||||
{:class =>object.class.to_s.underscore.pluralize, :html => v}
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,47 @@
|
|||
module Diaspora
|
||||
module XMLParser
|
||||
def parse_sender_id_from_xml(xml)
|
||||
doc = Nokogiri::XML(xml) { |cfg| cfg.noblanks }
|
||||
doc.xpath("/XML/head/sender/email").text.to_s
|
||||
end
|
||||
|
||||
def parse_sender_object_from_xml(xml)
|
||||
sender_id = parse_sender_id_from_xml(xml)
|
||||
Friend.where(:email => sender_id).first
|
||||
end
|
||||
|
||||
def parse_body_contents_from_xml(xml)
|
||||
doc = Nokogiri::XML(xml) { |cfg| cfg.noblanks }
|
||||
doc.xpath("/XML/posts/post")
|
||||
end
|
||||
|
||||
def parse_objects_from_xml(xml)
|
||||
objects = []
|
||||
sender = parse_sender_object_from_xml(xml)
|
||||
body = parse_body_contents_from_xml(xml)
|
||||
body.children.each do |post|
|
||||
begin
|
||||
object = post.name.camelize.constantize.from_xml post.to_s
|
||||
object.person = sender if object.is_a? Post
|
||||
objects << object
|
||||
rescue
|
||||
puts "Not a real type: #{object.to_s}"
|
||||
end
|
||||
end
|
||||
objects
|
||||
end
|
||||
|
||||
def store_objects_from_xml(xml)
|
||||
objects = parse_objects_from_xml(xml)
|
||||
|
||||
objects.each do |p|
|
||||
p.save if p.respond_to?(:person) && !(p.person.nil?) #WTF
|
||||
#p.save if p.respond_to?(:person) && !(p.person == nil) #WTF
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
module Webhooks
|
||||
def self.included(klass)
|
||||
klass.class_eval do
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
body {
|
||||
font-family: "helvetica", "arial", "sans-serif";
|
||||
padding: 2em;
|
||||
margin: 0; }
|
||||
|
||||
|
|
@ -46,82 +45,75 @@ a {
|
|||
margin: 0;
|
||||
font-weight: bold;
|
||||
font-size: 12px;
|
||||
background-color: #cc0000;
|
||||
color: white; }
|
||||
background-color: #cc0000; }
|
||||
.error_messages p {
|
||||
margin: 8px 10px; }
|
||||
.error_messages ul {
|
||||
margin: 0; }
|
||||
|
||||
header {
|
||||
z-index: 10;
|
||||
position: fixed;
|
||||
width: 100%;
|
||||
margin-top: -2em;
|
||||
margin-right: -2em;
|
||||
margin-left: -2em;
|
||||
position: relative;
|
||||
margin: -2em;
|
||||
margin-bottom: 0;
|
||||
height: 30px;
|
||||
color: white;
|
||||
background-color: #1a1a21;
|
||||
border-bottom: 2px solid #f2f8fc;
|
||||
border-bottom: 2px solid white;
|
||||
padding-top: 5px; }
|
||||
header #diaspora_text {
|
||||
position: fixed;
|
||||
position: absolute;
|
||||
border: none;
|
||||
top: 8px;
|
||||
left: 1em; }
|
||||
top: 10px; }
|
||||
header #session_action {
|
||||
position: fixed;
|
||||
right: 1em;
|
||||
font-size: 120%;
|
||||
position: absolute;
|
||||
right: 300px;
|
||||
font-size: 110%;
|
||||
top: 7px; }
|
||||
header #session_action a {
|
||||
color: #cccccc;
|
||||
border: none; }
|
||||
|
||||
ul.nav {
|
||||
#show_filters {
|
||||
z-index: 100;
|
||||
position: absolute;
|
||||
right: 0;
|
||||
text-align: right; }
|
||||
|
||||
#show_filters > a {
|
||||
border: 1px solid #666666;
|
||||
padding: 5px; }
|
||||
|
||||
ul#stream_filters {
|
||||
padding: 0;
|
||||
margin: 0;
|
||||
width: 200px;
|
||||
top: 100px;
|
||||
font-size: 130%; }
|
||||
ul.nav li {
|
||||
margin: 0; }
|
||||
ul#stream_filters li {
|
||||
display: block;
|
||||
padding: 5px 10px;
|
||||
background-color: #f2f8fc;
|
||||
border: 1px solid white; }
|
||||
ul.nav li:first-child {
|
||||
padding: 5px 0; }
|
||||
ul#stream_filters li:first-child {
|
||||
border-top-right-radius: 5px;
|
||||
border-top-left-radius: 5px; }
|
||||
ul.nav li:last-child {
|
||||
ul#stream_filters li:last-child {
|
||||
border-bottom-right-radius: 5px;
|
||||
border-bottom-left-radius: 5px; }
|
||||
ul.nav a {
|
||||
ul#stream_filters a {
|
||||
color: #b1cfe3; }
|
||||
ul#stream_filters a:hover {
|
||||
color: black; }
|
||||
|
||||
#header_below {
|
||||
z-index: 5;
|
||||
position: fixed;
|
||||
height: 40px;
|
||||
width: 100%;
|
||||
padding: 1em;
|
||||
padding-top: 40px;
|
||||
top: 0;
|
||||
background-color: rgba(255, 255, 255, 0.9);
|
||||
margin-left: -2em; }
|
||||
#header_below img {
|
||||
position: absolute;
|
||||
width: 200px;
|
||||
border-radius: 5px; }
|
||||
margin: 0 -2em;
|
||||
-webkit-box-shadow: 0 2px 2px -1px #999999;
|
||||
background-color: #f2f8fc;
|
||||
border-bottom: 1px solid #7e96a6;
|
||||
padding-top: 0.8em;
|
||||
padding-bottom: 0.4em; }
|
||||
|
||||
#content {
|
||||
position: absolute;
|
||||
left: 250px;
|
||||
top: 94px;
|
||||
width: 60%;
|
||||
min-width: 500px;
|
||||
max-width: 700px; }
|
||||
top: 94px; }
|
||||
|
||||
#main {
|
||||
width: 100%; }
|
||||
|
||||
ul#stream {
|
||||
margin: 0;
|
||||
|
|
@ -135,7 +127,6 @@ ul#stream {
|
|||
|
||||
li.message {
|
||||
line-height: 140%;
|
||||
font-size: 120%;
|
||||
font-family: "Lucida Grande";
|
||||
color: #999999; }
|
||||
li.message span.from {
|
||||
|
|
@ -146,12 +137,13 @@ li.message {
|
|||
color: #bababa;
|
||||
font-size: 70%; }
|
||||
|
||||
.mine {
|
||||
background-color: rgba(202, 237, 204, 0.5); }
|
||||
#user_name {
|
||||
font-size: 15px;
|
||||
line-height: 100%; }
|
||||
|
||||
h1 {
|
||||
position: relative;
|
||||
font-size: 24px;
|
||||
font-size: 18px;
|
||||
font-weight: bold;
|
||||
line-height: 36px; }
|
||||
h1 p.description, h1 span.description {
|
||||
|
|
@ -160,11 +152,6 @@ h1 {
|
|||
color: #999999;
|
||||
padding: 0.1em; }
|
||||
|
||||
.big_number {
|
||||
font-weight: bold;
|
||||
font-size: 500%;
|
||||
line-height: 100%; }
|
||||
|
||||
h3 {
|
||||
position: relative;
|
||||
font-size: 18px;
|
||||
|
|
@ -177,30 +164,39 @@ h3 {
|
|||
width: 100%;
|
||||
margin-bottom: 1em; }
|
||||
|
||||
#main {
|
||||
width: 70%;
|
||||
min-width: 400px;
|
||||
max-width: 700px;
|
||||
float: left; }
|
||||
|
||||
#friends_list {
|
||||
float: right;
|
||||
width: 20%;
|
||||
min-width: 130px;
|
||||
padding-left: 10%; }
|
||||
|
||||
form {
|
||||
font-size: 130%;
|
||||
font-size: 120%;
|
||||
margin: 1em;
|
||||
margin-left: 0em; }
|
||||
form input {
|
||||
font-size: 150%;
|
||||
padding: 0.2em;
|
||||
max-width: 100%; }
|
||||
|
||||
#user_name {
|
||||
background-color: rgba(255, 255, 255, 0.5); }
|
||||
text-shadow: 0 1px 0 white; }
|
||||
#user_name a {
|
||||
color: black; }
|
||||
#user_name a:hover {
|
||||
color: #cc1e14; }
|
||||
|
||||
#comment_text {
|
||||
padding: 3px; }
|
||||
|
||||
ul.comment_set {
|
||||
margin: 0;
|
||||
margin-top: 1em;
|
||||
padding: 0;
|
||||
padding-left: 1em;
|
||||
list-style: none;
|
||||
width: 90%; }
|
||||
ul.comment_set li.comment {
|
||||
margin-bottom: 0.5em;
|
||||
background-color: #f2f8fc;
|
||||
padding: 0.6em;
|
||||
border-radius: 5px; }
|
||||
ul.comment_set li.comment .from {
|
||||
color: #666666;
|
||||
font-weight: normal; }
|
||||
ul.comment_set li.comment .from a {
|
||||
color: #333333;
|
||||
font-weight: bold; }
|
||||
|
|
|
|||
|
|
@ -1,6 +1,4 @@
|
|||
body
|
||||
:font
|
||||
:family 'helvetica', 'arial', 'sans-serif'
|
||||
:padding 2em
|
||||
:margin 0
|
||||
a
|
||||
|
|
@ -50,101 +48,82 @@ a
|
|||
:weight bold
|
||||
:size 12px
|
||||
:background-color #c00
|
||||
:color #fff
|
||||
p
|
||||
:margin 8px 10px
|
||||
ul
|
||||
:margin 0
|
||||
|
||||
header
|
||||
:z-index 10
|
||||
|
||||
:position fixed
|
||||
:width 100%
|
||||
|
||||
:margin
|
||||
:top -2em
|
||||
:right -2em
|
||||
:left -2em
|
||||
|
||||
:position relative
|
||||
:margin -2em
|
||||
:bottom 0
|
||||
:height 30px
|
||||
:color #fff
|
||||
:background
|
||||
:color #1A1A21
|
||||
:border
|
||||
:bottom 2px solid #F2F8FC
|
||||
:bottom 2px solid #fff
|
||||
:padding
|
||||
:top 5px
|
||||
|
||||
#diaspora_text
|
||||
:position fixed
|
||||
:position absolute
|
||||
:border none
|
||||
:top 8px
|
||||
:left 1em
|
||||
:top 10px
|
||||
|
||||
#session_action
|
||||
:position fixed
|
||||
:right 1em
|
||||
:position absolute
|
||||
:right 300px
|
||||
:font
|
||||
:size 120%
|
||||
:size 110%
|
||||
:top 7px
|
||||
a
|
||||
:color #ccc
|
||||
:border none
|
||||
|
||||
|
||||
ul.nav
|
||||
#show_filters
|
||||
:z-index 100
|
||||
:position absolute
|
||||
:right 0
|
||||
:text-align right
|
||||
|
||||
#show_filters > a
|
||||
:border 1px solid #666
|
||||
:padding 5px
|
||||
|
||||
ul#stream_filters
|
||||
:padding 0
|
||||
:margin 0
|
||||
:width 200px
|
||||
:top 100px
|
||||
:font
|
||||
:size 130%
|
||||
|
||||
li
|
||||
:display block
|
||||
:padding 5px 10px
|
||||
:background
|
||||
:color #F2F8FC
|
||||
:border 1px solid #fff
|
||||
|
||||
|
||||
:padding 5px 0
|
||||
&:first-child
|
||||
:border-top-right-radius 5px
|
||||
:border-top-left-radius 5px
|
||||
|
||||
&:last-child
|
||||
:border-bottom-right-radius 5px
|
||||
:border-bottom-left-radius 5px
|
||||
|
||||
a
|
||||
:color #B1CFE3
|
||||
a:hover
|
||||
:color #000
|
||||
|
||||
#header_below
|
||||
:z-index 5
|
||||
:position fixed
|
||||
:height 40px
|
||||
:width 100%
|
||||
:padding 1em
|
||||
:top 40px
|
||||
:top 0
|
||||
:background
|
||||
:color rgba( 255, 255, 255, 0.9)
|
||||
:margin
|
||||
:left -2em
|
||||
img
|
||||
:position absolute
|
||||
:width 200px
|
||||
:border-radius 5px
|
||||
:margin 0 -2em
|
||||
:-webkit-box-shadow 0 2px 2px -1px #999
|
||||
:background-color #F2F8FC
|
||||
:border
|
||||
:bottom 1px solid #7E96A6
|
||||
:padding
|
||||
:top 0.8em
|
||||
:bottom 0.4em
|
||||
|
||||
#content
|
||||
:position absolute
|
||||
:left 250px
|
||||
:top 94px
|
||||
:width 60%
|
||||
:min-width 500px
|
||||
:max-width 700px
|
||||
|
||||
#main
|
||||
:width 100%
|
||||
|
||||
ul#stream
|
||||
:margin 0
|
||||
|
|
@ -161,7 +140,6 @@ ul#stream
|
|||
li.message
|
||||
:line-height 140%
|
||||
:font
|
||||
:size 120%
|
||||
:family 'Lucida Grande'
|
||||
:color #999
|
||||
|
||||
|
|
@ -177,12 +155,17 @@ li.message
|
|||
:color #bababa
|
||||
:font-size 70%
|
||||
.mine
|
||||
:background-color rgba(202, 237, 204, 0.5)
|
||||
//:background-color rgba(202, 237, 204, 0.5)
|
||||
|
||||
#user_name
|
||||
:font
|
||||
:size 15px
|
||||
:line-height 100%
|
||||
|
||||
h1
|
||||
:position relative
|
||||
:font
|
||||
:size 24px
|
||||
:size 18px
|
||||
:weight bold
|
||||
:line-height 36px
|
||||
|
||||
|
|
@ -193,12 +176,6 @@ h1
|
|||
:color #999
|
||||
:padding 0.1em
|
||||
|
||||
.big_number
|
||||
:font
|
||||
:weight bold
|
||||
:size 500%
|
||||
:line-height 100%
|
||||
|
||||
h3
|
||||
:position relative
|
||||
:font
|
||||
|
|
@ -215,27 +192,13 @@ h3
|
|||
:margin
|
||||
:bottom 1em
|
||||
|
||||
#main
|
||||
:width 70%
|
||||
:min-width 400px
|
||||
:max-width 700px
|
||||
:float left
|
||||
|
||||
#friends_list
|
||||
:float right
|
||||
:width 20%
|
||||
:min-width 130px
|
||||
:padding-left 10%
|
||||
|
||||
form
|
||||
:font
|
||||
:size 130%
|
||||
:size 120%
|
||||
:margin 1em
|
||||
:margin-left 0em
|
||||
|
||||
input
|
||||
:font
|
||||
:size 150%
|
||||
:padding 0.2em
|
||||
:max-width 100%
|
||||
|
||||
|
|
@ -244,6 +207,32 @@ form
|
|||
:color #000
|
||||
&:hover
|
||||
:color #CC1E14
|
||||
:background
|
||||
:color rgba( 255, 255, 255, 0.5)
|
||||
:text
|
||||
:shadow 0 1px 0 #fff
|
||||
|
||||
#comment_text
|
||||
:padding 3px
|
||||
|
||||
ul.comment_set
|
||||
:margin 0
|
||||
:top 1em
|
||||
:padding 0
|
||||
:left 1em
|
||||
:list-style none
|
||||
:width 90%
|
||||
|
||||
li.comment
|
||||
:margin
|
||||
:bottom 0.5em
|
||||
:background-color #F2F8FC
|
||||
:padding 0.6em
|
||||
:border-radius 5px
|
||||
|
||||
.from
|
||||
:color #666
|
||||
:font
|
||||
:weight normal
|
||||
a
|
||||
:color #333
|
||||
:font
|
||||
:weight bold
|
||||
|
|
|
|||
|
|
@ -15,19 +15,7 @@ describe "parser in application helper" do
|
|||
store_objects_from_xml(xml)
|
||||
StatusMessage.count.should == 0
|
||||
end
|
||||
it 'should discard posts where it does not know the type' do
|
||||
xml = "<XML>
|
||||
<head>
|
||||
<sender>
|
||||
<email>#{Friend.first.email}</email>
|
||||
</sender>
|
||||
</head><posts>
|
||||
<post><status_message>\n <message>Here is another message</message>\n <owner>a@a.com</owner>\n <snippet>a@a.com</snippet>\n <source>a@a.com</source>\n</status_message></post> <post><not_a_real_type></not_a_real_type></post> <post><status_message>\n <message>HEY DUDE</message>\n <owner>a@a.com</owner>\n <snippet>a@a.com</snippet>\n <source>a@a.com</source>\n</status_message></post>
|
||||
</posts></XML>"
|
||||
store_objects_from_xml(xml)
|
||||
Post.count.should == 2
|
||||
Post.first.person.email.should == Friend.first.email
|
||||
end
|
||||
|
||||
it "should reject xml with no sender" do
|
||||
xml = "<XML>
|
||||
<head>
|
||||
|
|
@ -40,6 +28,7 @@ describe "parser in application helper" do
|
|||
Post.count.should == 0
|
||||
|
||||
end
|
||||
|
||||
it "should reject xml with a sender not in the database" do
|
||||
xml = "<XML>
|
||||
<head>
|
||||
|
|
@ -54,6 +43,7 @@ describe "parser in application helper" do
|
|||
store_objects_from_xml(xml)
|
||||
Post.count.should == 0
|
||||
end
|
||||
|
||||
it 'should discard types which are not of type post' do
|
||||
xml = "<XML>
|
||||
<head>
|
||||
|
|
@ -62,13 +52,11 @@ describe "parser in application helper" do
|
|||
</sender>
|
||||
</head>
|
||||
<posts>
|
||||
<post><status_message>\n <message>Here is another message</message>\n <owner>a@a.com</owner>\n <snippet>a@a.com</snippet>\n <source>a@a.com</source>\n</status_message></post>
|
||||
<post><friend></friend></post>
|
||||
<post><status_message>\n <message>HEY DUDE</message>\n <owner>a@a.com</owner>\n <snippet>a@a.com</snippet>\n <source>a@a.com</source>\n</status_message></post>
|
||||
</posts></XML>"
|
||||
|
||||
store_objects_from_xml(xml)
|
||||
Post.count.should == 2
|
||||
Post.first.person.email.should == Friend.first.email
|
||||
Post.count.should == 0
|
||||
end
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue