Changesets can be listed by changeset number.
The Git repository is here.
- Revision:
- 193
- Log:
First stage commit of Typo 4.1, modified for the ROOL site.
Includes all local modifications but a final pass needs to be
made to delete any files left over from earlier Typo versions
that shouldn't be here anymore. See the 'tags' section of the
repository for a clean Typo 4.1 tree.Note that symlinks to shared files in the RISC OS Open theme
directory have been deliberately included this time around; I
decided that on balance it was better to leave them in as
placeholders, since unlike symlinks in app/views/shared, the
Typo theme structure is not a standard Rails concept.
- Author:
- rool
- Date:
- Wed Apr 04 18:51:02 +0100 2007
- Size:
- 4955 Bytes
1 | require File.dirname(__FILE__) + '/../spec_helper' |
2 | |
3 | context 'Given a post which references a pingback enabled article' do |
4 | fixtures :contents, :blogs |
5 | |
6 | PINGBACK_TARGET='http://anotherblog.org/xml-rpc' |
7 | REFERENCED_URL='http://anotherblog.org/a-post' |
8 | REFERRER_URL='http://myblog.net/referring-post' |
9 | |
10 | |
11 | setup do |
12 | @mock_response = mock('response') |
13 | @mock_xmlrpc_response = mock('xmlrpc_response') |
14 | end |
15 | |
16 | specify 'Pingback sent to url found in referenced header' do |
17 | @mock_response.should_receive(:[]).with('X-Pingback').at_least(:once).and_return(PINGBACK_TARGET) |
18 | @mock_xmlrpc_response.should_receive(:call).with('pingback.ping', REFERRER_URL, REFERENCED_URL) |
19 | make_and_send_ping |
20 | end |
21 | |
22 | specify 'Pingback sent to url found in referenced body' do |
23 | @mock_response.should_receive(:[]).with('X-Pingback').at_least(:once).and_return(nil) |
24 | @mock_response.should_receive(:body).at_least(:once)\ |
25 | .and_return(%{<link rel="pingback" href="http://anotherblog.org/xml-rpc" />}) |
26 | @mock_xmlrpc_response.should_receive(:call).with('pingback.ping', REFERRER_URL, REFERENCED_URL) |
27 | make_and_send_ping |
28 | end |
29 | |
30 | specify 'Pingback sent when new article is saved' do |
31 | ActiveRecord::Base.observers.should == [:email_notifier, :web_notifier] |
32 | |
33 | blog = Blog.default |
34 | |
35 | blog.should_not_send_outbound_pings |
36 | blog.send_outbound_pings = 1 |
37 | blog.save! |
38 | blog.should_send_outbound_pings |
39 | |
40 | |
41 | a = blog.articles.build \ |
42 | :body => '<a href="http://anotherblog.org/a-post">', |
43 | :title => 'Test the pinging', |
44 | :published => true |
45 | |
46 | Net::HTTP.should_receive(:get_response).and_return(@mock_response) |
47 | XMLRPC::Client.should_receive(:new2).with(PINGBACK_TARGET).and_return(@mock_xmlrpc_response) |
48 | |
49 | @mock_response.should_receive(:[]).with('X-Pingback').at_least(:once).and_return(PINGBACK_TARGET) |
50 | @mock_xmlrpc_response.should_receive(:call)\ |
51 | .with('pingback.ping', |
52 | %r{http://myblog.net/articles/\d{4}/\d{2}/\d{2}/test-the-pinging}, |
53 | REFERENCED_URL) |
54 | |
55 | |
56 | a.should_have(1).html_urls |
57 | a.save! |
58 | a.should_be_just_published |
59 | a.reload |
60 | a.should_not_be_just_published |
61 | # Saving again will not resend the pings |
62 | a.save |
63 | end |
64 | |
65 | def make_and_send_ping |
66 | Net::HTTP.should_receive(:get_response).and_return(@mock_response) |
67 | XMLRPC::Client.should_receive(:new2).with(PINGBACK_TARGET).and_return(@mock_xmlrpc_response) |
68 | |
69 | ping = contents(:article1).pings.build("url" => REFERENCED_URL) |
70 | ping.should_be_instance_of(Ping) |
71 | ping.url.should == REFERENCED_URL |
72 | ping.send_pingback_or_trackback(REFERRER_URL) |
73 | end |
74 | end |
75 | |
76 | context "An article links to another article, which contains a trackback URL" do |
77 | fixtures :contents, :blogs |
78 | |
79 | REFERENCED_URL='http://anotherblog.org/a-post' |
80 | TRACKBACK_URL="http://anotherblog.org/a-post/trackback" |
81 | REFERRER_URL='http://myblog.net/referring-post' |
82 | |
83 | def expected_trackback_post_data |
84 | "title=Article+1%21&excerpt=body&url=http://myblog.net/referring-post&blog_name=test+blog" |
85 | end |
86 | |
87 | specify 'Trackback URL is detected and pinged' do |
88 | @mock = mock('html_response') |
89 | Net::HTTP.should_receive(:get_response).with(URI.parse(REFERENCED_URL)).and_return(@mock) |
90 | @mock.should_receive(:[]).with('X-Pingback').at_least(:once) |
91 | @mock.should_receive(:body).twice.and_return(referenced_body) |
92 | Net::HTTP.should_receive(:start).with(URI.parse(TRACKBACK_URL).host, 80).and_yield(@mock) |
93 | @mock.should_receive(:post) \ |
94 | .with('/a-post/trackback', expected_trackback_post_data, |
95 | 'Content-type' => 'application/x-www-form-urlencoded; charset=utf-8') \ |
96 | .and_return(@mock) |
97 | |
98 | ping = contents(:article1).pings.build(:url => REFERENCED_URL) |
99 | ping.send_pingback_or_trackback(REFERRER_URL) |
100 | end |
101 | |
102 | |
103 | def referenced_body |
104 | <<-eobody |
105 | <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" |
106 | xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" |
107 | xmlns:dc="http://purl.org/dc/elements/1.1/"> |
108 | <rdf:Description |
109 | rdf:about="" |
110 | trackback:ping="http://anotherblog.org/a-post/trackback" |
111 | dc:title="Track me, track me!" |
112 | dc:identifier="http://anotherblog.org/a-post" |
113 | dc:description="Track me 'til I fart!'" |
114 | dc:creator="pdcawley" |
115 | dc:date="2006-03-01T04:31:00-05:00" /> |
116 | </rdf:RDF> |
117 | eobody |
118 | end |
119 | end |
120 | |
121 | context 'Given a remote site to notify, eg technorati' do |
122 | fixtures :contents, :blogs |
123 | |
124 | specify 'we can ping them correctly' do |
125 | mock = mock('response') |
126 | XMLRPC::Client.should_receive(:new2).with('http://rpc.technorati.com/rpc/ping').and_return(mock) |
127 | mock.should_receive(:call).with('weblogUpdates.ping', 'test blog', |
128 | 'http://myblog.net', 'http://myblog.net/new-post') |
129 | |
130 | ping = contents(:article1).pings.build("url" => "http://rpc.technorati.com/rpc/ping") |
131 | ping.send_weblogupdatesping('http://myblog.net', 'http://myblog.net/new-post') |
132 | end |
133 | end |