activeadmin 0.6.0 → 0.6.1
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of activeadmin might be problematic. Click here for more details.
- data/.gitignore +5 -1
- data/.travis.yml +1 -1
- data/.yardopts +2 -3
- data/CHANGELOG.md +180 -36
- data/CONTRIBUTING.md +12 -2
- data/Gemfile +9 -3
- data/README.rdoc +38 -65
- data/Rakefile +1 -3
- data/activeadmin.gemspec +10 -11
- data/app/assets/images/active_admin/index_list_icons/block_icon.svg +1 -1
- data/app/assets/images/active_admin/index_list_icons/blog_icon.svg +1 -1
- data/app/assets/images/active_admin/index_list_icons/grid_icon.svg +1 -1
- data/app/assets/images/active_admin/index_list_icons/table_icon.svg +1 -1
- data/app/assets/javascripts/active_admin/components/jquery.aa.checkbox-toggler.js.coffee +2 -2
- data/app/assets/javascripts/active_admin/components/jquery.aa.dropdown-menu.js.coffee +2 -2
- data/app/assets/javascripts/active_admin/components/jquery.aa.popover.js.coffee +2 -2
- data/app/assets/javascripts/active_admin/components/jquery.aa.table-checkbox-toggler.js.coffee +2 -2
- data/app/assets/javascripts/active_admin/lib/namespace.js.coffee +2 -1
- data/app/assets/javascripts/active_admin/pages/application.js.coffee +6 -1
- data/app/assets/stylesheets/active_admin/_base.css.scss +29 -34
- data/app/assets/stylesheets/active_admin/_forms.css.scss +65 -62
- data/app/assets/stylesheets/active_admin/_header.css.scss +57 -45
- data/app/assets/stylesheets/active_admin/_typography.css.scss +9 -9
- data/app/assets/stylesheets/active_admin/components/_batch_actions.css.scss +1 -1
- data/app/assets/stylesheets/active_admin/components/_blank_slates.scss +5 -5
- data/app/assets/stylesheets/active_admin/components/_breadcrumbs.scss +2 -2
- data/app/assets/stylesheets/active_admin/components/_comments.css.scss +1 -1
- data/app/assets/stylesheets/active_admin/components/_date_picker.css.scss +20 -20
- data/app/assets/stylesheets/active_admin/components/_dropdown_menu.scss +16 -16
- data/app/assets/stylesheets/active_admin/components/_flash_messages.css.scss +25 -23
- data/app/assets/stylesheets/active_admin/components/_grid.scss +2 -2
- data/app/assets/stylesheets/active_admin/components/_index_list.scss +1 -1
- data/app/assets/stylesheets/active_admin/components/_pagination.scss +10 -10
- data/app/assets/stylesheets/active_admin/components/_panels.scss +1 -1
- data/app/assets/stylesheets/active_admin/components/_popovers.css.scss +27 -27
- data/app/assets/stylesheets/active_admin/components/_scopes.scss +1 -1
- data/app/assets/stylesheets/active_admin/components/_table_tools.css.scss +10 -10
- data/app/assets/stylesheets/active_admin/components/_tables.css.scss +9 -9
- data/app/assets/stylesheets/active_admin/mixins/_buttons.css.scss +3 -3
- data/app/assets/stylesheets/active_admin/mixins/_gradients.css.scss +4 -4
- data/app/assets/stylesheets/active_admin/mixins/_icons.css.scss +4 -7
- data/app/assets/stylesheets/active_admin/mixins/_reset.css.scss +5 -5
- data/app/assets/stylesheets/active_admin/mixins/_rounded.css.scss +3 -3
- data/app/assets/stylesheets/active_admin/mixins/_sections.css.scss +6 -6
- data/app/assets/stylesheets/active_admin/mixins/_shadows.css.scss +8 -8
- data/app/assets/stylesheets/active_admin/mixins/_typography.scss +1 -1
- data/app/assets/stylesheets/active_admin/mixins/_utilities.scss +1 -1
- data/app/assets/stylesheets/active_admin/mixins/_variables.css.scss +9 -1
- data/app/assets/stylesheets/active_admin/pages/_logged_out.scss +1 -1
- data/app/assets/stylesheets/active_admin/print.css.scss +2 -8
- data/app/assets/stylesheets/active_admin/structure/_footer.scss +5 -5
- data/app/assets/stylesheets/active_admin/structure/_main_structure.scss +13 -13
- data/app/assets/stylesheets/active_admin/structure/_title_bar.scss +14 -14
- data/app/views/active_admin/devise/passwords/edit.html.erb +1 -1
- data/app/views/active_admin/devise/sessions/new.html.erb +1 -1
- data/app/views/active_admin/devise/shared/_links.erb +8 -1
- data/app/views/active_admin/resource/index.csv.erb +3 -3
- data/app/views/layouts/active_admin_logged_out.html.erb +5 -3
- data/config/locales/bg.yml +101 -0
- data/{lib/active_admin → config}/locales/ca.yml +24 -7
- data/{lib/active_admin → config}/locales/cs.yml +34 -12
- data/{lib/active_admin → config}/locales/da.yml +29 -7
- data/config/locales/de-CH.yml +117 -0
- data/{lib/active_admin → config}/locales/de.yml +19 -9
- data/config/locales/en-GB.yml +90 -0
- data/{lib/active_admin → config}/locales/en.yml +16 -6
- data/config/locales/es.yml +106 -0
- data/{lib/active_admin/locales/es.yml → config/locales/es_MX.yml} +14 -8
- data/{lib/active_admin → config}/locales/fr.yml +14 -6
- data/{lib/active_admin → config}/locales/he.yml +16 -6
- data/{lib/active_admin → config}/locales/hr.yml +14 -6
- data/{lib/active_admin → config}/locales/hu.yml +31 -6
- data/{lib/active_admin → config}/locales/it.yml +14 -6
- data/{lib/active_admin → config}/locales/ja.yml +32 -7
- data/{lib/active_admin → config}/locales/ko.yml +14 -6
- data/{lib/active_admin → config}/locales/lt.yml +15 -6
- data/{lib/active_admin → config}/locales/lv.yml +14 -6
- data/{lib/active_admin → config}/locales/nl.yml +14 -6
- data/{lib/active_admin → config}/locales/no-NB.yml +14 -6
- data/{lib/active_admin → config}/locales/pl.yml +14 -6
- data/{lib/active_admin → config}/locales/pt-BR.yml +14 -6
- data/{lib/active_admin → config}/locales/pt-PT.yml +14 -6
- data/{lib/active_admin → config}/locales/ro.yml +32 -7
- data/{lib/active_admin → config}/locales/ru.yml +30 -8
- data/{lib/active_admin → config}/locales/sv-SE.yml +14 -6
- data/{lib/active_admin → config}/locales/tr.yml +15 -6
- data/config/locales/uk.yml +100 -0
- data/{lib/active_admin → config}/locales/vi.yml +15 -6
- data/{lib/active_admin → config}/locales/zh-CN.yml +15 -6
- data/{lib/active_admin → config}/locales/zh-TW.yml +15 -6
- data/docs/0-installation.md +22 -18
- data/docs/1-general-configuration.md +1 -1
- data/docs/10-custom-pages.md +3 -3
- data/docs/11-decorators.md +18 -2
- data/docs/12-arbre-components.md +53 -54
- data/docs/13-authorization-adapter.md +31 -10
- data/docs/2-resource-customization.md +16 -1
- data/docs/3-index-pages.md +13 -1
- data/docs/3-index-pages/create-an-index.md +4 -4
- data/docs/3-index-pages/index-as-block.md +1 -1
- data/docs/3-index-pages/index-as-blog.md +1 -1
- data/docs/3-index-pages/index-as-grid.md +1 -1
- data/docs/4-csv-format.md +4 -4
- data/docs/5-forms.md +46 -3
- data/docs/{6-show-screens.md → 6-show-pages.md} +3 -3
- data/docs/8-custom-actions.md +3 -3
- data/docs/9-batch-actions.md +9 -1
- data/features/action_item.feature +6 -6
- data/features/authorization_cancan.feature +1 -1
- data/features/belongs_to.feature +3 -3
- data/features/breadcrumb.feature +2 -2
- data/features/comments/commenting.feature +7 -5
- data/features/dashboard.feature +0 -51
- data/features/favicon.feature +20 -0
- data/features/global_navigation.feature +0 -1
- data/features/index/batch_actions.feature +12 -11
- data/features/index/filters.feature +6 -6
- data/features/index/format_as_csv.feature +4 -5
- data/features/index/index_as_blog.feature +20 -1
- data/features/index/index_as_table.feature +1 -1
- data/features/index/index_blank_slate.feature +3 -3
- data/features/index/index_parameters.feature +4 -10
- data/features/index/index_scope_to.feature +24 -0
- data/features/index/index_scopes.feature +17 -5
- data/features/index/pagination.feature +15 -0
- data/features/registering_pages.feature +1 -1
- data/features/registering_resources.feature +2 -2
- data/features/show/default_content.feature +3 -3
- data/features/sidebar_sections.feature +3 -3
- data/features/specifying_actions.feature +1 -1
- data/features/step_definitions/additional_web_steps.rb +3 -16
- data/features/step_definitions/asset_steps.rb +5 -1
- data/features/step_definitions/attribute_steps.rb +4 -4
- data/features/step_definitions/batch_action_steps.rb +25 -74
- data/features/step_definitions/breadcrumb_steps.rb +1 -3
- data/features/step_definitions/comment_steps.rb +0 -1
- data/features/step_definitions/configuration_steps.rb +53 -69
- data/features/step_definitions/dashboard_steps.rb +2 -2
- data/features/step_definitions/factory_steps.rb +17 -33
- data/features/step_definitions/filter_steps.rb +2 -2
- data/features/step_definitions/format_steps.rb +10 -14
- data/features/step_definitions/index_scope_steps.rb +9 -25
- data/features/step_definitions/index_views_steps.rb +1 -1
- data/features/step_definitions/sidebar_steps.rb +2 -1
- data/features/step_definitions/site_title_steps.rb +1 -1
- data/features/step_definitions/table_steps.rb +6 -1
- data/features/step_definitions/user_steps.rb +23 -38
- data/features/step_definitions/web_steps.rb +18 -147
- data/features/support/env.rb +13 -34
- data/features/support/paths.rb +2 -0
- data/features/users/logging_in.feature +2 -2
- data/features/users/logging_out.feature +0 -12
- data/features/users/resetting_password.feature +1 -1
- data/lib/active_admin.rb +4 -17
- data/lib/active_admin/abstract_view_factory.rb +1 -1
- data/lib/active_admin/application.rb +19 -28
- data/lib/active_admin/asset_registration.rb +7 -25
- data/lib/active_admin/authorization_adapter.rb +9 -5
- data/lib/active_admin/base_controller.rb +2 -2
- data/lib/active_admin/base_controller/authorization.rb +25 -27
- data/lib/active_admin/batch_actions/resource_extension.rb +3 -3
- data/lib/active_admin/batch_actions/views/batch_action_selector.rb +1 -1
- data/lib/active_admin/batch_actions/views/selection_cells.rb +1 -1
- data/lib/active_admin/callbacks.rb +1 -1
- data/lib/active_admin/cancan_adapter.rb +2 -2
- data/lib/active_admin/comments.rb +32 -38
- data/lib/active_admin/comments/comment.rb +6 -8
- data/lib/active_admin/comments/views.rb +0 -1
- data/lib/active_admin/comments/views/active_admin_comments.rb +27 -38
- data/lib/active_admin/csv_builder.rb +4 -6
- data/lib/active_admin/dependency_checker.rb +4 -0
- data/lib/active_admin/deprecation.rb +3 -3
- data/lib/active_admin/dsl.rb +5 -5
- data/lib/active_admin/engine.rb +1 -1
- data/lib/active_admin/filters.rb +2 -1
- data/lib/active_admin/filters/forms.rb +36 -43
- data/lib/active_admin/filters/formtastic_addons.rb +45 -0
- data/lib/active_admin/filters/resource_extension.rb +9 -1
- data/lib/active_admin/form_builder.rb +30 -19
- data/lib/active_admin/helpers/optional_display.rb +11 -13
- data/lib/active_admin/helpers/settings.rb +50 -8
- data/lib/active_admin/inputs/filter_base.rb +5 -18
- data/lib/active_admin/inputs/filter_base/search_method_select.rb +73 -0
- data/lib/active_admin/inputs/filter_boolean_input.rb +6 -14
- data/lib/active_admin/inputs/filter_check_boxes_input.rb +1 -1
- data/lib/active_admin/inputs/filter_numeric_input.rb +2 -47
- data/lib/active_admin/inputs/filter_select_input.rb +32 -10
- data/lib/active_admin/inputs/filter_string_input.rb +12 -14
- data/lib/active_admin/namespace.rb +8 -40
- data/lib/active_admin/page.rb +2 -2
- data/lib/active_admin/page_dsl.rb +1 -1
- data/lib/active_admin/reloader.rb +3 -3
- data/lib/active_admin/resource.rb +16 -23
- data/lib/active_admin/resource/belongs_to.rb +8 -5
- data/lib/active_admin/resource/menu.rb +10 -23
- data/lib/active_admin/resource/naming.rb +3 -3
- data/lib/active_admin/resource/page_presenters.rb +2 -2
- data/lib/active_admin/resource/routes.rb +74 -21
- data/lib/active_admin/resource/scope_to.rb +74 -0
- data/lib/active_admin/resource/scopes.rb +8 -4
- data/lib/active_admin/resource_collection.rb +20 -66
- data/lib/active_admin/resource_controller.rb +12 -16
- data/lib/active_admin/resource_controller/data_access.rb +19 -22
- data/lib/active_admin/resource_controller/resource_class_methods.rb +2 -2
- data/lib/active_admin/resource_controller/scoping.rb +4 -9
- data/lib/active_admin/resource_dsl.rb +5 -32
- data/lib/active_admin/router.rb +34 -47
- data/lib/active_admin/scope.rb +5 -3
- data/lib/active_admin/sidebar_section.rb +1 -1
- data/lib/active_admin/version.rb +1 -1
- data/lib/active_admin/view_factory.rb +1 -1
- data/lib/active_admin/view_helpers/auto_link_helper.rb +1 -1
- data/lib/active_admin/view_helpers/breadcrumb_helper.rb +8 -8
- data/lib/active_admin/view_helpers/display_helper.rb +15 -6
- data/lib/active_admin/view_helpers/download_format_links_helper.rb +2 -2
- data/lib/active_admin/view_helpers/form_helper.rb +6 -1
- data/lib/active_admin/view_helpers/icon_helper.rb +1 -1
- data/lib/active_admin/view_helpers/method_or_proc_helper.rb +5 -5
- data/lib/active_admin/view_helpers/title_helper.rb +1 -1
- data/lib/active_admin/views/components/action_list_popover.rb +6 -6
- data/lib/active_admin/views/components/attributes_table.rb +9 -12
- data/lib/active_admin/views/components/blank_slate.rb +4 -4
- data/lib/active_admin/views/components/columns.rb +1 -1
- data/lib/active_admin/views/components/index_list.rb +1 -1
- data/lib/active_admin/views/components/paginated_collection.rb +20 -12
- data/lib/active_admin/views/components/panel.rb +1 -1
- data/lib/active_admin/views/components/scopes.rb +2 -1
- data/lib/active_admin/views/components/sidebar_section.rb +1 -1
- data/lib/active_admin/views/components/status_tag.rb +1 -1
- data/lib/active_admin/views/header.rb +2 -2
- data/lib/active_admin/views/index_as_blog.rb +16 -3
- data/lib/active_admin/views/index_as_table.rb +2 -2
- data/lib/active_admin/views/pages/base.rb +8 -3
- data/lib/active_admin/views/pages/form.rb +2 -2
- data/lib/active_admin/views/pages/index.rb +19 -17
- data/lib/generators/active_admin/assets/templates/3.0/active_admin.js +1 -1
- data/lib/generators/active_admin/assets/templates/3.1/active_admin.css.scss +1 -13
- data/lib/generators/active_admin/devise/devise_generator.rb +22 -1
- data/lib/generators/active_admin/install/install_generator.rb +1 -5
- data/lib/generators/active_admin/install/templates/active_admin.rb.erb +40 -19
- data/lib/generators/active_admin/install/templates/admin_user.rb.erb +18 -18
- data/lib/generators/active_admin/install/templates/migrations/create_active_admin_comments.rb +19 -0
- data/lib/generators/active_admin/resource/resource_generator.rb +1 -1
- data/lib/generators/active_admin/resource/templates/admin.rb +1 -1
- data/script/use_rails +1 -1
- data/spec/integration/memory_spec.rb +3 -2
- data/spec/javascripts/coffeescripts/jquery.aa.checkbox-toggler-spec.js.coffee +4 -4
- data/spec/javascripts/coffeescripts/jquery.aa.popover-spec.js.coffee +1 -1
- data/spec/javascripts/coffeescripts/jquery.aa.table-checkbox-toggler-spec.js.coffee +2 -2
- data/spec/javascripts/compiled/jquery.aa.checkbox-toggler-spec.js +4 -4
- data/spec/javascripts/compiled/jquery.aa.popover-spec.js +1 -1
- data/spec/javascripts/compiled/jquery.aa.table-checkbox-toggler-spec.js +2 -2
- data/spec/spec_helper.rb +16 -6
- data/spec/spec_helper_without_rails.rb +2 -0
- data/spec/support/deferred_garbage_collection.rb +19 -0
- data/spec/support/jslint.yml +1 -1
- data/spec/support/rails_template.rb +29 -27
- data/spec/support/templates/admin/stores.rb +5 -1
- data/spec/unit/abstract_view_factory_spec.rb +1 -1
- data/spec/unit/action_builder_spec.rb +7 -7
- data/spec/unit/active_admin_spec.rb +0 -14
- data/spec/unit/application_spec.rb +16 -17
- data/spec/unit/asset_registration_spec.rb +21 -8
- data/spec/unit/authorization/authorization_adapter_spec.rb +3 -3
- data/spec/unit/authorization/controller_authorization_spec.rb +16 -24
- data/spec/unit/batch_actions/resource_spec.rb +11 -11
- data/spec/unit/belongs_to_spec.rb +1 -1
- data/spec/unit/cancan_adapter_spec.rb +11 -3
- data/spec/unit/comments_spec.rb +10 -28
- data/spec/unit/controller_filters_spec.rb +22 -24
- data/spec/unit/csv_builder_spec.rb +3 -3
- data/spec/unit/devise_spec.rb +10 -10
- data/spec/unit/filters/filter_form_builder_spec.rb +140 -45
- data/spec/unit/filters/resource_spec.rb +20 -19
- data/spec/unit/form_builder_spec.rb +122 -70
- data/spec/unit/menu_item_spec.rb +3 -3
- data/spec/unit/namespace/authorization_spec.rb +4 -8
- data/spec/unit/namespace/register_page_spec.rb +1 -1
- data/spec/unit/namespace/register_resource_spec.rb +12 -7
- data/spec/unit/namespace_spec.rb +4 -10
- data/spec/unit/page_spec.rb +1 -1
- data/spec/unit/resource/menu_spec.rb +1 -1
- data/spec/unit/resource/naming_spec.rb +9 -0
- data/spec/unit/resource/pagination_spec.rb +2 -2
- data/spec/unit/resource/routes_spec.rb +73 -0
- data/spec/unit/resource/scopes_spec.rb +1 -1
- data/spec/unit/resource_collection_spec.rb +95 -43
- data/spec/unit/resource_registration_spec.rb +3 -12
- data/spec/unit/resource_spec.rb +41 -48
- data/spec/unit/routing_spec.rb +10 -64
- data/spec/unit/scope_spec.rb +19 -0
- data/spec/unit/settings_spec.rb +88 -0
- data/spec/unit/view_factory_spec.rb +1 -0
- data/spec/unit/{breadcrumbs_spec.rb → view_helpers/breadcrumbs_spec.rb} +16 -7
- data/spec/unit/view_helpers/display_name_spec.rb +41 -0
- data/spec/unit/view_helpers/form_helper_spec.rb +36 -2
- data/spec/unit/views/components/attributes_table_spec.rb +17 -9
- data/spec/unit/views/components/batch_action_popover_spec.rb +4 -4
- data/spec/unit/views/components/index_list_spec.rb +2 -2
- data/spec/unit/views/components/paginated_collection_spec.rb +42 -0
- data/spec/unit/views/components/panel_spec.rb +8 -0
- data/spec/unit/views/components/site_title_spec.rb +2 -2
- data/spec/unit/views/components/table_for_spec.rb +4 -4
- data/spec/unit/views/pages/form_spec.rb +35 -0
- data/spec/unit/views/pages/layout_spec.rb +1 -1
- data/spec/unit/views/tabbed_navigation_spec.rb +10 -10
- data/tasks/parallel_tests.rake +1 -1
- data/tasks/test.rake +4 -1
- metadata +117 -106
- data/app/assets/stylesheets/active_admin/pages/_dashboard.scss +0 -5
- data/lib/active_admin/comments/views/active_admin_comment.rb +0 -0
- data/lib/active_admin/dashboards.rb +0 -68
- data/lib/active_admin/dashboards/dashboard_controller.rb +0 -50
- data/lib/active_admin/dashboards/section.rb +0 -34
- data/lib/active_admin/locales/bg.yml +0 -77
- data/lib/generators/active_admin/install/templates/migrations/1_create_admin_notes.rb +0 -17
- data/lib/generators/active_admin/install/templates/migrations/2_move_admin_notes_to_comments.rb +0 -26
- data/spec/unit/base_controller_spec.rb +0 -6
- data/spec/unit/dashboard_controller_spec.rb +0 -76
- data/spec/unit/dashboard_section_spec.rb +0 -56
- data/spec/unit/dashboards_spec.rb +0 -59
- data/spec/unit/display_name_spec.rb +0 -29
@@ -7,9 +7,9 @@ Then /^I should not see the default welcome message$/ do
|
|
7
7
|
end
|
8
8
|
|
9
9
|
Then /^I should see a dashboard widget "([^"]*)"$/ do |name|
|
10
|
-
page.should have_css('.dashboard .panel h3', :text => name)
|
10
|
+
page.should have_css('.dashboard .panel h3', :text => name)
|
11
11
|
end
|
12
12
|
|
13
13
|
Then /^I should not see a dashboard widget "([^"]*)"$/ do |name|
|
14
|
-
page.should_not have_css('.dashboard .panel h3', :text => name)
|
14
|
+
page.should_not have_css('.dashboard .panel h3', :text => name)
|
15
15
|
end
|
@@ -1,29 +1,15 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
Post.create! :title => title, :author => author, :published_at => published_at
|
14
|
-
end
|
15
|
-
|
16
|
-
Given /^(\d+)( published)? posts? written by "([^"]*)" exist$/ do |count, published, author_name|
|
17
|
-
first, last = author_name.split(' ')
|
18
|
-
author = User.find_or_create_by_first_name_and_last_name(first, last, :username => author_name.gsub(' ', '').underscore)
|
19
|
-
(0...count.to_i).each do |i|
|
20
|
-
Post.create! :title => "Hello World #{i}", :author => author, :published_at => (published ? Time.now : nil)
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
Given /^(\d+)( published)? posts? exists?$/ do |count, published|
|
25
|
-
(0...count.to_i).each do |i|
|
26
|
-
Post.create! :title => "Hello World #{i}", :published_at => (published ? Time.now : nil)
|
1
|
+
def create_user(name, type = 'User')
|
2
|
+
type.camelize.constantize.
|
3
|
+
find_or_create_by_first_name_and_last_name *name.split(' '), :username => name.gsub(' ', '').underscore
|
4
|
+
end
|
5
|
+
|
6
|
+
Given /^(a|\d+)( published)? posts?(?: with the title "([^"]*)")?(?: and body "([^"]*)")?(?: written by "([^"]*)")? exists?$/ do |count, published, title, body, user|
|
7
|
+
count = count == 'a' ? 1 : count.to_i
|
8
|
+
published = Time.now if published
|
9
|
+
author = create_user(user) if user
|
10
|
+
title ||= "Hello World %i"
|
11
|
+
count.times do |i|
|
12
|
+
Post.create! :title => title % i, :body => body, :author => author, :published_at => published
|
27
13
|
end
|
28
14
|
end
|
29
15
|
|
@@ -32,9 +18,11 @@ Given /^a category named "([^"]*)" exists$/ do |name|
|
|
32
18
|
end
|
33
19
|
|
34
20
|
Given /^a (user|publisher) named "([^"]*)" exists$/ do |type, name|
|
35
|
-
|
36
|
-
|
37
|
-
|
21
|
+
create_user name, type
|
22
|
+
end
|
23
|
+
|
24
|
+
Given /^a store named "([^"]*)" exists$/ do |name|
|
25
|
+
Store.create! :name => name
|
38
26
|
end
|
39
27
|
|
40
28
|
Given /^I create a new post with the title "([^"]*)"$/ do |title|
|
@@ -43,7 +31,3 @@ Given /^I create a new post with the title "([^"]*)"$/ do |title|
|
|
43
31
|
fill_in :title, :with => title
|
44
32
|
click_button "Create Post"
|
45
33
|
end
|
46
|
-
|
47
|
-
Given /^a store named "([^"]*)" exists$/ do |name|
|
48
|
-
Store.create! :name => name
|
49
|
-
end
|
@@ -3,7 +3,7 @@ Then /^I should see a select filter for "([^"]*)"$/ do |label|
|
|
3
3
|
end
|
4
4
|
|
5
5
|
Then /^I should see a string filter for "([^"]*)"$/ do |label|
|
6
|
-
page.should have_css(".filter_string label", :text =>
|
6
|
+
page.should have_css(".filter_string label", :text => label)
|
7
7
|
end
|
8
8
|
|
9
9
|
Then /^I should see a date range filter for "([^"]*)"$/ do |label|
|
@@ -12,6 +12,6 @@ end
|
|
12
12
|
|
13
13
|
Then /^I should see the following filters:$/ do |table|
|
14
14
|
table.rows_hash.each do |label, type|
|
15
|
-
step
|
15
|
+
step %{I should see a #{type} filter for "#{label}"}
|
16
16
|
end
|
17
17
|
end
|
@@ -10,20 +10,17 @@ Then "I should see nicely formatted datetimes" do
|
|
10
10
|
page.body.should =~ /\w+ \d{1,2}, \d{4} \d{2}:\d{2}/
|
11
11
|
end
|
12
12
|
|
13
|
-
Then /^I should see a link to download "([^"]*)"$/ do |
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
Then /^I should not see a link to download "([^"]*)"$/ do |format_type|
|
18
|
-
page.should_not have_css("#index_footer a", :text => format_type)
|
13
|
+
Then /^I should( not)? see a link to download "([^"]*)"$/ do |negate, format|
|
14
|
+
method = negate ? :should_not : :should
|
15
|
+
page.send method, have_css("#index_footer a", :text => format)
|
19
16
|
end
|
20
17
|
|
21
18
|
# Check first rows of the displayed CSV.
|
22
19
|
Then /^I should download a CSV file with "([^"]*)" separator for "([^"]*)" containing:$/ do |sep, resource_name, table|
|
23
|
-
page.
|
24
|
-
|
25
|
-
|
26
|
-
|
20
|
+
body = page.driver.response.body
|
21
|
+
headers = page.response_headers
|
22
|
+
headers['Content-Type'].should eq 'text/csv; charset=utf-8'
|
23
|
+
headers['Content-Disposition'].should eq %{attachment; filename="#{resource_name}-#{Time.now.strftime("%Y-%m-%d")}.csv"}
|
27
24
|
|
28
25
|
begin
|
29
26
|
csv = CSVLib.parse(body, :col_sep => sep)
|
@@ -33,7 +30,7 @@ Then /^I should download a CSV file with "([^"]*)" separator for "([^"]*)" conta
|
|
33
30
|
if expected_cell.blank?
|
34
31
|
cell.should be_nil
|
35
32
|
else
|
36
|
-
(cell || '').should match
|
33
|
+
(cell || '').should match /#{expected_cell}/
|
37
34
|
end
|
38
35
|
end
|
39
36
|
end
|
@@ -47,10 +44,9 @@ Then /^I should download a CSV file with "([^"]*)" separator for "([^"]*)" conta
|
|
47
44
|
end
|
48
45
|
|
49
46
|
Then /^I should download a CSV file for "([^"]*)" containing:$/ do |resource_name, table|
|
50
|
-
step
|
47
|
+
step %{I should download a CSV file with "," separator for "#{resource_name}" containing:}, table
|
51
48
|
end
|
52
49
|
|
53
50
|
Then /^the CSV file should contain "([^"]*)" in quotes$/ do |text|
|
54
|
-
|
55
|
-
body.should match(/\"#{text}\"/)
|
51
|
+
page.driver.response.body.should match /"#{text}"/
|
56
52
|
end
|
@@ -1,13 +1,7 @@
|
|
1
|
-
Then /^I should see the scope "([^"]*)"
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
Then /^I should not see the scope "([^"]*)"$/ do |name|
|
6
|
-
step %{I should not see "#{name}" within ".scopes"}
|
7
|
-
end
|
8
|
-
|
9
|
-
Then /^I should see the scope "([^"]*)" selected$/ do |name|
|
10
|
-
step %{I should see "#{name}" within ".scopes .selected"}
|
1
|
+
Then /^I should( not)? see the scope "([^"]*)"( selected)?$/ do |negate, name, selected|
|
2
|
+
should = "I should#{' not' if negate}"
|
3
|
+
scope = ".scopes#{' .selected' if selected}"
|
4
|
+
step %{#{should} see "#{name}" within "#{scope}"}
|
11
5
|
end
|
12
6
|
|
13
7
|
Then /^I should see the scope "([^"]*)" not selected$/ do |name|
|
@@ -16,22 +10,12 @@ Then /^I should see the scope "([^"]*)" not selected$/ do |name|
|
|
16
10
|
end
|
17
11
|
|
18
12
|
Then /^I should see the scope "([^"]*)" with the count (\d+)$/ do |name, count|
|
19
|
-
|
13
|
+
name = name.gsub(' ','').underscore.downcase
|
14
|
+
step %{I should see "#{count}" within ".scopes .#{name} .count"}
|
20
15
|
end
|
21
16
|
|
22
17
|
Then /^I should see the scope "([^"]*)" with no count$/ do |name|
|
23
|
-
|
24
|
-
page.
|
25
|
-
|
26
|
-
|
27
|
-
Then /^I should see (\d+) ([\w]*) in the table$/ do |count, resource_type|
|
28
|
-
begin
|
29
|
-
page.should have_css("table#index_table_#{resource_type} tr > td:first", :count => count.to_i)
|
30
|
-
rescue
|
31
|
-
current_count = 0
|
32
|
-
|
33
|
-
all("table#index_table_#{resource_type} tr > td:first").each { current_count += 1 }
|
34
|
-
|
35
|
-
raise "There were #{current_count} rows in the table not #{count}"
|
36
|
-
end
|
18
|
+
name = name.gsub(" ", "").underscore.downcase
|
19
|
+
page.should have_css(".scopes .#{name}")
|
20
|
+
page.should_not have_css(".scopes .#{name} .count")
|
37
21
|
end
|
@@ -3,5 +3,6 @@ Then /^I should see a sidebar titled "([^"]*)"$/ do |title|
|
|
3
3
|
end
|
4
4
|
|
5
5
|
Then /^I should not see a sidebar titled "([^"]*)"$/ do |title|
|
6
|
-
|
6
|
+
title = title.gsub(' ', '').underscore
|
7
|
+
page.all(:css, "##{title}_sidebar_section").count.should == 0
|
7
8
|
end
|
@@ -1,3 +1,8 @@
|
|
1
|
+
Then /^I should see (\d+) ([\w]*) in the table$/ do |count, resource_type|
|
2
|
+
all("table.index_table tr > td:first").count.should eq count.to_i
|
3
|
+
end
|
4
|
+
|
5
|
+
# TODO: simplify this, if possible?
|
1
6
|
class HtmlTableToTextHelper
|
2
7
|
def initialize(html, table_css_selector = "table")
|
3
8
|
@html = html
|
@@ -10,7 +15,7 @@ class HtmlTableToTextHelper
|
|
10
15
|
row.css('th, td').map do |td|
|
11
16
|
cell_to_string(td)
|
12
17
|
end
|
13
|
-
end
|
18
|
+
end
|
14
19
|
end
|
15
20
|
|
16
21
|
private
|
@@ -1,55 +1,40 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
1
|
+
def ensure_user_created(email)
|
2
|
+
user = AdminUser.find_or_create_by_email :email => email,
|
3
|
+
:password => 'password', :password_confirmation => 'password'
|
4
|
+
|
5
|
+
unless user.persisted?
|
6
|
+
raise "Could not create user #{email}: #{user.errors.full_messages}"
|
4
7
|
end
|
8
|
+
user
|
9
|
+
end
|
10
|
+
|
11
|
+
Given /^(?:I am logged|log) out$/ do
|
12
|
+
click_link 'Logout' if page.all(:css, "a", :text => 'Logout').any?
|
5
13
|
end
|
6
14
|
|
7
15
|
Given /^I am logged in$/ do
|
8
|
-
|
9
|
-
|
10
|
-
login_as(user)
|
16
|
+
step 'log out'
|
17
|
+
login_as ensure_user_created 'admin@example.com'
|
11
18
|
end
|
12
19
|
|
13
20
|
# only for @requires-reloading scenario
|
14
21
|
Given /^I am logged in with capybara$/ do
|
15
|
-
|
22
|
+
ensure_user_created 'admin@example.com'
|
23
|
+
step 'log out'
|
16
24
|
|
17
25
|
visit new_admin_user_session_path
|
18
|
-
fill_in
|
19
|
-
fill_in
|
20
|
-
click_button
|
26
|
+
fill_in 'Email', :with => 'admin@example.com'
|
27
|
+
fill_in 'Password', :with => 'password'
|
28
|
+
click_button 'Login'
|
21
29
|
end
|
22
30
|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
if page.all(:css, "a", :text => "Logout").size > 0
|
27
|
-
click_link "Logout"
|
28
|
-
end
|
31
|
+
Given /^an admin user "([^"]*)" exists$/ do |email|
|
32
|
+
ensure_user_created(email)
|
29
33
|
end
|
30
34
|
|
31
|
-
Given /^an admin user "([^"]*)" exists$/ do |
|
32
|
-
user =
|
33
|
-
|
34
|
-
:password_confirmation => "password"
|
35
|
-
|
36
|
-
unless user.persisted?
|
37
|
-
puts "Coult not create an admin user #{admin_email}: #{user.errors.full_messages}"
|
38
|
-
raise "Could not create an admin user"
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
|
-
Given /^an admin user "([^"]*)" exists with (expired )?reset password token "(.*?)"$/ do |admin_email, expired, token|
|
43
|
-
user = AdminUser.find_or_create_by_email :email => admin_email,
|
44
|
-
:password => "password",
|
45
|
-
:password_confirmation => "password"
|
46
|
-
|
47
|
-
unless user.persisted?
|
48
|
-
puts "Coult not create an admin user #{admin_email}: #{user.errors.full_messages}"
|
49
|
-
raise "Could not create an admin user"
|
50
|
-
end
|
51
|
-
|
52
|
-
user.reset_password_token = token
|
35
|
+
Given /^an admin user "([^"]*)" exists with( expired)? reset password token "(.*?)"$/ do |email, expired, token|
|
36
|
+
user = ensure_user_created(email)
|
37
|
+
user.reset_password_token = token
|
53
38
|
user.reset_password_sent_at = 1.minute.ago unless expired
|
54
39
|
user.save
|
55
40
|
end
|
@@ -1,26 +1,4 @@
|
|
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
1
|
require 'uri'
|
23
|
-
require 'cgi'
|
24
2
|
require File.expand_path(File.join(File.dirname(__FILE__), "..", "support", "paths"))
|
25
3
|
require File.expand_path(File.join(File.dirname(__FILE__), "..", "support", "selectors"))
|
26
4
|
|
@@ -41,169 +19,62 @@ When /^(.*) within (.*[^:]):$/ do |step_name, parent, table_or_string|
|
|
41
19
|
with_scope(parent) { step "#{step_name}:", table_or_string }
|
42
20
|
end
|
43
21
|
|
44
|
-
Given /^(
|
22
|
+
Given /^(?:I )am on (.+)$/ do |page_name|
|
45
23
|
visit path_to(page_name)
|
46
24
|
end
|
47
25
|
|
48
|
-
When /^(
|
26
|
+
When /^(?:I )go to (.+)$/ do |page_name|
|
49
27
|
visit path_to(page_name)
|
50
28
|
end
|
51
29
|
|
52
|
-
When /^(
|
30
|
+
When /^(?:I )press "([^"]*)"$/ do |button|
|
53
31
|
click_button(button)
|
54
32
|
end
|
55
33
|
|
56
|
-
When /^(
|
34
|
+
When /^(?:I )follow "([^"]*)"$/ do |link|
|
57
35
|
click_link(link)
|
58
36
|
end
|
59
37
|
|
60
|
-
When /^(
|
61
|
-
fill_in(field, :with => value)
|
62
|
-
end
|
63
|
-
|
64
|
-
When /^(?:|I )fill in "([^"]*)" for "([^"]*)"$/ do |value, field|
|
38
|
+
When /^(?:I )fill in "([^"]*)" with "([^"]*)"$/ do |field, value|
|
65
39
|
fill_in(field, :with => value)
|
66
40
|
end
|
67
41
|
|
68
|
-
|
69
|
-
#
|
70
|
-
# When I fill in the following:
|
71
|
-
# | Account Number | 5002 |
|
72
|
-
# | Expiry date | 2009-11-01 |
|
73
|
-
# | Note | Nice guy |
|
74
|
-
# | Wants Email? | |
|
75
|
-
#
|
76
|
-
# TODO: Add support for checkbox, select og option
|
77
|
-
# based on naming conventions.
|
78
|
-
#
|
79
|
-
When /^(?:|I )fill in the following:$/ do |fields|
|
80
|
-
fields.rows_hash.each do |name, value|
|
81
|
-
When %{I fill in "#{name}" with "#{value}"}
|
82
|
-
end
|
83
|
-
end
|
84
|
-
|
85
|
-
When /^(?:|I )select "([^"]*)" from "([^"]*)"$/ do |value, field|
|
42
|
+
When /^(?:I )select "([^"]*)" from "([^"]*)"$/ do |value, field|
|
86
43
|
select(value, :from => field)
|
87
44
|
end
|
88
45
|
|
89
|
-
When /^(
|
90
|
-
|
91
|
-
end
|
92
|
-
|
93
|
-
When /^(?:|I )uncheck "([^"]*)"$/ do |field|
|
94
|
-
uncheck(field)
|
46
|
+
When /^(?:I )(check|uncheck|choose) "([^"]*)"$/ do |action, field|
|
47
|
+
send action, field
|
95
48
|
end
|
96
49
|
|
97
|
-
When /^(
|
98
|
-
choose(field)
|
99
|
-
end
|
100
|
-
|
101
|
-
When /^(?:|I )attach the file "([^"]*)" to "([^"]*)"$/ do |path, field|
|
50
|
+
When /^(?:I )attach the file "([^"]*)" to "([^"]*)"$/ do |path, field|
|
102
51
|
attach_file(field, File.expand_path(path))
|
103
52
|
end
|
104
53
|
|
105
|
-
Then /^(
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
assert page.has_content?(text)
|
110
|
-
end
|
111
|
-
end
|
112
|
-
|
113
|
-
Then /^(?:|I )should see \/([^\/]*)\/$/ do |regexp|
|
114
|
-
regexp = Regexp.new(regexp)
|
115
|
-
|
116
|
-
if page.respond_to? :should
|
117
|
-
page.should have_xpath('//*', :text => regexp)
|
118
|
-
else
|
119
|
-
assert page.has_xpath?('//*', :text => regexp)
|
120
|
-
end
|
121
|
-
end
|
122
|
-
|
123
|
-
Then /^(?:|I )should not see "([^"]*)"$/ do |text|
|
124
|
-
if page.respond_to? :should
|
125
|
-
page.should have_no_content(text)
|
126
|
-
else
|
127
|
-
assert page.has_no_content?(text)
|
128
|
-
end
|
129
|
-
end
|
130
|
-
|
131
|
-
Then /^(?:|I )should not see \/([^\/]*)\/$/ do |regexp|
|
132
|
-
regexp = Regexp.new(regexp)
|
133
|
-
|
134
|
-
if page.respond_to? :should
|
135
|
-
page.should have_no_xpath('//*', :text => regexp)
|
136
|
-
else
|
137
|
-
assert page.has_no_xpath?('//*', :text => regexp)
|
138
|
-
end
|
54
|
+
Then /^(?:I )should( not)? see( the element)? "([^"]*)"$/ do |negate, is_css, text|
|
55
|
+
should = negate ? :should_not : :should
|
56
|
+
have = is_css ? have_css(text) : have_content(text)
|
57
|
+
page.send should, have
|
139
58
|
end
|
140
59
|
|
141
|
-
Then /^the "([^"]*)" field(?: within (.*))? should contain "([^"]*)"$/ do |field, parent, value|
|
60
|
+
Then /^the "([^"]*)" field(?: within (.*))? should( not)? contain "([^"]*)"$/ do |field, parent, negate, value|
|
142
61
|
with_scope(parent) do
|
143
62
|
field = find_field(field)
|
144
63
|
field_value = (field.tag_name == 'textarea') ? field.text : field.value
|
145
|
-
|
146
|
-
field_value.should =~ /#{value}/
|
147
|
-
else
|
148
|
-
assert_match(/#{value}/, field_value)
|
149
|
-
end
|
64
|
+
negate ? field_value.should_not =~ /#{value}/ : field_value.should =~ /#{value}/
|
150
65
|
end
|
151
66
|
end
|
152
67
|
|
153
|
-
Then /^the "([^"]*)"
|
154
|
-
with_scope(parent) do
|
155
|
-
field = find_field(field)
|
156
|
-
field_value = (field.tag_name == 'textarea') ? field.text : field.value
|
157
|
-
if field_value.respond_to? :should_not
|
158
|
-
field_value.should_not =~ /#{value}/
|
159
|
-
else
|
160
|
-
assert_no_match(/#{value}/, field_value)
|
161
|
-
end
|
162
|
-
end
|
163
|
-
end
|
164
|
-
|
165
|
-
Then /^the "([^"]*)" checkbox(?: within (.*))? should be checked$/ do |label, parent|
|
68
|
+
Then /^the "([^"]*)" checkbox(?: within (.*))? should( not)? be checked$/ do |label, parent, negate|
|
166
69
|
with_scope(parent) do
|
167
70
|
field_checked = find_field(label)['checked']
|
168
|
-
|
169
|
-
field_checked.should be_true
|
170
|
-
else
|
171
|
-
assert field_checked
|
172
|
-
end
|
71
|
+
field_checked.should negate ? be_false : be_true
|
173
72
|
end
|
174
73
|
end
|
175
74
|
|
176
|
-
Then /^the "([^"]*)" checkbox(?: within (.*))? should not be checked$/ do |label, parent|
|
177
|
-
with_scope(parent) do
|
178
|
-
field_checked = find_field(label)['checked']
|
179
|
-
if field_checked.respond_to? :should
|
180
|
-
field_checked.should be_false
|
181
|
-
else
|
182
|
-
assert !field_checked
|
183
|
-
end
|
184
|
-
end
|
185
|
-
end
|
186
|
-
|
187
75
|
Then /^(?:|I )should be on (.+)$/ do |page_name|
|
188
76
|
current_path = URI.parse(current_url).path
|
189
|
-
|
190
|
-
current_path.should == path_to(page_name)
|
191
|
-
else
|
192
|
-
assert_equal path_to(page_name), current_path
|
193
|
-
end
|
194
|
-
end
|
195
|
-
|
196
|
-
Then /^(?:|I )should have the following query string:$/ do |expected_pairs|
|
197
|
-
query = URI.parse(current_url).query
|
198
|
-
actual_params = query ? CGI.parse(query) : {}
|
199
|
-
expected_params = {}
|
200
|
-
expected_pairs.rows_hash.each_pair{|k,v| expected_params[k] = v.split(',')}
|
201
|
-
|
202
|
-
if actual_params.respond_to? :should
|
203
|
-
actual_params.should == expected_params
|
204
|
-
else
|
205
|
-
assert_equal expected_params, actual_params
|
206
|
-
end
|
77
|
+
current_path.should == path_to(page_name)
|
207
78
|
end
|
208
79
|
|
209
80
|
Then /^show me the page$/ do
|