npverni (owner)

Revisions

gist: 221518 Download_button fork
public
Description:
boston.rb: Test, Feature and code for Jobs Atom Feed
Public Clone URL: git://gist.github.com/221518.git
Embed All Files: show embed
Diff #
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
From ec7bf4201c54d03d603b47452a5da98659e99b8b Mon Sep 17 00:00:00 2001
From: Nathan Verni <npverni@gmail.com>
Date: Thu, 29 Oct 2009 11:28:05 -0400
Subject: [PATCH 1/2] Test, Feature and code for Jobs Atom Feed
 
---
 app/views/jobs/index.atom.builder | 19 +++++++++++++++++++
 1 files changed, 19 insertions(+), 0 deletions(-)
 create mode 100644 app/views/jobs/index.atom.builder
 
diff --git a/app/views/jobs/index.atom.builder b/app/views/jobs/index.atom.builder
new file mode 100644
index 0000000..bd3757c
--- /dev/null
+++ b/app/views/jobs/index.atom.builder
@@ -0,0 +1,19 @@
+atom_feed :schema_date => 2009 do |feed|
+ feed.title("Boston.rb Jobs")
+ feed.subtitle("Jobs for Boston Rubyists")
+ feed.updated(@jobs.first.updated_at) if @jobs.any?
+
+ @jobs.each do |job|
+ feed.entry(job) do |entry|
+ entry.title("#{job.title} at #{job.organization}")
+ entry.content "type" => "html" do
+ xml.text!("<strong>Location:</strong> #{job.location}")
+ xml.text!(job.cached_description_html)
+ end
+
+ entry.author do |author|
+ author.name("Boston Ruby Group")
+ end
+ end
+ end
+end
--
1.6.4.2
 
 
From b4db2c3380101e667ba111e46689ab789647ad2b Mon Sep 17 00:00:00 2001
From: Nathan Verni <npverni@gmail.com>
Date: Thu, 29 Oct 2009 11:32:26 -0400
Subject: [PATCH 2/2] Test, Feature and code for Jobs Atom Feed
 
---
 app/controllers/jobs_controller.rb | 2 ++
 features/jobs.feature | 8 +++++++-
 features/support/paths.rb | 3 ++-
 test/functional/jobs_controller_test.rb | 21 +++++++++++++++++++++
 4 files changed, 32 insertions(+), 2 deletions(-)
 
diff --git a/app/controllers/jobs_controller.rb b/app/controllers/jobs_controller.rb
index 1b2c86d..bfa6767 100644
--- a/app/controllers/jobs_controller.rb
+++ b/app/controllers/jobs_controller.rb
@@ -3,6 +3,8 @@ class JobsController < InheritedResources::Base
 
   before_filter :authorize, :only => [:edit]
 
+ respond_to :atom, :only => :index
+
   def create
     create! { root_url }
   end
diff --git a/features/jobs.feature b/features/jobs.feature
index aa85a69..77effca 100644
--- a/features/jobs.feature
+++ b/features/jobs.feature
@@ -25,4 +25,10 @@ Feature: Jobs
     And I follow "This is a job"
     Then I should see "This is a job at thoughtbot"
     And I should see "user interface to the metal - you should love doing it all."
-
\ No newline at end of file
+
+ Scenario: Viewing jobs atom feed
+ Given a job exists with a title of "This is a job"
+ And a job exists with a title of "Here is another cool job"
+ When I go to the jobs atom feed
+ Then I should see "This is a job at thoughtbot"
+ And I should see an entry for "Here is another cool job at thoughtbot"
diff --git a/features/support/paths.rb b/features/support/paths.rb
index a75c8da..7204b1d 100644
--- a/features/support/paths.rb
+++ b/features/support/paths.rb
@@ -20,7 +20,8 @@ module NavigationHelpers
       presentation_path(@presentation)
     when /new presentation page/i
       new_presentation_path
-
+ when /the jobs atom feed/i
+ jobs_path :format => :atom
     # Add more page name => path mappings here
 
     else
diff --git a/test/functional/jobs_controller_test.rb b/test/functional/jobs_controller_test.rb
index 879b647..dcb6f8e 100644
--- a/test/functional/jobs_controller_test.rb
+++ b/test/functional/jobs_controller_test.rb
@@ -54,6 +54,27 @@ class JobsControllerTest < ActionController::TestCase
     should_redirect_to("home") { root_path }
   end
 
+ context "on GET to /jobs :format => 'atom' with jobs" do
+ setup do
+ Factory(:job)
+ get :index, :format => 'atom'
+ end
+
+ should_assign_to :jobs
+ should_render_template 'index.atom'
+ should_respond_with :success
+ end
+
+ context "on GET to /jobs :format => 'atom' without jobs" do
+ setup do
+ get :index, :format => 'atom'
+ end
+
+ should_assign_to :jobs
+ should_render_template 'index.atom'
+ should_respond_with :success
+ end
+
   context 'on PUT to /jobs/:id when signed in' do
     setup do
       sign_in
--
1.6.4.2