voluntary 0.0.1 → 0.0.2

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 (54) hide show
  1. data/app/helpers/product_helper.rb +5 -3
  2. data/config/initializers/vendor_extensions.rb +1 -0
  3. data/lib/generators/voluntary/install/install_generator.rb +0 -17
  4. data/lib/generators/voluntary/product_dummy/product_dummy_generator.rb +105 -0
  5. data/lib/generators/voluntary/product_dummy/templates/app/controllers/application_controller.rb +3 -0
  6. data/lib/generators/voluntary/product_dummy/templates/app/controllers/home_controller.rb +4 -0
  7. data/lib/generators/voluntary/product_dummy/templates/app/models/ability.rb +49 -0
  8. data/lib/generators/voluntary/product_dummy/templates/app/models/app_config.rb +32 -0
  9. data/lib/generators/voluntary/product_dummy/templates/app/views/home/index.html.erb +0 -0
  10. data/lib/generators/voluntary/product_dummy/templates/app/views/layouts/application.html.erb +50 -0
  11. data/lib/generators/voluntary/product_dummy/templates/config/application.yml +147 -0
  12. data/lib/generators/voluntary/product_dummy/templates/config/cucumber.yml +8 -0
  13. data/lib/generators/voluntary/product_dummy/templates/config/database.example.yml +28 -0
  14. data/lib/generators/voluntary/product_dummy/templates/config/email.example.yml +9 -0
  15. data/lib/generators/voluntary/product_dummy/templates/config/locale_settings.yml +121 -0
  16. data/lib/generators/voluntary/product_dummy/templates/config/main_navigation.rb +262 -0
  17. data/lib/generators/voluntary/product_dummy/templates/config/mongoid.yml +78 -0
  18. data/lib/generators/voluntary/product_dummy/templates/config/routes.rb +3 -0
  19. data/lib/generators/voluntary/product_dummy/templates/features/step_definitions/area_behaviour_steps.rb +17 -0
  20. data/lib/generators/voluntary/product_dummy/templates/features/step_definitions/area_steps.rb +11 -0
  21. data/lib/generators/voluntary/product_dummy/templates/features/step_definitions/candidature_steps.rb +34 -0
  22. data/lib/generators/voluntary/product_dummy/templates/features/step_definitions/comment_behaviour_steps.rb +23 -0
  23. data/lib/generators/voluntary/product_dummy/templates/features/step_definitions/comment_steps.rb +25 -0
  24. data/lib/generators/voluntary/product_dummy/templates/features/step_definitions/email_steps.rb +89 -0
  25. data/lib/generators/voluntary/product_dummy/templates/features/step_definitions/factory_steps.rb +120 -0
  26. data/lib/generators/voluntary/product_dummy/templates/features/step_definitions/javascript_steps.rb +15 -0
  27. data/lib/generators/voluntary/product_dummy/templates/features/step_definitions/navigation_steps.rb +3 -0
  28. data/lib/generators/voluntary/product_dummy/templates/features/step_definitions/product_steps.rb +15 -0
  29. data/lib/generators/voluntary/product_dummy/templates/features/step_definitions/project_steps.rb +23 -0
  30. data/lib/generators/voluntary/product_dummy/templates/features/step_definitions/resources_steps.rb +8 -0
  31. data/lib/generators/voluntary/product_dummy/templates/features/step_definitions/session_steps.rb +35 -0
  32. data/lib/generators/voluntary/product_dummy/templates/features/step_definitions/state_machines/vacancy_steps.rb +7 -0
  33. data/lib/generators/voluntary/product_dummy/templates/features/step_definitions/story_steps.rb +33 -0
  34. data/lib/generators/voluntary/product_dummy/templates/features/step_definitions/task_steps.rb +29 -0
  35. data/lib/generators/voluntary/product_dummy/templates/features/step_definitions/user_steps.rb +4 -0
  36. data/lib/generators/voluntary/product_dummy/templates/features/step_definitions/vacancy_steps.rb +32 -0
  37. data/lib/generators/voluntary/product_dummy/templates/features/step_definitions/web_steps.rb +271 -0
  38. data/lib/generators/voluntary/product_dummy/templates/features/step_definitions/wizards/story_steps.rb +15 -0
  39. data/lib/generators/voluntary/product_dummy/templates/features/support/database_cleaner_patches.rb +24 -0
  40. data/lib/generators/voluntary/product_dummy/templates/features/support/env.rb +86 -0
  41. data/lib/generators/voluntary/product_dummy/templates/features/support/integration_sessions_controller.rb +32 -0
  42. data/lib/generators/voluntary/product_dummy/templates/features/support/integration_sessions_form.html.erb +1 -0
  43. data/lib/generators/voluntary/product_dummy/templates/features/support/paths.rb +98 -0
  44. data/lib/generators/voluntary/product_dummy/templates/features/support/selectors.rb +44 -0
  45. data/lib/generators/voluntary/product_dummy/templates/features/support/spork_env +72 -0
  46. data/lib/generators/voluntary/product_dummy/templates/features/support/user_cuke_helpers.rb +78 -0
  47. data/lib/generators/voluntary/product_dummy/templates/spec/support/deferred_garbage_collector.rb +45 -0
  48. data/lib/generators/voluntary/product_dummy/templates/spec/support/devise.rb +3 -0
  49. data/lib/generators/voluntary/product_dummy/templates/spec/support/mongo_database_cleaner.rb +25 -0
  50. data/lib/voluntary/version.rb +1 -1
  51. metadata +212 -168
  52. data/app/views/products/types/text_creation/stories/_form.html.erb +0 -19
  53. data/app/views/products/types/text_creation/stories/_task_fields.html.erb +0 -7
  54. data/lib/vendors/active_model/naming.rb +0 -14
