noodall-components-gallery 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (66) hide show
  1. data/.gitignore +7 -0
  2. data/Gemfile +21 -0
  3. data/Gemfile.lock +186 -0
  4. data/MIT-LICENSE +20 -0
  5. data/README.rdoc +3 -0
  6. data/Rakefile +39 -0
  7. data/app/models/gallery.rb +13 -0
  8. data/app/views/admin/components/_gallery.html.erb +49 -0
  9. data/app/views/components/_gallery.html.erb +23 -0
  10. data/cucumber.yml +8 -0
  11. data/features/gallery_component.feature +19 -0
  12. data/features/step_definitions/asset_steps.rb +66 -0
  13. data/features/step_definitions/cms_node_steps.rb +126 -0
  14. data/features/step_definitions/component_steps.rb +138 -0
  15. data/features/step_definitions/web_steps.rb +219 -0
  16. data/features/support/env.rb +50 -0
  17. data/features/support/paths.rb +58 -0
  18. data/lib/noodall-components-gallery.rb +1 -0
  19. data/lib/noodall/components/gallery/engine.rb +11 -0
  20. data/lib/noodall/components/gallery/version.rb +7 -0
  21. data/noodall-components-gallery.gemspec +22 -0
  22. data/spec/dummy/Rakefile +7 -0
  23. data/spec/dummy/app/controllers/application_controller.rb +22 -0
  24. data/spec/dummy/app/helpers/application_helper.rb +3 -0
  25. data/spec/dummy/app/models/page_a.rb +8 -0
  26. data/spec/dummy/app/models/user.rb +12 -0
  27. data/spec/dummy/app/views/admin/nodes/_page_a.html.erb +47 -0
  28. data/spec/dummy/app/views/layouts/application.html.erb +14 -0
  29. data/spec/dummy/app/views/nodes/page_a.html.erb +14 -0
  30. data/spec/dummy/config.ru +4 -0
  31. data/spec/dummy/config/application.rb +46 -0
  32. data/spec/dummy/config/boot.rb +10 -0
  33. data/spec/dummy/config/database.yml +12 -0
  34. data/spec/dummy/config/environment.rb +5 -0
  35. data/spec/dummy/config/environments/development.rb +26 -0
  36. data/spec/dummy/config/environments/production.rb +49 -0
  37. data/spec/dummy/config/environments/test.rb +35 -0
  38. data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
  39. data/spec/dummy/config/initializers/dragonfly.rb +1 -0
  40. data/spec/dummy/config/initializers/inflections.rb +10 -0
  41. data/spec/dummy/config/initializers/mime_types.rb +5 -0
  42. data/spec/dummy/config/initializers/mongo_mapper.rb +13 -0
  43. data/spec/dummy/config/initializers/noodall.rb +5 -0
  44. data/spec/dummy/config/initializers/secret_token.rb +7 -0
  45. data/spec/dummy/config/initializers/session_store.rb +8 -0
  46. data/spec/dummy/config/locales/en.yml +5 -0
  47. data/spec/dummy/config/routes.rb +3 -0
  48. data/spec/dummy/public/404.html +26 -0
  49. data/spec/dummy/public/422.html +26 -0
  50. data/spec/dummy/public/500.html +26 -0
  51. data/spec/dummy/public/favicon.ico +0 -0
  52. data/spec/dummy/public/javascripts/application.js +2 -0
  53. data/spec/dummy/public/javascripts/controls.js +965 -0
  54. data/spec/dummy/public/javascripts/dragdrop.js +974 -0
  55. data/spec/dummy/public/javascripts/effects.js +1123 -0
  56. data/spec/dummy/public/javascripts/prototype.js +6001 -0
  57. data/spec/dummy/public/javascripts/rails.js +175 -0
  58. data/spec/dummy/public/stylesheets/.gitkeep +0 -0
  59. data/spec/dummy/script/rails +6 -0
  60. data/spec/factories/asset.rb +6 -0
  61. data/spec/factories/node.rb +6 -0
  62. data/spec/files/beef.png +0 -0
  63. data/spec/integration/navigation_spec.rb +9 -0
  64. data/spec/noodall_component_gallery_spec.rb +7 -0
  65. data/spec/spec_helper.rb +30 -0
  66. metadata +149 -0
