admin_data 1.0.22 → 1.1.0

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 (116) hide show
  1. data/History.txt +23 -16
  2. data/README.md +1 -1
  3. data/Rakefile +2 -2
  4. data/app/controllers/admin_data/application_controller.rb +111 -0
  5. data/app/controllers/admin_data/crud_controller.rb +100 -0
  6. data/app/controllers/admin_data/feed_controller.rb +38 -16
  7. data/app/controllers/admin_data/home_controller.rb +11 -0
  8. data/app/controllers/admin_data/migration_controller.rb +12 -12
  9. data/app/controllers/admin_data/public_controller.rb +29 -19
  10. data/app/controllers/admin_data/search_controller.rb +99 -103
  11. data/app/controllers/admin_data/table_structure_controller.rb +25 -0
  12. data/app/helpers/admin_data/application_helper.rb +287 -0
  13. data/app/views/admin_data/crud/association/_association_info.html.erb +11 -0
  14. data/app/views/admin_data/crud/association/_belongs_to_info.html.erb +7 -0
  15. data/app/views/admin_data/{main → crud}/association/_habtm_info.html.erb +3 -3
  16. data/app/views/admin_data/{main → crud}/association/_has_many_info.html.erb +3 -3
  17. data/app/views/admin_data/crud/association/_has_one_info.html.erb +6 -0
  18. data/app/views/admin_data/{main → crud}/edit.html.erb +9 -9
  19. data/app/views/admin_data/{main → crud}/misc/_form.html.erb +6 -6
  20. data/app/views/admin_data/{main → crud}/misc/_modify_record.html.erb +4 -4
  21. data/app/views/admin_data/{main → crud}/new.html.erb +7 -7
  22. data/app/views/admin_data/{main → crud}/show.html.erb +10 -10
  23. data/app/views/admin_data/{main → home}/index.html.erb +2 -2
  24. data/app/views/admin_data/migration/index.html.erb +3 -3
  25. data/app/views/admin_data/search/_search_base.html.erb +5 -5
  26. data/app/views/admin_data/search/quick_search.html.erb +4 -4
  27. data/app/views/admin_data/search/search/_listing.html.erb +11 -9
  28. data/app/views/admin_data/search/search/_sortby.html.erb +4 -3
  29. data/app/views/admin_data/search/search/_title.html.erb +7 -7
  30. data/app/views/admin_data/shared/_breadcrum.html.erb +11 -5
  31. data/app/views/admin_data/shared/_header.html.erb +6 -6
  32. data/app/views/admin_data/shared/_secondary_navigation.html.erb +13 -14
  33. data/app/views/admin_data/{main/table_structure.html.erb → table_structure/index.html.erb} +11 -11
  34. data/app/views/layouts/admin_data.html.erb +15 -15
  35. data/config/routes.rb +3 -3
  36. data/lib/admin_data.rb +29 -6
  37. data/lib/admin_data/active_record_util.rb +38 -6
  38. data/lib/admin_data/configuration.rb +113 -0
  39. data/lib/admin_data/deprecation.rb +31 -0
  40. data/lib/admin_data/railtie.rb +2 -7
  41. data/lib/admin_data/search.rb +1 -1
  42. data/lib/admin_data/util.rb +74 -161
  43. data/lib/admin_data/version.rb +1 -1
  44. data/test/rails_root/app/controllers/application_controller.rb +3 -0
  45. data/test/rails_root/app/helpers/application_helper.rb +5 -0
  46. data/test/rails_root/app/models/city.rb +22 -0
  47. data/test/rails_root/app/models/club.rb +3 -0
  48. data/test/rails_root/app/models/newspaper.rb +4 -0
  49. data/test/rails_root/app/models/phone_number.rb +3 -0
  50. data/test/rails_root/app/models/user.rb +17 -0
  51. data/test/rails_root/app/models/website.rb +3 -0
  52. data/test/rails_root/config/application.rb +42 -0
  53. data/test/rails_root/config/boot.rb +13 -0
  54. data/test/rails_root/config/environment.rb +5 -0
  55. data/test/rails_root/config/environments/development.rb +22 -0
  56. data/test/rails_root/config/environments/production.rb +49 -0
  57. data/test/rails_root/config/environments/test.rb +35 -0
  58. data/test/rails_root/config/initializers/admin_data.rb +22 -0
  59. data/test/rails_root/config/initializers/backtrace_silencers.rb +7 -0
  60. data/test/rails_root/config/initializers/empty_spaces_to_nil.rb +10 -0
  61. data/test/rails_root/config/initializers/inflections.rb +10 -0
  62. data/test/rails_root/config/initializers/mime_types.rb +5 -0
  63. data/test/rails_root/config/initializers/secret_token.rb +7 -0
  64. data/test/rails_root/config/initializers/session_store.rb +8 -0
  65. data/test/rails_root/config/routes.rb +9 -0
  66. data/test/rails_root/db/migrate/20091030202259_create_users.rb +55 -0
  67. data/test/rails_root/db/schema.rb +63 -0
  68. data/test/rails_root/db/seeds.rb +40 -0
  69. data/test/rails_root/features/step_definitions/advance_search_steps.rb +13 -0
  70. data/test/rails_root/features/step_definitions/app_steps.rb +40 -0
  71. data/test/rails_root/features/step_definitions/async.rb +18 -0
  72. data/test/rails_root/features/step_definitions/crud_show_steps.rb +37 -0
  73. data/test/rails_root/features/step_definitions/feed_steps.rb +3 -0
  74. data/test/rails_root/features/step_definitions/quick_search_steps.rb +65 -0
  75. data/test/rails_root/features/step_definitions/util.rb +86 -0
  76. data/test/rails_root/features/step_definitions/web_steps.rb +219 -0
  77. data/test/rails_root/features/support/env.rb +68 -0
  78. data/test/rails_root/features/support/paths.rb +33 -0
  79. data/test/rails_root/test/factories.rb +30 -0
  80. data/test/rails_root/test/performance/browsing_test.rb +9 -0
  81. data/test/rails_root/test/test_helper.rb +13 -0
  82. metadata +100 -49
  83. data/app/controllers/admin_data/base_controller.rb +0 -112
  84. data/app/controllers/admin_data/main_controller.rb +0 -141
  85. data/app/views/admin_data/main/association/_association_info.html.erb +0 -11
  86. data/app/views/admin_data/main/association/_belongs_to_info.html.erb +0 -7
  87. data/app/views/admin_data/main/association/_has_one_info.html.erb +0 -6
  88. data/lib/admin_data/chelper.rb +0 -37
  89. data/lib/admin_data/helpers.rb +0 -271
  90. data/lib/admin_data/settings.rb +0 -67
  91. data/lib/css/base.css +0 -1108
  92. data/lib/css/vendor/jquery-ui-1.7.2.custom.css +0 -406
  93. data/lib/js/advance_search/act_on_result.js +0 -45
  94. data/lib/js/advance_search/advance_search.js +0 -83
  95. data/lib/js/advance_search/advance_search_structure.js +0 -79
  96. data/lib/js/advance_search/ajaxify_advance_search.js +0 -28
  97. data/lib/js/advance_search/build_first_row.js +0 -8
  98. data/lib/js/advance_search/event_bindings.js +0 -76
  99. data/lib/js/advance_search/global_ajax_setting.js +0 -10
  100. data/lib/js/advance_search/trigger_submit_on_domready.js +0 -6
  101. data/lib/js/misc/drop_down_change.js +0 -8
  102. data/lib/js/misc/js_util.js +0 -58
  103. data/lib/js/misc/quick_search_input_focus.js +0 -6
  104. data/lib/js/test/act_on_result.js +0 -120
  105. data/lib/js/test/advance_search.js +0 -80
  106. data/lib/js/test/ajaxify_advance_search.js +0 -29
  107. data/lib/js/test/build_first_row.js +0 -10
  108. data/lib/js/test/event_bindings.js +0 -100
  109. data/lib/js/vendor/jack.js +0 -903
  110. data/lib/js/vendor/jquery-1.4.2.js +0 -6240
  111. data/lib/js/vendor/jquery-ui-1.7.2.custom.min.js +0 -298
  112. data/lib/js/vendor/jquery.ba-isjquery.js +0 -21
  113. data/lib/js/vendor/jquery.form.js +0 -814
  114. data/lib/js/vendor/log.js +0 -9
  115. data/lib/js/vendor/qunit.js +0 -1043
  116. data/lib/js/vendor/rails.js +0 -132
