Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 298 lines (256 sloc) 6.925 kb
e5f1011 @jordelver Add an .rvmrc
jordelver authored
1 rvmrc = "rvm 1.9.2@#{app_path} --create"
2 create_file '.rvmrc', rvmrc
3
07c3f9e @jordelver Make sure github is added as source of gems
jordelver authored
4 add_source "http://gems.github.com"
5
1403783 @stengland Initial commit
stengland authored
6 append_file 'Gemfile', do
7 <<-RUBY
17c92c0 @jordelver Make sure we use 0.2.5 as there is a bug in later versions
jordelver authored
8 gem "mm-versionable", '0.2.5'
1403783 @stengland Initial commit
stengland authored
9 gem "noodall-ui"
10 gem 'bson_ext'
11 gem "dragonfly"
12
13 group :test do
14 gem 'capybara'
15 gem 'database_cleaner'
16 gem 'cucumber-rails'
17 gem 'launchy' # So you can do Then show me the page
18 gem 'factory_girl_rails'
19 gem 'fakerama'
20 end
21 RUBY
22 end
23
24 create_file 'test/dummy/app/models/user.rb', do
25 <<-RUBY
26 class User
27 include MongoMapper::Document
28 include Canable::Cans
29
30 key :email, String
31 key :full_name, String
32 key :groups, Array
33
34 cattr_accessor :editor_groups
35
36 def admin?
37 groups.include?('website administrator')
38 end
39
40 def editor?
41 return true if self.class.editor_groups.blank?
42 admin? or (self.class.editor_groups & groups).size > 0
43 end
44
45 end
46 RUBY
47 end
48
49 create_file 'test/dummy/config/mongo.yml' do
50 <<-YAML
51 development:
062b536 @jordelver Use the plugin name to name the mongo databases
jordelver authored
52 database: #{app_path}_development
1403783 @stengland Initial commit
stengland authored
53 test:
062b536 @jordelver Use the plugin name to name the mongo databases
jordelver authored
54 database: #{app_path}_test
1403783 @stengland Initial commit
stengland authored
55 production:
062b536 @jordelver Use the plugin name to name the mongo databases
jordelver authored
56 database: #{app_path}_production
1403783 @stengland Initial commit
stengland authored
57 YAML
58 end
59
60 remove_file 'test/dummy/config/routes.rb'
61 create_file 'test/dummy/config/routes.rb' do
62 <<-RUBY
63 require 'noodall/routes'
64
65 Noodall::Routes.draw(Dummy::Application)
66 RUBY
67 end
68
71b686a @jordelver Add initializers for Dragonfly setup and note on how to add slots
jordelver authored
69 create_file 'test/dummy/config/initializers/noodall.rb' do
70 <<-RUBY
71 # Add your Noodall:Node slots here
72 #
73 # Noodall::Node.slot :<slot name>, <component name>
74 #
75 # For example:
76 #
77 # Noodall::Node.slot :carousel, Carousel
78 RUBY
79 end
80
81 create_file 'test/dummy/config/initializers/noodall_dragonfly.rb' do
82 <<-RUBY
83 # Configuration for processing and encoding
84 app = Dragonfly::App[:noodall_assets]
85 app.configure_with(:imagemagick)
86 app.configure_with(:rails)
87 app.datastore = Dragonfly::DataStorage::MongoDataStore.new :db => MongoMapper.database
88
89 # For more info about Dragonfly configuration please visit
90 # http://markevans.github.com/dragonfly/
91 RUBY
92 end
93
1403783 @stengland Initial commit
stengland authored
94 inject_into_class 'test/dummy/app/controllers/application_controller.rb', 'ApplicationController' do
95 <<-RUBY
96 @@current_user = User.find_or_create_by_full_name("Demo User")
97
98 def self.current_user=(user)
99 @@current_user = user
100 end
101
102 def current_user
103 @@current_user
104 end
105 helper_method :current_user
106
107 def destroy_user_session_path
108 ''
109 end
110 helper_method :destroy_user_session_path
111
112 def authenticate_user!
113 true
114 end
115
116 def anybody_signed_in?
117 true
118 end
119 RUBY
120 end
121
4104eb3 @jordelver Add normal content page model and views
jordelver authored
122 create_file 'test/dummy/app/models/content_page.rb' do
123 <<-RUBY
124 class ContentPage < Noodall::Node
125 # Define which Node Templates can be used as children of Nodes using this template
126 sub_templates ContentPage
127
128 # Define the number of each slot type this Node Template allows. Slots are defined in 'config/initializers/noodall.rb'
129 # small_slots 4
130 end
131 RUBY
132 end
133
134 create_file 'test/dummy/app/views/admin/nodes/_content_page.html.erb' do
135 <<-'RUBY'
136 <%= render :partial => 'noodall/admin/nodes/body', :locals => { :f => f } %>
137 <% content_for :component_table do %>
138 <!--
139 modify this table to look like your template and link slots to correct anchors
140 <table class="component-table">
141 <tr>
142 <td rowspan="2" class="content"></td>
143 <td colspan="2" rowspan="4" class="content"></td>
144 <td><a href="#small_component_form_0" class="slot_link">4</a></td>
145 </tr>
146 <tr>
147 <td><a href="#small_component_form_1" class="slot_link">5</a></td>
148 </tr>
149 <tr>
150 <td></td>
151 <td><a href="#small_component_form_2" class="slot_link">6</a></td>
152 </tr>
153 <tr>
154 <td></td>
155 <td><a href="#small_component_form_3" class="slot_link">7</a></td>
156 </tr>
157 <tr>
158 <td></td>
159 <td colspan="2"><a href="#wide_component_form_0" class="slot_link">1</a></td>
160 <td></td>
161 </tr>
162 <tr>
163 <td></td>
164 <td colspan="2"><a href="#wide_component_form_1" class="slot_link">2</a></td>
165 <td></td>
166 </tr>
167 <tr>
168 <td></td>
169 <td colspan="2"><a href="#wide_component_form_2" class="slot_link">3</a></td>
170 <td></td>
171 </tr>
172 <tr>
173 <td></td>
174 <td></td>
175 <td></td>
176 <td></td>
177 </tr>
178 </table>
179 -->
180 <% end -%>
181 RUBY
182 end
183
184 create_file 'test/dummy/app/views/nodes/content_page.html.erb' do
185 <<-RUBY
186 <h1><%= @node.title %></h1>
187
188 <%= @node.body.html_safe %>
189
190 <!--
191 Add a slot for your new component here
192 <%= component @node, '<component_name>_slot_0' %>
193 -->
194 RUBY
195 end
196
1403783 @stengland Initial commit
stengland authored
197 generate 'cucumber:install'
198
199 prepend_file 'features/support/env.rb', 'ENV["RAILS_ROOT"] ||= File.expand_path(File.dirname(__FILE__) + "/../../test/dummy")'
200
201 gsub_file 'features/support/env.rb', ':transaction', ':truncation'
f5a66b6 @jordelver Include Noodall::Permalinks helpers so we can use them in tests
jordelver authored
202
54746ea @jordelver Add basic cucumber steps
jordelver authored
203 create_file 'features/step_definitions/component_steps.rb' do
204 <<-'RUBY'
205 Given /^I am editing content$/ do
206 @_content = Factory(:content_page)
207 visit noodall_admin_node_path(@_content)
208 end
209
210 Given /^place a "([^"]*)" component in a slot$/ do |component_name|
211 slot_name = case component_name
d8e1054 @jordelver Remove specific slot name and add note that you should add it yourself
jordelver authored
212 # Fill in your component and component slot name
213 # when '<component>'
214 # '<component> Slot'
54746ea @jordelver Add basic cucumber steps
jordelver authored
215 else
216 'Large Slot'
217 end
218 within('ol#slot-list') do
219 click_link slot_name
220 end
221 within "#fancybox-content" do
222 select component_name, :from => 'Select the type of component'
223 end
224 end
225
226 When /^I view the content$/ do
227 # If we haven't saved the component yet do so
228 if page.find('#fancybox-content').visible?
229 within "#fancybox-content" do
230 click_button 'Save'
231 end
232 sleep 2
233 click_button 'Publish'
234 end
235 visit node_path(@_content)
236 end
237 RUBY
238 end
239
f5a66b6 @jordelver Include Noodall::Permalinks helpers so we can use them in tests
jordelver authored
240 create_file 'features/support/noodall.rb' do
241 <<-RUBY
242 # Load Noodall specific stuff
243 require 'noodall/permalinks'
244 World(Noodall::Permalinks)
245 RUBY
246 end
87b3b09 @jordelver Add bear minimum of factories for testing
jordelver authored
247
248 create_file 'factories/asset.rb' do
249 <<-'RUBY'
250 Factory.define :asset do |asset|
251 asset.tags { Faker::Lorem.words(4) }
252 asset.title { "Image asset" }
253 asset.description { "The asset description" }
254 asset.file { Fakerama::Asset::Photo.landscape }
255 end
256
257 Factory.define :txt_asset, :parent => :asset do |asset|
258 asset.title { "A text file asset" }
259 asset.description { "The text file asset description" }
260 asset.file { Fakerama::Asset::Document.txt }
261 end
262
263 Factory.define :zip_asset, :parent => :asset do |asset|
264 asset.title { "A zip file asset" }
265 asset.description { "The zip file asset description" }
266 asset.file {File.new(File.expand_path("../../files/test.zip", __FILE__))}
267 end
268
269 Factory.define :document_asset, :parent => :asset do |asset|
270 asset.title { "Document asset" }
271 asset.file { File.new("#{Rails.root}/spec/files/test.pdf") }
272 end
273 RUBY
274 end
275
276 create_file 'factories/content_page.rb' do
277 <<-RUBY
278 Factory.define :content_page do |content_page|
279 content_page.title { Faker::Lorem.words(3).join(' ') }
280 content_page.body { Faker::Lorem.paragraphs(6) }
281 content_page.published_at { Time.now }
282 content_page.publish true
283 end
284 RUBY
285 end
286
287 create_file 'features/support/factory_girl.rb' do
288 <<-RUBY
289 require 'factory_girl'
290 require 'fakerama'
291 FactoryGirl.definition_file_paths = [
292 File.expand_path(File.dirname(__FILE__) + '/../../factories')
293 ]
294 FactoryGirl.find_definitions
295 RUBY
296 end
297
Something went wrong with that request. Please try again.