the_jobbook_admin_data 1.3.0a

Sign up to get free protection for your applications and to get access to all the features.
Files changed (174) hide show
  1. data/.gitignore +19 -0
  2. data/CHANGELOG.rdoc +284 -0
  3. data/Gemfile +22 -0
  4. data/Gemfile.lock +121 -0
  5. data/Guardfile +14 -0
  6. data/MIT-LICENSE +20 -0
  7. data/README.md +37 -0
  8. data/README.rdoc +3 -0
  9. data/Rakefile +40 -0
  10. data/admin_data.gemspec +23 -0
  11. data/app/assets/images/add.png +0 -0
  12. data/app/assets/images/admin_data/.gitkeep +0 -0
  13. data/app/assets/images/no.png +0 -0
  14. data/app/assets/images/site.png +0 -0
  15. data/app/assets/images/sort_by_asc.jpg +0 -0
  16. data/app/assets/images/sort_by_desc.jpg +0 -0
  17. data/app/assets/images/sort_by_nothing.jpg +0 -0
  18. data/app/assets/javascripts/admin_data.js +18 -0
  19. data/app/assets/javascripts/admin_data/application.js +15 -0
  20. data/app/assets/javascripts/advance_search/act_on_result.js +45 -0
  21. data/app/assets/javascripts/advance_search/advance_search.js +83 -0
  22. data/app/assets/javascripts/advance_search/advance_search_structure.js +79 -0
  23. data/app/assets/javascripts/advance_search/ajaxify_advance_search.js +28 -0
  24. data/app/assets/javascripts/advance_search/build_first_row.js +8 -0
  25. data/app/assets/javascripts/advance_search/event_bindings.js +76 -0
  26. data/app/assets/javascripts/advance_search/global_ajax_setting.js +10 -0
  27. data/app/assets/javascripts/advance_search/sortby.js +14 -0
  28. data/app/assets/javascripts/advance_search/trigger_submit_on_domready.js +6 -0
  29. data/app/assets/javascripts/analytics/report.js +7 -0
  30. data/app/assets/javascripts/misc/drop_down_change.js +8 -0
  31. data/app/assets/javascripts/misc/js_util.js +58 -0
  32. data/app/assets/javascripts/misc/quick_search_input_focus.js +6 -0
  33. data/app/assets/javascripts/vendor/jquery-1.4.2.js +6240 -0
  34. data/app/assets/javascripts/vendor/jquery-ui-1.7.2.custom.min.js +298 -0
  35. data/app/assets/javascripts/vendor/jquery.ba-isjquery.js +21 -0
  36. data/app/assets/javascripts/vendor/jquery_form.js +814 -0
  37. data/app/assets/javascripts/vendor/log.js +9 -0
  38. data/app/assets/javascripts/vendor/rails.js +132 -0
  39. data/app/assets/stylesheets/admin_data.css +1141 -0
  40. data/app/assets/stylesheets/admin_data/application.css +13 -0
  41. data/app/assets/stylesheets/vendor/jquery-ui-1.7.2.custom.css +406 -0
  42. data/app/controllers/admin_data/application_controller.rb +107 -0
  43. data/app/controllers/admin_data/crud_controller.rb +100 -0
  44. data/app/controllers/admin_data/feed_controller.rb +48 -0
  45. data/app/controllers/admin_data/home_controller.rb +8 -0
  46. data/app/controllers/admin_data/migration_controller.rb +18 -0
  47. data/app/controllers/admin_data/public_controller.rb +28 -0
  48. data/app/controllers/admin_data/search_controller.rb +143 -0
  49. data/app/controllers/admin_data/table_structure_controller.rb +25 -0
  50. data/app/helpers/admin_data/application_helper.rb +320 -0
  51. data/app/views/admin_data/crud/association/_association_info.html.erb +11 -0
  52. data/app/views/admin_data/crud/association/_belongs_to_info.html.erb +7 -0
  53. data/app/views/admin_data/crud/association/_habtm_info.html.erb +7 -0
  54. data/app/views/admin_data/crud/association/_has_many_info.html.erb +7 -0
  55. data/app/views/admin_data/crud/association/_has_one_info.html.erb +6 -0
  56. data/app/views/admin_data/crud/edit.html.erb +36 -0
  57. data/app/views/admin_data/crud/misc/_form.html.erb +38 -0
  58. data/app/views/admin_data/crud/misc/_modify_record.html.erb +18 -0
  59. data/app/views/admin_data/crud/new.html.erb +25 -0
  60. data/app/views/admin_data/crud/show.html.erb +42 -0
  61. data/app/views/admin_data/feed/index.rss.builder +25 -0
  62. data/app/views/admin_data/home/index.html.erb +21 -0
  63. data/app/views/admin_data/migration/index.html.erb +18 -0
  64. data/app/views/admin_data/migration/jstest.html.erb +51 -0
  65. data/app/views/admin_data/search/advance_search.html.erb +1 -0
  66. data/app/views/admin_data/search/quick_search.html.erb +1 -0
  67. data/app/views/admin_data/search/search/_advance_search_form.html.erb +52 -0
  68. data/app/views/admin_data/search/search/_errors.html.erb +5 -0
  69. data/app/views/admin_data/search/search/_listing.html.erb +43 -0
  70. data/app/views/admin_data/search/search/_search_form.html.erb +27 -0
  71. data/app/views/admin_data/search/search/_title.html.erb +34 -0
  72. data/app/views/admin_data/shared/_breadcrum.html.erb +16 -0
  73. data/app/views/admin_data/shared/_drop_down_klasses.html.erb +4 -0
  74. data/app/views/admin_data/shared/_flash_message.html.erb +13 -0
  75. data/app/views/admin_data/shared/_header.html.erb +20 -0
  76. data/app/views/admin_data/shared/_powered_by.html.erb +6 -0
  77. data/app/views/admin_data/shared/_secondary_navigation.html.erb +26 -0
  78. data/app/views/admin_data/table_structure/index.html.erb +54 -0
  79. data/app/views/layouts/admin_data.html.erb +34 -0
  80. data/app/views/layouts/admin_data/application.html.erb +14 -0
  81. data/app/views/layouts/search.html.erb +71 -0
  82. data/config/routes.rb +32 -0
  83. data/lib/admin_data.rb +27 -0
  84. data/lib/admin_data/active_record_util.rb +102 -0
  85. data/lib/admin_data/analytics.rb +176 -0
  86. data/lib/admin_data/authenticator.rb +15 -0
  87. data/lib/admin_data/config.rb +38 -0
  88. data/lib/admin_data/configuration.rb +127 -0
  89. data/lib/admin_data/date_util.rb +58 -0
  90. data/lib/admin_data/engine.rb +17 -0
  91. data/lib/admin_data/model_finder.rb +15 -0
  92. data/lib/admin_data/rails_version_check.rb +8 -0
  93. data/lib/admin_data/search.rb +188 -0
  94. data/lib/admin_data/setup_config.rb +24 -0
  95. data/lib/admin_data/util.rb +102 -0
  96. data/lib/admin_data/version.rb +3 -0
  97. data/lib/tasks/admin_data_tasks.rake +4 -0
  98. data/script/rails +8 -0
  99. data/test/admin_data_test.rb +7 -0
  100. data/test/dummy/README.md +19 -0
  101. data/test/dummy/Rakefile +7 -0
  102. data/test/dummy/app/controllers/application_controller.rb +3 -0
  103. data/test/dummy/app/helpers/application_helper.rb +5 -0
  104. data/test/dummy/app/models/user.rb +3 -0
  105. data/test/dummy/app/models/user/student.rb +2 -0
  106. data/test/dummy/app/views/layouts/application.html.erb +14 -0
  107. data/test/dummy/config.ru +4 -0
  108. data/test/dummy/config/application.rb +15 -0
  109. data/test/dummy/config/boot.rb +13 -0
  110. data/test/dummy/config/cucumber.yml +9 -0
  111. data/test/dummy/config/database.yml +25 -0
  112. data/test/dummy/config/database.yml.mysql +22 -0
  113. data/test/dummy/config/database.yml.pg +15 -0
  114. data/test/dummy/config/database.yml.sqlite3 +25 -0
  115. data/test/dummy/config/environment.rb +5 -0
  116. data/test/dummy/config/environments/development.rb +22 -0
  117. data/test/dummy/config/environments/production.rb +49 -0
  118. data/test/dummy/config/environments/test.rb +35 -0
  119. data/test/dummy/config/initializers/admin_data.rb +15 -0
  120. data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
  121. data/test/dummy/config/initializers/empty_spaces_to_nil.rb +10 -0
  122. data/test/dummy/config/initializers/inflections.rb +10 -0
  123. data/test/dummy/config/initializers/mime_types.rb +5 -0
  124. data/test/dummy/config/initializers/secret_token.rb +7 -0
  125. data/test/dummy/config/initializers/session_store.rb +8 -0
  126. data/test/dummy/config/locales/en.yml +5 -0
  127. data/test/dummy/config/routes.rb +9 -0
  128. data/test/dummy/db/development.sqlite3 +0 -0
  129. data/test/dummy/db/migrate/20091030202259_create_tables.rb +72 -0
  130. data/test/dummy/db/production.sqlite3 +1 -0
  131. data/test/dummy/db/schema.rb +23 -0
  132. data/test/dummy/db/seeds.rb +40 -0
  133. data/test/dummy/db/test.sqlite3 +0 -0
  134. data/test/dummy/features/advance_search/boolean.feature +74 -0
  135. data/test/dummy/features/advance_search/datetime.feature +101 -0
  136. data/test/dummy/features/advance_search/delete_all.feature +20 -0
  137. data/test/dummy/features/advance_search/destroy_all.feature +20 -0
  138. data/test/dummy/features/advance_search/integer.feature +69 -0
  139. data/test/dummy/features/advance_search/multiple_rows.feature +87 -0
  140. data/test/dummy/features/advance_search/string.feature +130 -0
  141. data/test/dummy/features/crud.feature +50 -0
  142. data/test/dummy/features/crud_show.feature +56 -0
  143. data/test/dummy/features/feed.feature +13 -0
  144. data/test/dummy/features/home.feature +42 -0
  145. data/test/dummy/features/migration.feature +7 -0
  146. data/test/dummy/features/quick_search.feature +113 -0
  147. data/test/dummy/features/step_definitions/advance_search_steps.rb +13 -0
  148. data/test/dummy/features/step_definitions/app_steps.rb +36 -0
  149. data/test/dummy/features/step_definitions/async.rb +18 -0
  150. data/test/dummy/features/step_definitions/configuration_steps.rb +61 -0
  151. data/test/dummy/features/step_definitions/crud_show_steps.rb +37 -0
  152. data/test/dummy/features/step_definitions/feed_steps.rb +24 -0
  153. data/test/dummy/features/step_definitions/quick_search_steps.rb +68 -0
  154. data/test/dummy/features/step_definitions/util.rb +90 -0
  155. data/test/dummy/features/step_definitions/web_steps.rb +219 -0
  156. data/test/dummy/features/support/env.rb +66 -0
  157. data/test/dummy/features/support/hooks.rb +9 -0
  158. data/test/dummy/features/support/paths.rb +33 -0
  159. data/test/dummy/features/table_structure.feature +18 -0
  160. data/test/dummy/lib/tasks/.gitkeep +0 -0
  161. data/test/dummy/lib/tasks/cucumber.rake +53 -0
  162. data/test/dummy/lib/tasks/dbs.rake +30 -0
  163. data/test/dummy/lib/tasks/sample_cars.rake +18 -0
  164. data/test/dummy/public/.gitkeep +0 -0
  165. data/test/dummy/script/cucumber +10 -0
  166. data/test/dummy/script/rails +6 -0
  167. data/test/dummy/test/factories.rb +30 -0
  168. data/test/dummy/test/test_helper.rb +7 -0
  169. data/test/integration/navigation_test.rb +10 -0
  170. data/test/test_helper.rb +15 -0
  171. data/test/unit/admin_data/model_finder_test.rb +16 -0
  172. data/test/unit/car_test.rb +96 -0
  173. data/test/unit/user_phone_test.rb +19 -0
  174. metadata +253 -0