@@ -0,0 +1,3 @@
1
+ Given /^I am logged in through http basic authentication$/ do
2
+ basic_auth('admin_data', 'welcome')
3
+ end
@@ -0,0 +1,65 @@
1
+ Given /^user config has defined additional_column phone_numbers$/ do
2
+ AdminData.config.columns_order = AdminData.config.columns_order.merge('User' => [:id, :phone_numbers])
3
+ AdminData.config.column_settings = AdminData.config.column_settings.merge('User' => { :phone_numbers => lambda {|model| model.phone_numbers.map {|r| r.number}.join(', ') } })
4
+ end
5
+
6
+ Then /^table should have additional column phone_numbers with valid data$/ do
7
+ AdminData.config.columns_order = AdminData.config.columns_order.merge('User' => nil)
8
+ AdminData.config.column_settings = AdminData.config.column_settings.merge('User' => nil)
9
+
10
+ data = tableish('table.table tr', 'th,td')
11
+ data[0][0].should == "id"
12
+ data[0][1].should == "phone_numbers"
13
+ data[0][2].should == "first_name"
14
+ data[0][3].should == "last_name"
15
+ user = User.find(data[1][0].to_i)
16
+ assert_equal user.phone_numbers.map(&:number).join(', '),data[1][1]
17
+ end
18
+
19
+
20
+ Then /^I should see population_5000$/ do
21
+ assert page.has_content?("[:population, 5000]")
22
+ end
23
+
24
+ Then /^(.*)verify that user "(.*)" is "(.*)"$/ do |async, attribute, input|
25
+ wait_until { page.evaluate_script("jQuery.active === 0") } unless async.blank?
26
+
27
+ page.has_xpath?("//table[@id='view_table']")
28
+ table = page.find(:xpath, "//table[@id='view_table']")
29
+
30
+ counter = attribute == 'first_name' ? 2 : 3
31
+ regex = Regexp.new(input)
32
+
33
+ if async.blank?
34
+ table.find(:xpath, "./tbody/tr/td[#{counter}]", :text => regex )
35
+ else
36
+ table.find(:xpath, "./tbody/tr/td[#{counter}]", :text => regex )
37
+ end
38
+ end
39
+
40
+ Then /^I should see following tabular attributes:$/ do |expected_cukes_table|
41
+ expected_cukes_table.diff!(tableish('table.table tr', 'td,th'))
42
+ end
43
+
44
+ Then /^first id of table should be of "(.*)"$/ do |first_name|
45
+ page.should have_css("#view_table tr td a", :text => User.find_by_first_name(first_name).id.to_s)
46
+ end
47
+
48
+ Then /^I should see tabular attributes for website with custom columns order$/ do
49
+ data = tableish('table.table tr', 'td,th').flatten
50
+ data[0].should == "id"
51
+ data[1].should == "dns_provider"
52
+ data[2].should == "user_id"
53
+ data[3].should == "url"
54
+ data[4].should == "created_at"
55
+ data[5].should == "updated_at"
56
+ end
57
+
58
+ Then /^I should see tabular attributes for city with custom column headers$/ do
59
+ data = tableish('table.table tr', 'td,th').flatten
60
+ data[0].should == "ID"
61
+ data[1].should == "City Name"
62
+ data[2].should == "City Info"
63
+ data[3].should == "created_at"
64
+ data[4].should == "updated_at"
65
+ end
@@ -0,0 +1,86 @@
1
+ Then /^page should have text field css "(.*)" with user_id value$/ do |css_selector|
2
+ elem = page.find(css_selector)
3
+ elem.value.should == PhoneNumber.last.user.id.to_s
4
+ end
5
+
6
+
7
+ Then /^page should have id "remove_row_3"$/ do
8
+ page.has_css?("remove_row_3")
9
+ end
10
+
11
+ Then /^I should see only two rows in the (.*) result table$/ do |search_type|
12
+ case search_type
13
+ when 'quick search'
14
+ table_id = 'view_table'
15
+ when 'advance search'
16
+ table_id = 'advance_search_table'
17
+ end
18
+ table = page.find(:xpath, "//table[@id='#{table_id}']")
19
+ table.find(:xpath, "./tbody/tr", :count => 2 )
20
+ end
21
+
22
+ Then /^async I should see "(.*)"$/ do |msg|
23
+ page.should have_content(msg)
24
+ end
25
+
26
+ Then /^page should have css "(.*)"$/ do |css_selector|
27
+ page.should have_css(css_selector)
28
+ end
29
+
30
+ Then /^page should have disabled css "(.*)"$/ do |css_selector|
31
+ elem = page.find(css_selector)
32
+ elem['disabled'].should == 'true'
33
+ end
34
+
35
+ def handy_has_links(table)
36
+ table.hashes.each do |h|
37
+ css_selector = h[:within]
38
+ selector = css_selector[1..-1]
39
+ page.should have_xpath( "//div[@id='#{selector}']//a[@href='#{h[:url]}']", :text => h[:text] )
40
+ end
41
+ end
42
+
43
+ Then /^page should have following links?:$/ do |table|
44
+ handy_has_links(table)
45
+ end
46
+
47
+
48
+ # Usage :
49
+ #
50
+ # position: if the option is the very first option in the dropdown list then position should be 1.
51
+ # css_selector: only class and id are supported at this time.
52
+ # value_match_type: If specified as "regex" then Regular expression will be used to detect the match.
53
+ #
54
+ # Then I should see dropdown with css_selector ".drop_down_value_klass" with following options:
55
+ # | text | value | position | value_match_type |
56
+ # | phone_number | /admin_data/quick_search/phone_number | 2 | regex |
57
+ # | user | /admin_data/quick_search/user | 3 | regex |
58
+ # | website | /admin_data/quick_search/website | 4 | regex |
59
+ #
60
+ def handy_has_select?(css_selector, select_options)
61
+ selector = css_selector[1..-1]
62
+ case css_selector[0,1]
63
+ when '.'
64
+ attribute = "@class='#{selector}'"
65
+ when '#'
66
+ attribute = "@id='#{selector}'"
67
+ else
68
+ raise 'only css_selector class or id is currently supported'
69
+ end
70
+
71
+ page.should have_xpath("//select[#{attribute}]")
72
+ selects = page.find(:xpath, "//select[#{attribute}]")
73
+
74
+ select_options.each do |h|
75
+ selects.find(:xpath, "./option[#{h[:position]}]", :text => h[:text])
76
+ if h[:value_match_type] == 'regex'
77
+ selects.find(:xpath, "./option[#{h[:position]}]").value.should match Regexp.new(h[:value])
78
+ else
79
+ selects.find(:xpath, "./option[#{h[:position]}]", :text => h[:value])
80
+ end
81
+ end
82
+ end
83
+
84
+ Then /^I should see dropdown with css_selector "(.*)" with following options:$/ do |css_selector, table|
85
+ handy_has_select?(css_selector, table.hashes)
86
+ end
@@ -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
@@ -0,0 +1,68 @@
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
+ ENV["RAILS_ENV"] ||= "test"
8
+ require File.expand_path(File.dirname(__FILE__) + '/../../config/environment')
9
+
10
+ require 'cucumber/formatter/unicode' # Remove this line if you don't want Cucumber Unicode support
11
+ require 'cucumber/rails/world'
12
+ require 'cucumber/rails/active_record'
13
+ require 'cucumber/web/tableish'
14
+
15
+ require 'capybara/rails'
16
+ require 'capybara/cucumber'
17
+ require 'capybara/session'
18
+ #require 'cucumber/rails/capybara_javascript_emulation' # Lets you click links with onclick javascript handlers without using @culerity or @javascript
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
+ # If you set this to false, any error raised from within your app will bubble
26
+ # up to your step definition and out to cucumber unless you catch it somewhere
27
+ # on the way. You can make Rails rescue errors and render error pages on a
28
+ # per-scenario basis by tagging a scenario or feature with the @allow-rescue tag.
29
+ #
30
+ # If you set this to true, Rails will rescue all errors and render error
31
+ # pages, more or less in the same way your application would behave in the
32
+ # default production environment. It's not recommended to do this for all
33
+ # of your scenarios, as this makes it hard to discover errors in your application.
34
+ ActionController::Base.allow_rescue = false
35
+
36
+ # If you set this to true, each scenario will run in a database transaction.
37
+ # You can still turn off transactions on a per-scenario basis, simply tagging
38
+ # a feature or scenario with the @no-txn tag. If you are using Capybara,
39
+ # tagging with @culerity or @javascript will also turn transactions off.
40
+ #
41
+ # If you set this to false, transactions will be off for all scenarios,
42
+ # regardless of whether you use @no-txn or not.
43
+ #
44
+ # Beware that turning transactions off will leave data in your database
45
+ # after each scenario, which can lead to hard-to-debug failures in
46
+ # subsequent scenarios. If you do this, we recommend you create a Before
47
+ # block that will explicitly put your database in a known state.
48
+ Cucumber::Rails::World.use_transactional_fixtures = true
49
+ # How to clean your database when transactions are turned off. See
50
+ # http://github.com/bmabey/database_cleaner for more info.
51
+ if defined?(ActiveRecord::Base)
52
+ begin
53
+ require 'database_cleaner'
54
+ DatabaseCleaner.strategy = :truncation
55
+ rescue LoadError => ignore_if_database_cleaner_not_present
56
+ end
57
+ end
58
+
59
+
60
+
61
+ require 'factory_girl'
62
+ require Rails.root.join('test', 'factories')
63
+ Dir[Rails.root.join('test', 'factories', '*.rb')].each {|f| require f}
64
+ require 'factory_girl/step_definitions'
65
+ require 'shoulda'
66
+
67
+ #Capybara.save_and_open_page_path = 'tmp'
68
+ #Capybara.default_wait_time = 40
@@ -0,0 +1,33 @@
1
+ module NavigationHelpers
2
+ # Maps a name to a path. Used by the
3
+ #
4
+ # When /^I go to (.+)$/ do |page_name|
5
+ #
6
+ # step definition in web_steps.rb
7
+ #
8
+ def path_to(page_name)
9
+ case page_name
10
+
11
+ when /the home\s?page/
12
+ '/'
13
+
14
+ # Add more mappings here.
15
+ # Here is an example that pulls values out of the Regexp:
16
+ #
17
+ # when /^(.*)'s profile page$/i
18
+ # user_profile_path(User.find_by_login($1))
19
+
20
+ else
21
+ begin
22
+ page_name =~ /the (.*) page/
23
+ path_components = $1.split(/\s+/)
24
+ self.send(path_components.push('path').join('_').to_sym)
25
+ rescue Object => e
26
+ raise "Can't find mapping from \"#{page_name}\" to a path.\n" +
27
+ "Now, go and add a mapping in #{__FILE__}"
28
+ end
29
+ end
30
+ end
31
+ end
32
+
33
+ World(NavigationHelpers)