@@ -0,0 +1,15 @@
1
+ When /^I confirm all future JS confirm dialogs on this page$/ do
2
+ page.evaluate_script('window.confirm = function() { return true; }')
3
+ end
4
+
5
+ When /^I cancel all future JS confirm dialogs on this page$/ do
6
+ page.evaluate_script('window.confirm = function() { return false; }')
7
+ end
8
+
9
+ When /^I confirm popup$/ do
10
+ page.driver.browser.switch_to.alert.accept
11
+ end
12
+
13
+ When /^I dismiss popup$/ do
14
+ page.driver.browser.switch_to.alert.dismiss
15
+ end
@@ -0,0 +1,3 @@
1
+ When /^I click the (\d+)(?:st|nd|rd|th) link of the (\d+)(?:st|nd|rd|th) row$/ do |link_position, row_position|
2
+ within(:row, row_position.to_i) { find(:xpath, ".//a[#{link_position.to_i}]").click }
3
+ end
@@ -0,0 +1,15 @@
1
+ Given /^a product named "([^\"]*)"$/ do |name|
2
+ attributes = {name: name}
3
+ attributes[:user_id] ||= @me.id if @me
4
+ attributes[:area_ids] ||= [Area.last.id] if Area.any?
5
+
6
+ @product = Product.where(name: name).first || Factory(:product, attributes)
7
+
8
+ @product.reload
9
+ end
10
+
11
+ Then /^I should see the following products:$/ do |expected_table|
12
+ rows = find('table').all('tr')
13
+ table = rows.map { |r| r.all('th,td').map { |c| c.text.strip } }
14
+ expected_table.diff!(table)
15
+ end
@@ -0,0 +1,23 @@
1
+ module ProjectFactoryMethods
2
+ def set_project_defaults(attributes)
3
+ attributes[:user_id] ||= @me.id if @me && !attributes[:user_id]
4
+ attributes[:product_id] ||= @product.id if @product && !attributes[:product_id]
5
+ attributes[:area_ids] ||= [Area.last.id] if Area.any? && !attributes[:area_ids]
6
+ end
7
+ end
8
+
9
+ World(ProjectFactoryMethods)
10
+
11
+ Given /^a project named "([^\"]*)"$/ do |name|
12
+ attributes = {name: name}
13
+ set_project_defaults(attributes)
14
+ @project = Factory(:project, attributes)
15
+
16
+ @project.reload
17
+ end
18
+
19
+ Then /^I should see the following projects:$/ do |expected_table|
20
+ rows = find('table').all('tr')
21
+ table = rows.map { |r| r.all('th,td').map { |c| c.text.strip } }
22
+ expected_table.diff!(table)
23
+ end
@@ -0,0 +1,8 @@
1
+ When /^I delete the (\d+)(?:st|nd|rd|th) "([^\"]*)"$/ do |pos, resource_name|
2
+ visit eval("#{resource_name.pluralize}_path")
3
+
4
+ within(:row, pos.to_i) { find(:xpath, ".//a[contains(text(), 'Actions')]").click }
5
+
6
+ page.execute_script 'window.confirm = function () { return true }'
7
+ click_link I18n.t('general.destroy')
8
+ end
@@ -0,0 +1,35 @@
1
+
2
+ Given /^(?:I am signed in|I sign in)$/ do
3
+ automatic_login
4
+ confirm_login
5
+ end
6
+
7
+ When /^I (?:sign|log) in as "([^"]*)"$/ do |name|
8
+ @me = User.find_by_name(name)
9
+ @me.password = 'password'
10
+ automatic_login
11
+ end
12
+
13
+ When /^I fill out change password section with my password and "([^"]*)" and "([^"]*)"$/ do |new_pass, confirm_pass|
14
+ fill_change_password_section(@me.password, new_pass, confirm_pass)
15
+ end
16
+
17
+ When /^I fill out forgot password form with "([^"]*)"$/ do |email|
18
+ fill_forgot_password_form(email)
19
+ end
20
+
21
+ When /^I submit forgot password form$/ do
22
+ submit_forgot_password_form
23
+ end
24
+
25
+ When /^I fill out reset password form with "([^"]*)" and "([^"]*)"$/ do |new_pass,confirm_pass|
26
+ fill_reset_password_form(new_pass, confirm_pass)
27
+ end
28
+
29
+ When /^I submit reset password form$/ do
30
+ submit_reset_password_form
31
+ end
32
+
33
+ When /^I (?:log|sign) out$/ do
34
+ logout
35
+ end
@@ -0,0 +1,7 @@
1
+ When /I click on the tab "([^"]*)"/ do |tab|
2
+ page.execute_script("$('a[href=\"##{tab.strip}\"]').click()")
3
+ end
4
+
5
+ When /I click on the (\d+)(?:st|nd|rd|th) link of a tab "([^"]*)"/ do |pos, tab|
6
+ find(:xpath, "id('#{tab}')//a[#{pos.to_i}]").click
7
+ end
@@ -0,0 +1,33 @@
1
+ module StoryFactoryMethods
2
+ def new_story(name, options = {})
3
+ factory = options[:factory] || :story
4
+ attributes = options[:attributes] || {}
5
+
6
+ attributes.merge!({name: name})
7
+ set_story_defaults(attributes)
8
+ @story = Factory(factory, attributes)
9
+
10
+ @story.reload
11
+ end
12
+
13
+ def set_story_defaults(attributes)
14
+ attributes[:offeror_id] ||= @me.id if @me && !attributes[:offeror_id]
15
+ attributes[:project_id] ||= @project.id if @project && !attributes[:project_id]
16
+ end
17
+ end
18
+
19
+ World(StoryFactoryMethods)
20
+
21
+ Given /^a story named "([^\"]*)"$/ do |name|
22
+ new_story(name)
23
+ end
24
+
25
+ Given /^a story without tasks named "([^\"]*)"$/ do |name|
26
+ new_story(name, factory: :story_without_tasks)
27
+ end
28
+
29
+ Then /^I should see the following stories:$/ do |expected_table|
30
+ rows = find('table').all('tr')
31
+ table = rows.map { |r| r.all('th,td').map { |c| c.text.strip } }
32
+ expected_table.diff!(table)
33
+ end
@@ -0,0 +1,29 @@
1
+ module TaskFactoryMethods
2
+ def new_task(name, options = {})
3
+ factory = options[:factory] || :task
4
+ attributes = options[:attributes] || {}
5
+
6
+ attributes.merge!({name: name})
7
+ set_task_defaults(attributes)
8
+ @task = Factory(factory, attributes)
9
+ @task.reload
10
+
11
+ @task
12
+ end
13
+
14
+ def set_task_defaults(attributes)
15
+ attributes[:story_id] ||= @story.id if @story && !attributes[:story_id]
16
+ end
17
+ end
18
+
19
+ World(TaskFactoryMethods)
20
+
21
+ Given /^a task named "([^\"]*)"$/ do |name|
22
+ new_task(name)
23
+ end
24
+
25
+ Then /^I should see the following tasks:$/ do |expected_table|
26
+ rows = find('table').all('tr')
27
+ table = rows.map { |r| r.all('th,td').map { |c| c.text.strip } }
28
+ expected_table.diff!(table)
29
+ end
@@ -0,0 +1,4 @@
1
+ Given /^a user named "([^\"]*)"$/ do |name|
2
+ @me = Factory(:user, name: name, email: "#{name}@volontari.at")
3
+ @me.reload
4
+ end
@@ -0,0 +1,32 @@
1
+ module VacancyFactoryMethods
2
+ def set_vacancy_defaults(attributes)
3
+ attributes[:user_id] ||= @me.id unless attributes[:user_id] || !@me
4
+ attributes[:project_id] ||= Project.last.id unless attributes[:project_id] || Project.all.none?
5
+ end
6
+
7
+ def new_vacancy(name, state = nil)
8
+ attributes = { name: name }
9
+ attributes[:state] = state if state
10
+
11
+ set_vacancy_defaults(attributes)
12
+
13
+ @vacancy = Factory(:vacancy, attributes)
14
+ @vacancy.reload
15
+ end
16
+ end
17
+
18
+ World(VacancyFactoryMethods)
19
+
20
+ Given /^a vacancy named "([^\"]*)"$/ do |name|
21
+ new_vacancy(name)
22
+ end
23
+
24
+ Given /^a vacancy named "([^\"]*)" with state "([^\"]*)"$/ do |name, state|
25
+ new_vacancy(name, state)
26
+ end
27
+
28
+ Then /^I should see the following vacancies:$/ do |expected_table|
29
+ rows = find('table').all('tr')
30
+ table = rows.map { |r| r.all('th,td').map { |c| c.text.strip } }
31
+ expected_table.diff!(table)
32
+ end
@@ -0,0 +1,271 @@
1
+ # TL;DR: YOU SHOULD DELETE THIS FILE
2
+ #
3
+ # This file was generated by Cucumber-Rails and is only here to get you a head start
4
+ # These step definitions are thin wrappers around the Capybara/Webrat API that lets you
5
+ # visit pages, interact with widgets and make assertions about page content.
6
+ #
7
+ # If you use these step definitions as basis for your features you will quickly end up
8
+ # with features that are:
9
+ #
10
+ # * Hard to maintain
11
+ # * Verbose to read
12
+ #
13
+ # A much better approach is to write your own higher level step definitions, following
14
+ # the advice in the following blog posts:
15
+ #
16
+ # * http://benmabey.com/2008/05/19/imperative-vs-declarative-scenarios-in-user-stories.html
17
+ # * http://dannorth.net/2011/01/31/whose-domain-is-it-anyway/
18
+ # * http://elabs.se/blog/15-you-re-cuking-it-wrong
19
+ #
20
+
21
+
22
+ require 'uri'
23
+ require 'cgi'
24
+ require File.expand_path(File.join(File.dirname(__FILE__), "..", "support", "paths"))
25
+ require File.expand_path(File.join(File.dirname(__FILE__), "..", "support", "selectors"))
26
+
27
+ module WithinHelpers
28
+ def with_scope(locator)
29
+ locator ? within(*selector_for(locator)) { yield } : yield
30
+ end
31
+ end
32
+ World(WithinHelpers)
33
+
34
+ # Single-line step scoper
35
+ When /^(.*) within (.*[^:])$/ do |step, parent|
36
+ with_scope(parent) { When step }
37
+ end
38
+
39
+ # Multi-line step scoper
40
+ When /^(.*) within (.*[^:]):$/ do |step, parent, table_or_string|
41
+ with_scope(parent) { When "#{step}:", table_or_string }
42
+ end
43
+
44
+ Given /^(?:|I )am on (.+)$/ do |page_name|
45
+ visit path_to(page_name)
46
+ end
47
+
48
+ When /^(?:|I )go to (.+)$/ do |page_name|
49
+ visit path_to(page_name)
50
+ end
51
+
52
+ When /^(?:|I )press "([^"]*)"$/ do |button|
53
+ click_button(button)
54
+ end
55
+
56
+ When /^(?:|I )follow "([^"]*)"$/ do |link|
57
+ click_link(link)
58
+ end
59
+
60
+ When /^(?:|I )fill in "([^"]*)" with "([^"]*)"$/ do |field, value|
61
+ fill_in(field, :with => value)
62
+ end
63
+
64
+ When /^(?:|I )fill in "([^"]*)" for "([^"]*)"$/ do |value, field|
65
+ fill_in(field, :with => value)
66
+ end
67
+
68
+ # TODO: get more than the 1st fieldset working
69
+ When /^(?:|I )fill in the (\d+)(?:st|nd|rd|th) field of "([^"]*)" with "([^"]*)"$/ do |pos, field, value|
70
+ raise NotImplementedError unless pos.to_i == 1
71
+
72
+ within(find(:xpath, "//fieldset[#{pos.to_i}]")) do
73
+ fill_in(field, :with => value)
74
+ end
75
+ end
76
+
77
+ # Use this to fill in an entire form with data from a table. Example:
78
+ #
79
+ # When I fill in the following:
80
+ # | Account Number | 5002 |
81
+ # | Expiry date | 2009-11-01 |
82
+ # | Note | Nice guy |
83
+ # | Wants Email? | |
84
+ #
85
+ # TODO: Add support for checkbox, select or option
86
+ # based on naming conventions.
87
+ #
88
+ When /^(?:|I )fill in the following:$/ do |fields|
89
+ fields.rows_hash.each do |name, value|
90
+ When %{I fill in "#{name}" with "#{value}"}
91
+ end
92
+ end
93
+
94
+ When /^(?:|I )select "([^"]*)" from "([^"]*)"$/ do |value, field|
95
+ select(value, :from => field)
96
+ end
97
+
98
+ When /^(?:|I )check "([^"]*)"$/ do |field|
99
+ check(field)
100
+ end
101
+
102
+ When /^(?:|I )uncheck "([^"]*)"$/ do |field|
103
+ uncheck(field)
104
+ end
105
+
106
+ When /^(?:|I )choose "([^"]*)"$/ do |field|
107
+ choose(field)
108
+ end
109
+
110
+ When /^(?:|I )attach the file "([^"]*)" to "([^"]*)"$/ do |path, field|
111
+ attach_file(field, File.expand_path(path))
112
+ end
113
+
114
+ When /^(?:|I )click element "([^"]*)"$/ do |selector|
115
+ find(selector_for(selector)).click
116
+ end
117
+
118
+ When /^(?:|I )click on "([^"]*)" inside "([^"]*)"$/ do |selector, container|
119
+ find(container).find(selector).click
120
+ end
121
+
122
+ Then /^(?:|I )should see "([^"]*)"$/ do |text|
123
+ if page.respond_to? :should
124
+ page.should have_content(text)
125
+ else
126
+ assert page.has_content?(text)
127
+ end
128
+ end
129
+
130
+ Then /^(?:|I )should see \/([^\/]*)\/$/ do |regexp|
131
+ regexp = Regexp.new(regexp)
132
+
133
+ if page.respond_to? :should
134
+ page.should have_xpath('//*', :text => regexp)
135
+ else
136
+ assert page.has_xpath?('//*', :text => regexp)
137
+ end
138
+ end
139
+
140
+ Then /^(?:|I )should not see "([^"]*)"$/ do |text|
141
+ if page.respond_to? :should
142
+ page.should have_no_content(text)
143
+ else
144
+ assert page.has_no_content?(text)
145
+ end
146
+ end
147
+
148
+ Then /^(?:|I )should not see \/([^\/]*)\/$/ do |regexp|
149
+ regexp = Regexp.new(regexp)
150
+
151
+ if page.respond_to? :should
152
+ page.should have_no_xpath('//*', :text => regexp)
153
+ else
154
+ assert page.has_no_xpath?('//*', :text => regexp)
155
+ end
156
+ end
157
+
158
+ Then /^the "([^"]*)" field(?: within (.*))? should contain "([^"]*)"$/ do |field, parent, value|
159
+ with_scope(parent) do
160
+ field = find_field(field)
161
+ field_value = (field.tag_name == 'textarea') ? field.text : field.value
162
+ if field_value.respond_to? :should
163
+ field_value.should =~ /#{value}/
164
+ else
165
+ assert_match(/#{value}/, field_value)
166
+ end
167
+ end
168
+ end
169
+
170
+ Then /^the "([^"]*)" field(?: within (.*))? should not contain "([^"]*)"$/ do |field, parent, value|
171
+ with_scope(parent) do
172
+ field = find_field(field)
173
+ field_value = (field.tag_name == 'textarea') ? field.text : field.value
174
+ if field_value.respond_to? :should_not
175
+ field_value.should_not =~ /#{value}/
176
+ else
177
+ assert_no_match(/#{value}/, field_value)
178
+ end
179
+ end
180
+ end
181
+
182
+ Then /^the "([^"]*)" field should have the error "([^"]*)"$/ do |field, error_message|
183
+ element = find_field(field)
184
+ classes = element.find(:xpath, '..')[:class].split(' ')
185
+
186
+ form_for_input = element.find(:xpath, 'ancestor::form[1]')
187
+ using_formtastic = form_for_input[:class].include?('formtastic')
188
+ error_class = using_formtastic ? 'error' : 'field_with_errors'
189
+
190
+ if classes.respond_to? :should
191
+ classes.should include(error_class)
192
+ else
193
+ assert classes.include?(error_class)
194
+ end
195
+
196
+ if page.respond_to?(:should)
197
+ if using_formtastic
198
+ error_paragraph = element.find(:xpath, '../*[@class="inline-errors"][1]')
199
+ error_paragraph.should have_content(error_message)
200
+ else
201
+ page.should have_content("#{field.titlecase} #{error_message}")
202
+ end
203
+ else
204
+ if using_formtastic
205
+ error_paragraph = element.find(:xpath, '../*[@class="inline-errors"][1]')
206
+ assert error_paragraph.has_content?(error_message)
207
+ else
208
+ assert page.has_content?("#{field.titlecase} #{error_message}")
209
+ end
210
+ end
211
+ end
212
+
213
+ Then /^the "([^"]*)" field should have no error$/ do |field|
214
+ element = find_field(field)
215
+ classes = element.find(:xpath, '..')[:class].split(' ')
216
+ if classes.respond_to? :should
217
+ classes.should_not include('field_with_errors')
218
+ classes.should_not include('error')
219
+ else
220
+ assert !classes.include?('field_with_errors')
221
+ assert !classes.include?('error')
222
+ end
223
+ end
224
+
225
+ Then /^the "([^"]*)" checkbox(?: within (.*))? should be checked$/ do |label, parent|
226
+ with_scope(parent) do
227
+ field_checked = find_field(label)['checked']
228
+ if field_checked.respond_to? :should
229
+ field_checked.should be_true
230
+ else
231
+ assert field_checked
232
+ end
233
+ end
234
+ end
235
+
236
+ Then /^the "([^"]*)" checkbox(?: within (.*))? should not be checked$/ do |label, parent|
237
+ with_scope(parent) do
238
+ field_checked = find_field(label)['checked']
239
+ if field_checked.respond_to? :should
240
+ field_checked.should be_false
241
+ else
242
+ assert !field_checked
243
+ end
244
+ end
245
+ end
246
+
247
+ Then /^(?:|I )should be on (.+)$/ do |page_name|
248
+ current_path = URI.parse(current_url).path
249
+ if current_path.respond_to? :should
250
+ current_path.should == path_to(page_name)
251
+ else
252
+ assert_equal path_to(page_name), current_path
253
+ end
254
+ end
255
+
256
+ Then /^(?:|I )should have the following query string:$/ do |expected_pairs|
257
+ query = URI.parse(current_url).query
258
+ actual_params = query ? CGI.parse(query) : {}
259
+ expected_params = {}
260
+ expected_pairs.rows_hash.each_pair{|k,v| expected_params[k] = v.split(',')}
261
+
262
+ if actual_params.respond_to? :should
263
+ actual_params.should == expected_params
264
+ else
265
+ assert_equal expected_params, actual_params
266
+ end
267
+ end
268
+
269
+ Then /^show me the page$/ do
270
+ save_and_open_page
271
+ end
@@ -0,0 +1,15 @@
1
+ When /^(?:|I )fill in the name field of the 1st task with "([^"]*)"$/ do |value|
2
+ find(:xpath, '/html/body/div[2]/div/div/div[2]/div[2]/form/fieldset//input[1]').set(value)
3
+ end
4
+
5
+ When /^(?:|I )fill in the text field of the 1st task with "([^"]*)"$/ do |value|
6
+ find(:xpath, '/html/body/div[2]/div/div/div[2]/div[2]/form/fieldset//textarea[1]').set(value)
7
+ end
8
+
9
+ When /^(?:|I )fill in the name field of the 2nd task with "([^"]*)"$/ do |value|
10
+ find(:xpath, '/html/body/div[2]/div/div/div[2]/div[2]/form/div[3]/fieldset//input[1]').set(value)
11
+ end
12
+
13
+ When /^(?:|I )fill in the text field of the 2nd task with "([^"]*)"$/ do |value|
14
+ find(:xpath, '/html/body/div[2]/div/div/div[2]/div[2]/form/div[3]/fieldset//textarea[1]').set(value)
15
+ end
@@ -0,0 +1,24 @@
1
+ # Copyright (c) 2010-2011, Diaspora Inc. This file is
2
+ # licensed under the Affero General Public License version 3 or later. See
3
+ # the COPYRIGHT file.
4
+
5
+ # disable_referential_integrity doesn't work when using PostgreSQL
6
+ # with a non-root user.
7
+ # See http://kopongo.com/2008/7/25/postgres-ri_constrainttrigger-error
8
+ module ActiveRecord
9
+ module ConnectionAdapters
10
+ class PostgreSQLAdapter < AbstractAdapter
11
+ def disable_referential_integrity(&block)
12
+ transaction {
13
+ begin
14
+ execute "SET CONSTRAINTS ALL DEFERRED"
15
+ yield
16
+ ensure
17
+ execute "SET CONSTRAINTS ALL IMMEDIATE"
18
+ end
19
+ }
20
+ end
21
+ end
22
+ end
23
+ end
24
+
@@ -0,0 +1,86 @@
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
+ if ENV['COVERAGE_REPORT']
8
+ require 'simplecov'
9
+ SimpleCov.start 'rails'
10
+ end
11
+
12
+ require 'cucumber/rails'
13
+ require 'factory_girl'
14
+ require 'capybara/webkit'
15
+ require File.expand_path(File.dirname(__FILE__) + '/../../spec/factories')
16
+ require File.expand_path(File.dirname(__FILE__) + '/../../spec/support/mongo_database_cleaner')
17
+ require File.join(File.dirname(__FILE__), "integration_sessions_controller")
18
+
19
+ # Capybara defaults to XPath selectors rather than Webrat's default of CSS3. In
20
+ # order to ease the transition to Capybara we set the default here. If you'd
21
+ # prefer to use XPath just remove this line and adjust any selectors in your
22
+ # steps to use the XPath syntax.
23
+ Capybara.default_selector = :css
24
+
25
+ Capybara.javascript_driver = ENV['JAVASCRIPT_DRIVER'] ? ENV['JAVASCRIPT_DRIVER'].to_sym : :webkit
26
+
27
+ Capybara.add_selector(:row) do
28
+ xpath { |num| ".//tbody/tr[#{num}]" }
29
+ end
30
+
31
+ # By default, any exception happening in your Rails application will bubble up
32
+ # to Cucumber so that your scenario will fail. This is a different from how
33
+ # your application behaves in the production environment, where an error page will
34
+ # be rendered instead.
35
+ #
36
+ # Sometimes we want to override this default behaviour and allow Rails to rescue
37
+ # exceptions and display an error page (just like when the app is running in production).
38
+ # Typical scenarios where you want to do this is when you test your error pages.
39
+ # There are two ways to allow Rails to rescue exceptions:
40
+ #
41
+ # 1) Tag your scenario (or feature) with @allow-rescue
42
+ #
43
+ # 2) Set the value below to true. Beware that doing this globally is not
44
+ # recommended as it will mask a lot of errors for you!
45
+ #
46
+ ActionController::Base.allow_rescue = false
47
+
48
+ # Remove/comment out the lines below if your app doesn't have a database.
49
+ # For some databases (like MongoDB and CouchDB) you may need to use :truncation instead.
50
+ begin
51
+ DatabaseCleaner.strategy = :truncation
52
+ Cucumber::Rails::World.use_transactional_fixtures = false
53
+ rescue NameError
54
+ raise "You need to add database_cleaner to your Gemfile (in the :test group) if you wish to use it."
55
+ end
56
+
57
+ After do
58
+ # TODO: find a better solution
59
+ #begin
60
+ MongoDatabaseCleaner.clean
61
+ #rescue Exception => e
62
+ # DatabaseCleaner.logger.error "Exception encountered by DatabaseCleaner in Cucumber After block: #{e}"
63
+ #end
64
+ end
65
+
66
+
67
+ # You may also want to configure DatabaseCleaner to use different strategies for certain features and scenarios.
68
+ # See the DatabaseCleaner documentation for details. Example:
69
+ #
70
+ # Before('@no-txn,@selenium,@culerity,@celerity,@javascript') do
71
+ # # { :except => [:widgets] } may not do what you expect here
72
+ # # as tCucumber::Rails::Database.javascript_strategy overrides
73
+ # # this setting.
74
+ # DatabaseCleaner.strategy = :truncation
75
+ # end
76
+ #
77
+ # Before('~@no-txn', '~@selenium', '~@culerity', '~@celerity', '~@javascript') do
78
+ # DatabaseCleaner.strategy = :transaction
79
+ # end
80
+ #
81
+
82
+ # Possible values are :truncation and :transaction
83
+ # The :transaction strategy is faster, but might give you threading problems.
84
+ # See https://github.com/cucumber/cucumber-rails/blob/master/features/choose_javascript_database_strategy.feature
85
+ Cucumber::Rails::Database.javascript_strategy = :truncation
86
+
@@ -0,0 +1,32 @@
1
+ class IntegrationSessionsController < ActionController::Base
2
+ def new
3
+ @user_id = params[:user_id]
4
+ render 'features/support/integration_sessions_form', layout: false
5
+ end
6
+
7
+ def create
8
+ logger.info User.find(params[:user_id]).inspect
9
+ sign_in_and_redirect User.find(params[:user_id])
10
+ end
11
+ end
12
+
13
+ #Copypasta from http://openhood.com/rails/rails%203/2010/07/20/add-routes-at-runtime-rails-3/
14
+ _routes = nil
15
+
16
+ begin
17
+ _routes = Dummy::Application.routes
18
+ _routes.disable_clear_and_finalize = true
19
+ _routes.clear!
20
+
21
+ Dummy::Application.routes_reloader.paths.each{ |path| load(path) }
22
+
23
+ _routes.draw do
24
+ # here you can add any route you want
25
+ post 'integration_sessions' => 'integration_sessions#create', :as => 'integration_sessions'
26
+ get 'integration_sessions' => 'integration_sessions#new', :as => 'new_integration_sessions'
27
+ end
28
+
29
+ ActiveSupport.on_load(:action_controller) { _routes.finalize! }
30
+ ensure
31
+ _routes.disable_clear_and_finalize = false
32
+ end
@@ -0,0 +1 @@
1
+ <%= button_to "Login", integration_sessions_path(user_id: @user_id) %>