@@ -0,0 +1,126 @@
1
+ Given /^the website has been populated with content based on the site map$/ do
2
+ seed_file = File.join(Rails.root, "demo", "seeds.rb")
3
+ load(seed_file)
4
+ end
5
+
6
+ When /^I click on a root$/ do
7
+ @_page = Noodall::Node.roots.last
8
+ within("tr:last") { click_link "Children" }
9
+ end
10
+
11
+ Then /^I should see a list the of the root’s children$/ do
12
+ @_page.children.each do |child|
13
+ page.should have_content(child.title)
14
+ end
15
+ end
16
+
17
+ When /^I click on a child$/ do
18
+ @_child = @_page.children.first
19
+ within(:css, "tr:first") { click_link "Children" }
20
+ end
21
+
22
+ Then /^I should see a list of the child’s children$/ do
23
+ @_child.children.each do |gchild|
24
+ page.should have_content(gchild.title)
25
+ end
26
+ end
27
+
28
+ Then /^I should be able to create a new root$/ do
29
+ click_link 'New'
30
+
31
+ fill_in 'Title', :with => 'New Root'
32
+
33
+ click_button 'Create'
34
+
35
+ page.should have_content(' was successfully created.')
36
+ end
37
+
38
+ Then /^I should see the root listed within the roots$/ do
39
+ visit noodall_admin_nodes_path
40
+ page.should have_content('New Root')
41
+ end
42
+
43
+ Then /^I should be able to create a new child$/ do
44
+ click_link 'New'
45
+
46
+ fill_in 'Title', :with => 'New Child'
47
+
48
+ click_button 'Create'
49
+
50
+ page.should have_content(' was successfully created.')
51
+ end
52
+
53
+ Then /^I should see the child listed within the root’s children$/ do
54
+ visit noodall_admin_node_nodes_path(@_page)
55
+ page.should have_content('New Child')
56
+ end
57
+
58
+ Then /^I should be able to delete content$/ do
59
+ @_deleted_node = Noodall::Node.roots.last
60
+ @_deleted_node_children = @_deleted_node.children
61
+
62
+ within(:css, 'table tbody tr:last') { click_link "Delete" }
63
+ page.should have_content("deleted")
64
+ end
65
+
66
+ Then /^the content and all of it’s sub content will be removed from the website$/ do
67
+
68
+ lambda { visit node_path(@_deleted_node) }.should raise_error(MongoMapper::DocumentNotFound)
69
+
70
+ @_deleted_node_children.each do |child|
71
+ lambda { visit node_path(child) }.should raise_error(MongoMapper::DocumentNotFound)
72
+ end
73
+ end
74
+
75
+ Then /^I should be able to move a child content to another parent$/ do
76
+ @_child = @_page.children.first
77
+ @_new_parent = Noodall::Node.roots.first
78
+ within(:css, "table tbody tr#node-#{@_child.id}") { click_link "Edit" }
79
+ # Simulates what we are now doing with JS
80
+ click_link "Advanced"
81
+ within(:css, '#parent-title' ) { click_link "Edit" }
82
+ within(:css, 'ol.tree' ) { click_link @_new_parent.title }
83
+ click_button 'Draft'
84
+ end
85
+
86
+ Then /^I should see the child listed within the other parent’s children$/ do
87
+ visit noodall_admin_node_nodes_path(@_new_parent)
88
+ within('tbody') do
89
+ page.should have_content(@_child.title)
90
+ end
91
+ end
92
+
93
+ Then /^I should be able change the order of the root’s children$/ do
94
+ table = table(tableish("table tr", 'td, th'))
95
+ title = table.hashes[2]['Title'] # 2 as zero index
96
+ within(:css, 'table tbody tr:nth(3)') { click_link "up" }
97
+ table = table(tableish("table tr", 'td, th'))
98
+ table.hashes[1]['Title'].should == title
99
+ within(:css, 'table tbody tr:nth(2)' ) { click_link "down" }
100
+ within(:css, 'table tbody tr:nth(3)' ) { click_link "down" }
101
+ table = table(tableish("table tr", 'td, th'))
102
+ table.hashes[3]['Title'].should == title
103
+ end
104
+
105
+ When /^I create a new child under an ancestor in "([^"]+)" template$/ do |template_title|
106
+ template = template_title.downcase.gsub(' ','_')
107
+ #create the ancester
108
+ parent = Factory(template.to_sym)
109
+
110
+ visit noodall_admin_node_nodes_path(parent)
111
+ click_link 'New'
112
+ end
113
+
114
+ Then /^I should be able select a template from the "([^"]+)"$/ do |sub_template_string|
115
+ sub_templates = sub_template_string.split(', ')
116
+
117
+ sub_templates.each do |sub_template|
118
+ choose sub_template
119
+ end
120
+ end
121
+
122
+ Then /^I should see a list of the roots$/ do
123
+ Noodall::Node.roots.each do |root|
124
+ page.should have_content(root.title)
125
+ end
126
+ end
@@ -0,0 +1,138 @@
1
+ Given /^I am editing content$/ do
2
+ @_content = Factory(:page_a)
3
+ visit noodall_admin_node_path(@_content)
4
+ end
5
+
6
+ When /^(?:|I )click a "([^"]*)" component slot$/ do |slot_name|
7
+ @_slot_type = slot_name.downcase
8
+ within('ol#slot-list') do
9
+ click_link "#{slot_name} Slot"
10
+ end
11
+ end
12
+
13
+ When /^(?:|I )select the "([^\"]+)" component$/ do |component_name|
14
+ within "#fancybox-inner" do
15
+ select component_name, :from => 'Select the type of component'
16
+ end
17
+ end
18
+
19
+ When /^(?:|I )fill in the following within the component:$/ do |fields|
20
+ within "#fancybox-inner" do
21
+ fields.rows_hash.each do |name, value|
22
+ When %{I fill in "#{name}" with "#{value}"}
23
+ end
24
+ end
25
+ end
26
+
27
+ When /^(?:|I )press "([^"]*)" within the component$/ do |button|
28
+ within "#fancybox-inner" do
29
+ click_button(button)
30
+ end
31
+ end
32
+
33
+ When /^(?:|I )select an image from the asset library$/ do
34
+ asset = Factory(:asset, :title => "My Image")
35
+ within "#fancybox-inner" do
36
+ pending
37
+ end
38
+ end
39
+
40
+ When /^(?:I|a website visitor) visit(?:s|) the content page$/ do
41
+ visit node_path(@_content)
42
+ end
43
+
44
+
45
+ Then /^I should see the general content$/ do
46
+ within("div##{@_slot_type}_slot_0.general-content") do |slot|
47
+ slot.should contain('Test Title One')
48
+ end
49
+ end
50
+
51
+ Then /^I select an image from the asset library$/ do
52
+ within "li.multi-file:last" do
53
+ asset = Factory(:asset, :title => "Image 1")
54
+ set_hidden_field "node[#{@_slot_type}_slot_0][contents][][asset_id]", :to => asset.id
55
+ end
56
+ end
57
+
58
+ Then /^I add some images to from the asset library$/ do
59
+ 5.times do |i|
60
+ Factory(:asset, :title => "Image #{i}")
61
+ end
62
+ page.find(:css, 'span.add-multi-asset').click
63
+ 3.times do |i|
64
+ within "#asset-browser li:nth(#{i + 1})" do
65
+ click_link "Add"
66
+ end
67
+ end
68
+ page.find(:css, 'li.action a').click
69
+ end
70
+
71
+ Then /^I should see the gallery thumbnails$/ do
72
+ page.should have_css("ul.gallery li img", :count => 3)
73
+ end
74
+
75
+
76
+ Given /^content exists with a gallery$/ do
77
+ @_content = Factory(:page_a)
78
+ @_content.small_slot_0 = Factory(:gallery)
79
+ @_content.save
80
+ end
81
+
82
+ Given /^I have not entered a URL for the first image$/ do
83
+ @_content.small_slot_0.contents.first.url = ''
84
+ @_content.save
85
+ end
86
+
87
+ Given /^I have entered a URL for the second image$/ do
88
+ @_content.small_slot_0.contents[1].url = 'http://example.com'
89
+ @_content.save
90
+ end
91
+
92
+ When /^I click on the first image$/ do
93
+ @_image = @_content.small_slot_0.contents.first
94
+ click_link_within("ul.gallery li:first", @_image.title)
95
+ end
96
+
97
+ Then /^I should see a larger version of the image$/ do
98
+ # taadaa
99
+ end
100
+
101
+ When /^I click on the second image$/ do
102
+ @_image = @_content.small_slot_0.contents[1]
103
+ response.should have_selector("ul.gallery li:nth(2) a[href='#{@_image.url}']")
104
+ end
105
+ #
106
+ Then /^I should be taken to the URL location$/ do
107
+ # Link already checked
108
+ end
109
+
110
+ Then /^I select some files from the asset library$/ do
111
+ 3.times do |i|
112
+ within "li.multi-file:last" do
113
+ asset = Factory(:document_asset, :title => "Download #{i+1}")
114
+ set_hidden_field 'node[wide_slot_0][contents][][asset_id]', :to => asset.id
115
+ end
116
+ click_button "Publish"
117
+ visit admin_node_path(@_content)
118
+ end
119
+ end
120
+
121
+ Then /^I should see the list of files$/ do
122
+ @_content.reload
123
+ @_content.wide_slot_0.contents.should have(8).things
124
+ response.should have_selector('ul#download-list li', :count => 8)
125
+ end
126
+
127
+ Then /^each file should have an icon based on file\-type$/ do
128
+ response.should have_selector("ul#download-list li.file-type-#{@_content.wide_slot_0.contents.first.asset.file_mime_type.parameterize}")
129
+ end
130
+
131
+ When /^I click on a file's listing$/ do
132
+ click_link_within("ul#download-list", @_content.wide_slot_0.contents.first.asset.title)
133
+ end
134
+
135
+ Then /^the file should start downloading$/ do
136
+ # ||||||||||||||||||=> done
137
+ end
138
+
@@ -0,0 +1,219 @@
1
+ # IMPORTANT: This file is generated by cucumber-rails - edit at your own peril.
2
+ # It is recommended to regenerate this file in the future when you upgrade to a
3
+ # newer version of cucumber-rails. Consider adding your own code to a new file
4
+ # instead of editing this one. Cucumber will automatically load all features/**/*.rb
5
+ # files.
6
+
7
+
8
+ require 'uri'
9
+ require 'cgi'
10
+ require File.expand_path(File.join(File.dirname(__FILE__), "..", "support", "paths"))
11
+
12
+ module WithinHelpers
13
+ def with_scope(locator)
14
+ locator ? within(locator) { yield } : yield
15
+ end
16
+ end
17
+ World(WithinHelpers)
18
+
19
+ Given /^(?:|I )am on (.+)$/ do |page_name|
20
+ visit path_to(page_name)
21
+ end
22
+
23
+ When /^(?:|I )go to (.+)$/ do |page_name|
24
+ visit path_to(page_name)
25
+ end
26
+
27
+ When /^(?:|I )press "([^"]*)"(?: within "([^"]*)")?$/ do |button, selector|
28
+ with_scope(selector) do
29
+ click_button(button)
30
+ end
31
+ end
32
+
33
+ When /^(?:|I )follow "([^"]*)"(?: within "([^"]*)")?$/ do |link, selector|
34
+ with_scope(selector) do
35
+ click_link(link)
36
+ end
37
+ end
38
+
39
+ When /^(?:|I )fill in "([^"]*)" with "([^"]*)"(?: within "([^"]*)")?$/ do |field, value, selector|
40
+ with_scope(selector) do
41
+ fill_in(field, :with => value)
42
+ end
43
+ end
44
+
45
+ When /^(?:|I )fill in "([^"]*)" for "([^"]*)"(?: within "([^"]*)")?$/ do |value, field, selector|
46
+ with_scope(selector) do
47
+ fill_in(field, :with => value)
48
+ end
49
+ end
50
+
51
+ # Use this to fill in an entire form with data from a table. Example:
52
+ #
53
+ # When I fill in the following:
54
+ # | Account Number | 5002 |
55
+ # | Expiry date | 2009-11-01 |
56
+ # | Note | Nice guy |
57
+ # | Wants Email? | |
58
+ #
59
+ # TODO: Add support for checkbox, select og option
60
+ # based on naming conventions.
61
+ #
62
+ When /^(?:|I )fill in the following(?: within "([^"]*)")?:$/ do |selector, fields|
63
+ with_scope(selector) do
64
+ fields.rows_hash.each do |name, value|
65
+ When %{I fill in "#{name}" with "#{value}"}
66
+ end
67
+ end
68
+ end
69
+
70
+ When /^(?:|I )select "([^"]*)" from "([^"]*)"(?: within "([^"]*)")?$/ do |value, field, selector|
71
+ with_scope(selector) do
72
+ select(value, :from => field)
73
+ end
74
+ end
75
+
76
+ When /^(?:|I )check "([^"]*)"(?: within "([^"]*)")?$/ do |field, selector|
77
+ with_scope(selector) do
78
+ check(field)
79
+ end
80
+ end
81
+
82
+ When /^(?:|I )uncheck "([^"]*)"(?: within "([^"]*)")?$/ do |field, selector|
83
+ with_scope(selector) do
84
+ uncheck(field)
85
+ end
86
+ end
87
+
88
+ When /^(?:|I )choose "([^"]*)"(?: within "([^"]*)")?$/ do |field, selector|
89
+ with_scope(selector) do
90
+ choose(field)
91
+ end
92
+ end
93
+
94
+ When /^(?:|I )attach the file "([^"]*)" to "([^"]*)"(?: within "([^"]*)")?$/ do |path, field, selector|
95
+ with_scope(selector) do
96
+ attach_file(field, path)
97
+ end
98
+ end
99
+
100
+ Then /^(?:|I )should see JSON:$/ do |expected_json|
101
+ require 'json'
102
+ expected = JSON.pretty_generate(JSON.parse(expected_json))
103
+ actual = JSON.pretty_generate(JSON.parse(response.body))
104
+ expected.should == actual
105
+ end
106
+
107
+ Then /^(?:|I )should see "([^"]*)"(?: within "([^"]*)")?$/ do |text, selector|
108
+ with_scope(selector) do
109
+ if page.respond_to? :should
110
+ page.should have_content(text)
111
+ else
112
+ assert page.has_content?(text)
113
+ end
114
+ end
115
+ end
116
+
117
+ Then /^(?:|I )should see \/([^\/]*)\/(?: within "([^"]*)")?$/ do |regexp, selector|
118
+ regexp = Regexp.new(regexp)
119
+ with_scope(selector) do
120
+ if page.respond_to? :should
121
+ page.should have_xpath('//*', :text => regexp)
122
+ else
123
+ assert page.has_xpath?('//*', :text => regexp)
124
+ end
125
+ end
126
+ end
127
+
128
+ Then /^(?:|I )should not see "([^"]*)"(?: within "([^"]*)")?$/ do |text, selector|
129
+ with_scope(selector) do
130
+ if page.respond_to? :should
131
+ page.should have_no_content(text)
132
+ else
133
+ assert page.has_no_content?(text)
134
+ end
135
+ end
136
+ end
137
+
138
+ Then /^(?:|I )should not see \/([^\/]*)\/(?: within "([^"]*)")?$/ do |regexp, selector|
139
+ regexp = Regexp.new(regexp)
140
+ with_scope(selector) do
141
+ if page.respond_to? :should
142
+ page.should have_no_xpath('//*', :text => regexp)
143
+ else
144
+ assert page.has_no_xpath?('//*', :text => regexp)
145
+ end
146
+ end
147
+ end
148
+
149
+ Then /^the "([^"]*)" field(?: within "([^"]*)")? should contain "([^"]*)"$/ do |field, selector, value|
150
+ with_scope(selector) do
151
+ field = find_field(field)
152
+ field_value = (field.tag_name == 'textarea') ? field.text : field.value
153
+ if field_value.respond_to? :should
154
+ field_value.should =~ /#{value}/
155
+ else
156
+ assert_match(/#{value}/, field_value)
157
+ end
158
+ end
159
+ end
160
+
161
+ Then /^the "([^"]*)" field(?: within "([^"]*)")? should not contain "([^"]*)"$/ do |field, selector, value|
162
+ with_scope(selector) do
163
+ field = find_field(field)
164
+ field_value = (field.tag_name == 'textarea') ? field.text : field.value
165
+ if field_value.respond_to? :should_not
166
+ field_value.should_not =~ /#{value}/
167
+ else
168
+ assert_no_match(/#{value}/, field_value)
169
+ end
170
+ end
171
+ end
172
+
173
+ Then /^the "([^"]*)" checkbox(?: within "([^"]*)")? should be checked$/ do |label, selector|
174
+ with_scope(selector) do
175
+ field_checked = find_field(label)['checked']
176
+ if field_checked.respond_to? :should
177
+ field_checked.should be_true
178
+ else
179
+ assert field_checked
180
+ end
181
+ end
182
+ end
183
+
184
+ Then /^the "([^"]*)" checkbox(?: within "([^"]*)")? should not be checked$/ do |label, selector|
185
+ with_scope(selector) do
186
+ field_checked = find_field(label)['checked']
187
+ if field_checked.respond_to? :should
188
+ field_checked.should be_false
189
+ else
190
+ assert !field_checked
191
+ end
192
+ end
193
+ end
194
+
195
+ Then /^(?:|I )should be on (.+)$/ do |page_name|
196
+ current_path = URI.parse(current_url).path
197
+ if current_path.respond_to? :should
198
+ current_path.should == path_to(page_name)
199
+ else
200
+ assert_equal path_to(page_name), current_path
201
+ end
202
+ end
203
+
204
+ Then /^(?:|I )should have the following query string:$/ do |expected_pairs|
205
+ query = URI.parse(current_url).query
206
+ actual_params = query ? CGI.parse(query) : {}
207
+ expected_params = {}
208
+ expected_pairs.rows_hash.each_pair{|k,v| expected_params[k] = v.split(',')}
209
+
210
+ if actual_params.respond_to? :should
211
+ actual_params.should == expected_params
212
+ else
213
+ assert_equal expected_params, actual_params
214
+ end
215
+ end
216
+
217
+ Then /^show me the page$/ do
218
+ save_and_open_page
219
+ end