@@ -0,0 +1,50 @@
1
+ Feature: CRUD
2
+
3
+ Scenario: edit
4
+ Given a user exists
5
+ Given I visit user show page
6
+ Given I follow "Edit"
7
+ When I fill in the following:
8
+ | user_first_name ||
9
+ | user_age ||
10
+ When I press "Update"
11
+ Then I should see "First name can't be blank"
12
+ Then I should see "Age can't be blank"
13
+ Then I should see "Age is not a number"
14
+ Then I should find value "(auto)" for "created_at"
15
+ Then I should find value "(auto)" for "updated_at"
16
+ When I fill in the following:
17
+ | user_first_name | Robert2 |
18
+ | user_age | 99 |
19
+ When I press "Update"
20
+ Then I should see "Robert2"
21
+ Then I should see "99"
22
+ Then I should see "Record was updated"
23
+
24
+ Scenario: edit PhoneNumber (no association drop-down)
25
+ Given configuration to hide the association drop down for PhoneNumber
26
+ Given a phone number exists
27
+ Given I visit phone_number show page
28
+ Given I follow "Edit"
29
+ Then page should have "input" field with selector "#phone_number_user_id"
30
+
31
+ Scenario: edit PhoneNumber (with association drop-down)
32
+ Given configuration to show the association drop down for PhoneNumber
33
+ Given a phone number exists
34
+ Given I visit phone_number show page
35
+ Given I follow "Edit"
36
+ Then page should have "select" field with selector "#phone_number_user_id"
37
+
38
+ Scenario: add a new record
39
+ Given a user exists
40
+ Given I visit quick_search page
41
+ Given I follow "+Add New Record"
42
+ Given I press "Create"
43
+ Then I should see "First name can't be blank"
44
+ Then I should see "Age can't be blank"
45
+ Then I should see "Age is not a number"
46
+ When I fill in the following:
47
+ | user_first_name | Johny |
48
+ | user_age | 21 |
49
+ When I press "Create"
50
+ Then I should see "Record was created"
@@ -0,0 +1,56 @@
1
+ Feature: CRUD show
2
+
3
+ Background:
4
+ When configured to display only 2 records per page
5
+ When configured to display City column :name as "City Name"
6
+
7
+ Scenario: show
8
+ Given a user exists
9
+ Given I visit user show page
10
+ Then I should notice id of the last person
11
+ Then I should see "Edit"
12
+ Then I should see "Delete"
13
+ Then I should see "Destroy"
14
+ Then I should see crud show tabular attributes
15
+
16
+ Scenario: show for Newspaper which has primary key as paper_id
17
+ Given a newspaper exists
18
+ Given I visit newspaper show page
19
+ Then I should see "Edit"
20
+
21
+ Scenario: show with has_one association info
22
+ Given the following user exists:
23
+ | first name | last name |
24
+ | Mary | Jane |
25
+ Given the following website exists:
26
+ | url | user |
27
+ | www.google.com | first name:Mary |
28
+ Given I visit user show page
29
+ Then I should see "website"
30
+ When I follow "website"
31
+ Then I should notice id of website of the last person
32
+ When I follow "user"
33
+ Then I should notice id of the last person
34
+
35
+ Scenario: show with has_many association info
36
+ Given the following user exists:
37
+ | first name | last name |
38
+ | Mary | Jane |
39
+ Given the following phone number exists:
40
+ | number | user |
41
+ | 123-456-7890 | first name:Mary |
42
+ | 123-456-7899 | first name:Mary |
43
+ Given I visit user show page
44
+ Then I should see "phone_numbers(2)"
45
+ When I follow "phone_numbers(2)"
46
+ Then I should see "has 2 phone_numbers"
47
+
48
+ Scenario: show with habtm association info
49
+ Given the following user exists:
50
+ | first name | last name |
51
+ | Mary | Jane |
52
+ Given user owns two clubs "sun-shine" and "rise-n-shine"
53
+ Given I visit user show page
54
+ Then I should see "clubs(2)"
55
+ When I follow "clubs(2)"
56
+ Then I should see "has 2 clubs"
@@ -0,0 +1,13 @@
1
+ Feature: RSS feed availabilty for all the models
2
+
3
+ Scenario: RSS feed availability with invalid authentication
4
+ Given a user exists
5
+ When mocked feed authentication returns false
6
+ Given I visit user feed page
7
+ Then I should see "not authorized"
8
+
9
+ Scenario: RSS feed availability with valid authentication
10
+ Given a user exists
11
+ When mocked feed authentication returns true
12
+ Given I visit user feed page
13
+ Then I should see "Feeds from admin_data User"
@@ -0,0 +1,42 @@
1
+ Feature: homepage
2
+
3
+ @javascript
4
+ Scenario: admin_data homepage
5
+ Given the following user exists:
6
+ | first_name | last_name |
7
+ | Mary | Jane |
8
+ | John | Smith |
9
+ | Neil | Singh |
10
+ | Trisha | Singh |
11
+ Given I visit admin_data page
12
+ Then I should see "Select from the drop down menu above"
13
+ When I follow "admin_data" within "#subnav"
14
+ Then I should see "Select from the drop down menu above"
15
+ Then show me the page
16
+ Then I should see dropdown with css_selector ".drop_down_value_klass" with following options:
17
+ | text | value | position | value_match_type |
18
+ | city | /admin_data/quick_search/city | 3 | regex |
19
+ | club | /admin_data/quick_search/club | 4 | regex |
20
+ | newspaper | /admin_data/quick_search/newspaper | 5 | regex |
21
+ | phone_number | /admin_data/quick_search/phone_number | 6 | regex |
22
+ | user | /admin_data/quick_search/user | 7 | regex |
23
+ | website | /admin_data/quick_search/website | 8 | regex |
24
+
25
+ Then I should see dropdown with css_selector "#drop_down_klasses" with following options:
26
+ | text | value | position | value_match_type |
27
+ | city | /admin_data/quick_search/city | 3 | regex |
28
+ | club | /admin_data/quick_search/club | 4 | regex |
29
+ | newspaper | /admin_data/quick_search/newspaper | 5 | regex |
30
+ | phone_number | /admin_data/quick_search/phone_number | 6 | regex |
31
+ | user | /admin_data/quick_search/user | 7 | regex |
32
+ | website | /admin_data/quick_search/website | 8 | regex |
33
+ When I select "user" from "drop_down_klasses"
34
+ Then first id of table should be of "Trisha"
35
+
36
+ Scenario: footer links
37
+ Given I visit admin_data page
38
+ Then page should have following links:
39
+ | url | text | within |
40
+ | http://github.com/neerajdotname/admin_data | admin_data | #footer |
41
+ | http://github.com/neerajdotname/admin_data/issues | Report Bug | #footer |
42
+ | http://github.com/neerajdotname/admin_data/wiki | Documentation | #footer |
@@ -0,0 +1,7 @@
1
+ Feature: Migration
2
+
3
+ @javascript
4
+ Scenario: migration information
5
+ Given I visit admin_data page
6
+ When I select "Migration Information" from "drop_down_klasses"
7
+ Then I should see "20091030202259"
@@ -0,0 +1,113 @@
1
+ Feature: quick search
2
+
3
+ Background:
4
+ When configured to display only 2 records per page
5
+ When configured to rename City columns:
6
+ | column | alias |
7
+ | :id | ID |
8
+ | :name | City Name |
9
+ | :data | City Info |
10
+
11
+ Scenario: quick search with no search term
12
+ Given the following user exists:
13
+ | first_name | last_name |
14
+ | Mary | Jane |
15
+ | John | Smith |
16
+ | Neil | Singh |
17
+ | Trisha | Singh |
18
+ Given I visit quick_search page
19
+ Then first id of table should be of "Trisha"
20
+ Then I should see "Next →"
21
+ Then I follow "Next →"
22
+ Then verify that user "first_name" is "John"
23
+ Then verify that user "last_name" is "Smith"
24
+
25
+ @javascript
26
+ Scenario: quick search with no search term for Newspaper which has paper_id as primary key
27
+ Given a newspaper exists
28
+ Given I visit admin_data page
29
+ When I select "newspaper" from "drop_down_klasses"
30
+ Then I should see "Listing Newspaper"
31
+
32
+ @javascript
33
+ Scenario: quick search with no search term for City which has to_model declared
34
+ Given a city exists
35
+ Given I visit admin_data page
36
+ When I select "city" from "drop_down_klasses"
37
+ Then I should see "Listing City"
38
+ When I follow "seattle"
39
+ Then I should see "seattle"
40
+ Then I should see population_5000
41
+
42
+ Scenario: quick search with search term
43
+ Given the following user exists:
44
+ | first_name | last_name |
45
+ | Mary | Jane |
46
+ | John | Smith |
47
+ Given I visit quick_search page
48
+ When I fill in "quick_search_input" with "John"
49
+ When I press "Search"
50
+ Then I should see "Search result: 1 record found"
51
+ Then verify that user "first_name" is "John"
52
+ Then verify that user "last_name" is "Smith"
53
+
54
+ Scenario: quick search with search term with association info
55
+ Given the following user exists:
56
+ | first name | last name |
57
+ | Mary | Jane |
58
+ Given the following phone number exists:
59
+ | number | user |
60
+ | 123-456-7890 | first name:Mary |
61
+ | 123-456-7777 | first name:Mary |
62
+ When I visit quick search page with association info page
63
+ Then I should see "has 2 phone_numbers"
64
+ Then I should see "2" rows in table "view_table"
65
+
66
+ Scenario: quick search with wrong klass name
67
+ When I visit quick search with wrong klass name page
68
+ Then I should see "wrong params[:klass] was supplied"
69
+
70
+ Scenario: quick search with wrong base klass name
71
+ Given the following user exists:
72
+ | first name | last name |
73
+ | Mary | Jane |
74
+ When I visit quick search with wrong base klass name page
75
+ Then I should see "user_wrong is an invalid value"
76
+
77
+ Scenario: quick search with wrong children klass name
78
+ Given the following user exists:
79
+ | first name | last name |
80
+ | Mary | Jane |
81
+ When I visit quick search with wrong children klass name page
82
+ Then I should see "phone_numbers_wrong is not a valid has_many association"
83
+
84
+ @javascript
85
+ Scenario: quick search for website with custom columns order
86
+ Given a website exists
87
+ Given I visit admin_data page
88
+ When I select "website" from "drop_down_klasses"
89
+ Then I should see tabular attributes for website with custom columns order
90
+
91
+ @javascript
92
+ Scenario: quick search for city with custom columns header
93
+ Given a city exists
94
+ Given I visit admin_data page
95
+ When I select "city" from "drop_down_klasses"
96
+ Then I should see tabular attributes for city with custom column headers
97
+
98
+ @javascript
99
+ Scenario: quick search for User with has_many info
100
+ Given the following user exists:
101
+ | first name | last name |
102
+ | Mary | Jane |
103
+ Given the following phone number exists:
104
+ | number | user |
105
+ | 123-456-7890 | first name:Mary |
106
+ | 123-456-7899 | first name:Mary |
107
+ Given user config has defined additional_column phone_numbers
108
+ Given I visit admin_data page
109
+ When I select "user" from "drop_down_klasses"
110
+ Then table should have additional column phone_numbers with valid data
111
+ Then reset columns_order and column_settings for User
112
+
113
+
@@ -0,0 +1,13 @@
1
+ Then /^async page should have text as current date for "(.*)"$/ do |css_selector|
2
+ wait_until { page.evaluate_script("jQuery.active === 0") }
3
+
4
+ page.find(css_selector).value.should == Time.now.strftime('%d-%B-%Y')
5
+ end
6
+
7
+ Given /^first user's value for active is nil$/ do
8
+ User.update_all('active = NULL', "id = #{User.first.id}")
9
+ end
10
+
11
+ Given /^last user's value for active is nil$/ do
12
+ User.update_all('active = NULL', "id = #{User.last.id}")
13
+ end
@@ -0,0 +1,36 @@
1
+ When /^I visit (.*) page$/ do |target_page|
2
+ case target_page
3
+ when 'admin_data'
4
+ visit '/admin_data'
5
+
6
+ when 'quick_search'
7
+ visit '/admin_data/quick_search/user'
8
+
9
+ when 'advance_search'
10
+ visit '/admin_data/advance_search/user'
11
+
12
+ when 'user show'
13
+ visit "/admin_data/klass/user/#{User.last.id}"
14
+
15
+ when 'phone_number show'
16
+ visit "/admin_data/klass/phone_number/#{PhoneNumber.last.id}"
17
+
18
+ when 'newspaper show'
19
+ visit "/admin_data/klass/newspaper/#{Newspaper.last.paper_id}"
20
+
21
+ when 'user feed'
22
+ visit "/admin_data/feed/user"
23
+
24
+ when 'quick search page with association info'
25
+ visit "/admin_data/quick_search/phone_number?base=user&children=phone_numbers&model_id=#{User.last.id}"
26
+
27
+ when 'quick search with wrong klass name'
28
+ visit "/admin_data/quick_search/phone_number_wrong"
29
+
30
+ when 'quick search with wrong base klass name'
31
+ visit "/admin_data/quick_search/phone_number?base=user_wrong&children=phone_numbers&model_id=#{User.last.id}"
32
+
33
+ when 'quick search with wrong children klass name'
34
+ visit "/admin_data/quick_search/phone_number?base=user&children=phone_numbers_wrong&model_id=#{User.last.id}"
35
+ end
36
+ end
@@ -0,0 +1,18 @@
1
+ Then /^async verify that number of "(.*)" records is "(.*)"$/ do |klass, count|
2
+ wait_until { page.evaluate_script("jQuery.active === 0") }
3
+ klass.constantize.count.should == count.to_i
4
+ end
5
+
6
+ Then /^async click "(.*)"$/ do |text|
7
+ wait_until { page.evaluate_script("jQuery.active === 0") }
8
+
9
+ page.evaluate_script('window.confirm = function() { return true; }')
10
+ page.click_link_or_button(text)
11
+ end
12
+
13
+ Then /^asyc I should see "(.*)"$/ do |text|
14
+ wait_until { page.evaluate_script("jQuery.active === 0") }
15
+
16
+ page.should have_content(text)
17
+ end
18
+
@@ -0,0 +1,61 @@
1
+ When /^configured to display only (\d*) records per page$/ do |max_recs|
2
+ AdminData.config do |config|
3
+ config.number_of_records_per_page = max_recs.to_i
4
+ end
5
+ end
6
+
7
+ def col_for( string )
8
+ string.gsub(/^\:/,'').downcase.to_sym
9
+ end
10
+
11
+ def add_to( config, param_sym, key1, key2, val)
12
+ hash = config.send( param_sym )
13
+ assign_sym = (param_sym.to_s + '=').to_sym
14
+ config.send( assign_sym, hash ||= {} )
15
+ hash[ key1 ] ||= {}
16
+ hash[ key1 ].store( key2, val )
17
+ end
18
+
19
+ # Assumes a table in the form:
20
+ # column, alias
21
+ # :city_name, City Name
22
+ When /^configured to rename (\w*) columns:$/ do |model, table|
23
+ @last_model = model
24
+ AdminData.config do |config|
25
+ table.hashes.each do |r|
26
+ add_to config, :column_headers, model, col_for(r['column']), r['alias']
27
+ end
28
+ end
29
+ end
30
+
31
+ When /^configured to display (\w*) column ([\:\w]*) as "([^"]*)"$/ do
32
+
33
+ |model, col_name, new_name|
34
+
35
+ @last_model = model
36
+ AdminData.config do |config|
37
+ add_to config, :column_headers, model, col_for(col_name), new_name
38
+ end
39
+ end
40
+
41
+ # Specify models to hide: Model1, Model2, Model3
42
+ Given /^configuration to (hide|show) the association drop down for ([\w\, ]*)$/ do |action,mods|
43
+ AdminData.config do |config|
44
+
45
+ hash = config.drop_down_for_associations
46
+ hash = {} if (hash == true || hash.nil?)
47
+
48
+ if action == "hide"
49
+ new_val = false
50
+ else
51
+ new_val = true
52
+ end
53
+
54
+ models = mods.split(', ')
55
+ models.each do |model|
56
+ hash.store( model.strip, new_val )
57
+ end
58
+
59
+ config.drop_down_for_associations = hash
60
+ end
61
+ end
@@ -0,0 +1,37 @@
1
+ Then /^I should see crud show tabular attributes$/ do
2
+ data = tableish('table.table tr', 'td,th').flatten
3
+ data[0].should == "id"
4
+ data[2].should == "first_name"
5
+ data[3].should == "Mary"
6
+ data[4].should == "last_name"
7
+ data[5].should == "Jane"
8
+ data[6].should == "age"
9
+ data[7].should == "21"
10
+ data[8].should == "data"
11
+ data[9].should == "nil"
12
+ data[10].should == "active"
13
+ data[11].should == "false"
14
+ data[12].should == "description"
15
+ data[13].should == ""
16
+ data[14].should == "born_at"
17
+ data[15].should =~ /30-August-2010/
18
+ end
19
+
20
+ Then /^I should find value "(.*)" for "(.*)"$/ do |text, column|
21
+ index = (column == 'created_at') ? 9 : 10
22
+ page.should have_xpath( "//form//div[@class='data'][#{index}]", :text => Regexp.new(text) )
23
+ end
24
+
25
+ Then /^I should notice id of the last person$/ do
26
+ page.should have_content("ID #{User.last.id}")
27
+ end
28
+
29
+ Then /^I should notice id of website of the last person$/ do
30
+ page.should have_content("ID #{User.last.website.id}")
31
+ end
32
+
33
+ Given /^user owns two clubs "sun-shine" and "rise-n-shine"$/ do
34
+ u = User.last
35
+ u.clubs.create(:name => 'sun-shine')
36
+ u.clubs.create(:name => 'rise-n-shine')
37
+ end