red_base 0.5.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.
- checksums.yaml +7 -0
- data/LICENSE +339 -0
- data/README.rdoc +40 -0
- data/Rakefile +42 -0
- data/app/assets/fonts/DroidNaskh-Bold.ttf +0 -0
- data/app/assets/fonts/DroidNaskh-Regular.ttf +0 -0
- data/app/assets/fonts/OpenSans-Bold.ttf +0 -0
- data/app/assets/fonts/OpenSans-BoldItalic.ttf +0 -0
- data/app/assets/fonts/OpenSans-ExtraBold.ttf +0 -0
- data/app/assets/fonts/OpenSans-ExtraBoldItalic.ttf +0 -0
- data/app/assets/fonts/OpenSans-Italic.ttf +0 -0
- data/app/assets/fonts/OpenSans-Light.ttf +0 -0
- data/app/assets/fonts/OpenSans-LightItalic.ttf +0 -0
- data/app/assets/fonts/OpenSans-Regular.ttf +0 -0
- data/app/assets/fonts/OpenSans-Semibold.ttf +0 -0
- data/app/assets/fonts/OpenSans-SemiboldItalic.ttf +0 -0
- data/app/assets/javascripts/red_base/application.js +20 -0
- data/app/assets/javascripts/red_base/dashboard/angular.js +9 -0
- data/app/assets/javascripts/red_base/dashboard/app.js +65 -0
- data/app/assets/javascripts/red_base/dashboard/application.js.erb +24 -0
- data/app/assets/javascripts/red_base/dashboard/functions.js.erb +91 -0
- data/app/assets/javascripts/red_base/dashboard/init.js +38 -0
- data/app/assets/javascripts/red_base/dashboard/init.js~ +0 -0
- data/app/assets/javascripts/red_base/dashboard/lib/angular-animate.js +1226 -0
- data/app/assets/javascripts/red_base/dashboard/lib/angular-gettext.js +202 -0
- data/app/assets/javascripts/red_base/dashboard/lib/angular-resource.js +578 -0
- data/app/assets/javascripts/red_base/dashboard/lib/angular-route.js +880 -0
- data/app/assets/javascripts/red_base/dashboard/lib/angular.js +20031 -0
- data/app/assets/javascripts/red_base/dashboard/lib/lodash.underscore.js +4893 -0
- data/app/assets/javascripts/red_base/dashboard/lib/restangular.js +1066 -0
- data/app/assets/javascripts/red_base/dashboard/locale/translations.js +5 -0
- data/app/assets/javascripts/red_base/dashboard/modules/anim.js +32 -0
- data/app/assets/javascripts/red_base/dashboard/modules/api.js +32 -0
- data/app/assets/javascripts/red_base/dashboard/modules/auth/auth.js +34 -0
- data/app/assets/javascripts/red_base/dashboard/modules/auth/group.js +174 -0
- data/app/assets/javascripts/red_base/dashboard/modules/auth/user.js +122 -0
- data/app/assets/javascripts/red_base/dashboard/modules/list-view.js +293 -0
- data/app/assets/javascripts/red_base/dashboard/modules/logs.js +41 -0
- data/app/assets/javascripts/red_base/dashboard/modules/modules.js +50 -0
- data/app/assets/javascripts/red_base/dashboard/modules/nav.js.erb +92 -0
- data/app/assets/javascripts/red_base/dashboard/templates/application.handlebars.erb +42 -0
- data/app/assets/javascripts/red_base/dashboard/templates/auth/groups/details.handlebars.erb +15 -0
- data/app/assets/javascripts/red_base/dashboard/templates/auth/groups/index.handlebars.erb +7 -0
- data/app/assets/javascripts/red_base/dashboard/templates/auth/groups/new.handlebars.erb +39 -0
- data/app/assets/javascripts/red_base/dashboard/templates/auth/index.handlebars.erb +31 -0
- data/app/assets/javascripts/red_base/dashboard/templates/auth/users/details.handlebars.erb +15 -0
- data/app/assets/javascripts/red_base/dashboard/templates/auth/users/index.handlebars.erb +11 -0
- data/app/assets/javascripts/red_base/dashboard/templates/auth/users/new.handlebars.erb +33 -0
- data/app/assets/javascripts/red_base/dashboard/templates/components/list-view.handlebars.erb +59 -0
- data/app/assets/javascripts/red_base/dashboard/templates/components/model-form.handlebars.erb +3 -0
- data/app/assets/javascripts/red_base/dashboard/templates/modules.handlebars.erb +15 -0
- data/app/assets/javascripts/red_base/dashboard/templates/navigation.handlebars.erb +43 -0
- data/app/assets/javascripts/red_base/dashboard/templates/widgets.handlebars +23 -0
- data/app/assets/javascripts/red_base/dashboard/variables.js.erb +17 -0
- data/app/assets/javascripts/red_base/groups.js +2 -0
- data/app/assets/javascripts/red_base/home.js +2 -0
- data/app/assets/javascripts/red_base/i18n.js +13 -0
- data/app/assets/javascripts/red_base/locale/en.json +27 -0
- data/app/assets/javascripts/red_base/locale/fa.json +27 -0
- data/app/assets/javascripts/red_base/users.js +2 -0
- data/app/assets/stylesheets/red_base/base.css.scss +402 -0
- data/app/assets/stylesheets/red_base/dashboard/dashboard.css.scss +169 -0
- data/app/assets/stylesheets/red_base/dashboard/ltr/application.css +21 -0
- data/app/assets/stylesheets/red_base/dashboard/ltr/base.css.scss.erb +28 -0
- data/app/assets/stylesheets/red_base/dashboard/ltr/base.css.scss~ +15 -0
- data/app/assets/stylesheets/red_base/dashboard/ltr/buttons.css.scss.erb +48 -0
- data/app/assets/stylesheets/red_base/dashboard/ltr/direction.css.scss +38 -0
- data/app/assets/stylesheets/red_base/dashboard/ltr/foundation_and_overrides.css.scss +1014 -0
- data/app/assets/stylesheets/red_base/dashboard/rtl/application.css +21 -0
- data/app/assets/stylesheets/red_base/dashboard/rtl/base.css.scss.erb +31 -0
- data/app/assets/stylesheets/red_base/dashboard/rtl/base.css.scss~ +1 -0
- data/app/assets/stylesheets/red_base/dashboard/rtl/base.css_flymake.scss +25 -0
- data/app/assets/stylesheets/red_base/dashboard/rtl/buttons.css.scss.erb +45 -0
- data/app/assets/stylesheets/red_base/dashboard/rtl/direction.css.scss +37 -0
- data/app/assets/stylesheets/red_base/dashboard/rtl/foundation_and_overrides.css.scss +1014 -0
- data/app/assets/stylesheets/red_base/dashboard/sidebar.css.scss +93 -0
- data/app/assets/stylesheets/red_base/devise.css.scss +34 -0
- data/app/assets/stylesheets/red_base/groups.css +4 -0
- data/app/assets/stylesheets/red_base/home.css.scss +14 -0
- data/app/assets/stylesheets/red_base/ltr/application.css +20 -0
- data/app/assets/stylesheets/red_base/ltr/buttons.css.scss.erb +48 -0
- data/app/assets/stylesheets/red_base/ltr/foundation_and_overrides.scss.erb +1012 -0
- data/app/assets/stylesheets/red_base/mixins.css.scss +15 -0
- data/app/assets/stylesheets/red_base/mixins.css.scss~ +7 -0
- data/app/assets/stylesheets/red_base/rtl/application.css +20 -0
- data/app/assets/stylesheets/red_base/rtl/buttons.css.scss.erb +48 -0
- data/app/assets/stylesheets/red_base/rtl/foundation_and_overrides.scss.erb +1012 -0
- data/app/assets/stylesheets/red_base/users.css +4 -0
- data/app/assets/stylesheets/red_base/variables.css.scss +100 -0
- data/app/controllers/red_base/api/v1/groups_controller.rb +65 -0
- data/app/controllers/red_base/api/v1/logs_controller.rb +12 -0
- data/app/controllers/red_base/api/v1/permissions_controller.rb +17 -0
- data/app/controllers/red_base/api/v1/users_controller.rb +54 -0
- data/app/controllers/red_base/api_controller.rb +51 -0
- data/app/controllers/red_base/application_controller.rb +34 -0
- data/app/controllers/red_base/dashboard_controller.rb +40 -0
- data/app/controllers/red_base/home_controller.rb +19 -0
- data/app/controllers/red_base/omniauth/callbacks_controller.rb +43 -0
- data/app/controllers/red_base/users/omniauth_callbacks_controller.rb~ +2 -0
- data/app/helpers/red_base/application_helper.rb +4 -0
- data/app/helpers/red_base/dashboard_helper.rb +5 -0
- data/app/helpers/red_base/groups_helper.rb +4 -0
- data/app/helpers/red_base/home_helper.rb +4 -0
- data/app/helpers/red_base/users_helper.rb +4 -0
- data/app/models/ability.rb +39 -0
- data/app/models/red_base/group.rb +27 -0
- data/app/models/red_base/permission.rb +15 -0
- data/app/models/red_base/user.rb +77 -0
- data/app/views/angularjs_templates/auth/groups/details.html +21 -0
- data/app/views/angularjs_templates/auth/groups/index.html +5 -0
- data/app/views/angularjs_templates/auth/groups/new.html +40 -0
- data/app/views/angularjs_templates/auth/index.html +30 -0
- data/app/views/angularjs_templates/auth/users/details.html +28 -0
- data/app/views/angularjs_templates/auth/users/index.html +6 -0
- data/app/views/angularjs_templates/auth/users/new.html +45 -0
- data/app/views/angularjs_templates/index.html +8 -0
- data/app/views/angularjs_templates/list-view/index.html +66 -0
- data/app/views/angularjs_templates/locale/fa.po +25 -0
- data/app/views/angularjs_templates/locale/templates.pot +24 -0
- data/app/views/angularjs_templates/logs/index.html +6 -0
- data/app/views/angularjs_templates/modules.html +17 -0
- data/app/views/angularjs_templates/nav.html.erb +38 -0
- data/app/views/angularjs_templates/nav.html.erb~ +43 -0
- data/app/views/devise/confirmations/new.html.erb +34 -0
- data/app/views/devise/mailer/confirmation_instructions.html.erb +5 -0
- data/app/views/devise/mailer/reset_password_instructions.html.erb +8 -0
- data/app/views/devise/mailer/unlock_instructions.html.erb +7 -0
- data/app/views/devise/passwords/edit.html.erb +44 -0
- data/app/views/devise/passwords/new.html.erb +32 -0
- data/app/views/devise/registrations/edit.html.erb +29 -0
- data/app/views/devise/registrations/new.html.erb +91 -0
- data/app/views/devise/sessions/new.html.erb +98 -0
- data/app/views/devise/shared/_links.erb +25 -0
- data/app/views/devise/unlocks/new.html.erb +30 -0
- data/app/views/layouts/red_base/application.html.erb +90 -0
- data/app/views/layouts/red_base/dashboard.html.erb +21 -0
- data/app/views/red_base/api/v1/groups/create.json.jbuilder +4 -0
- data/app/views/red_base/api/v1/groups/destroy.html.erb +2 -0
- data/app/views/red_base/api/v1/groups/destroy.json.jbuilder +1 -0
- data/app/views/red_base/api/v1/groups/edit.html.erb +2 -0
- data/app/views/red_base/api/v1/groups/index.html.erb +2 -0
- data/app/views/red_base/api/v1/groups/index.json.jbuilder +6 -0
- data/app/views/red_base/api/v1/groups/new.html.erb +2 -0
- data/app/views/red_base/api/v1/groups/show.html.erb +2 -0
- data/app/views/red_base/api/v1/groups/show.json.jbuilder +5 -0
- data/app/views/red_base/api/v1/groups/update.json.jbuilder +4 -0
- data/app/views/red_base/api/v1/logs/index.json.jbuilder +1 -0
- data/app/views/red_base/api/v1/permissions/index.json.jbuilder +1 -0
- data/app/views/red_base/api/v1/users/create.html.erb +2 -0
- data/app/views/red_base/api/v1/users/create.json.jbuilder +1 -0
- data/app/views/red_base/api/v1/users/destroy.json.jbuilder +1 -0
- data/app/views/red_base/api/v1/users/distroy.html.erb +2 -0
- data/app/views/red_base/api/v1/users/edit.html.erb +2 -0
- data/app/views/red_base/api/v1/users/index.html.erb +2 -0
- data/app/views/red_base/api/v1/users/index.json.jbuilder +4 -0
- data/app/views/red_base/api/v1/users/show.html.erb +2 -0
- data/app/views/red_base/api/v1/users/show.json.jbuilder +2 -0
- data/app/views/red_base/api/v1/users/update.json.jbuilder +1 -0
- data/app/views/red_base/dashboard/index.html.erb +37 -0
- data/app/views/red_base/home/index.html.erb +119 -0
- data/config/initializers/devise.rb +28 -0
- data/config/locales/devise.en.yml +59 -0
- data/config/locales/devise.fa.yml +56 -0
- data/config/locales/fa/LC_MESSAGES/red_base.mo +0 -0
- data/config/locales/fa/messages.mo +0 -0
- data/config/locales/fa/red_base.po +181 -0
- data/config/locales/red_base.pot +181 -0
- data/config/routes.rb +33 -0
- data/db/migrate/20131013091000_devise_create_red_base_users.rb +64 -0
- data/db/migrate/20131020124701_create_red_base_groups.rb +9 -0
- data/db/migrate/20131021170923_create_red_base_permissions.rb +10 -0
- data/db/migrate/20131123120422_add_permissions_groups_table.rb +8 -0
- data/db/seeds.rb +15 -0
- data/lib/devise_patch.rb~ +5 -0
- data/lib/generators/red_base/USAGE +8 -0
- data/lib/generators/red_base/angularjs_resource_generator.rb +74 -0
- data/lib/generators/red_base/install_all_generator.rb +38 -0
- data/lib/generators/red_base/install_generator.rb +42 -0
- data/lib/generators/red_base/install_specs_generator.rb +48 -0
- data/lib/generators/red_base/js_scaffold_generator.rb +232 -0
- data/lib/generators/red_base/templates/README +41 -0
- data/lib/generators/red_base/templates/README~ +4 -0
- data/lib/generators/red_base/templates/SPECS +13 -0
- data/lib/generators/red_base/templates/angularjs/details.html.erb +20 -0
- data/lib/generators/red_base/templates/angularjs/details.html.erb~ +0 -0
- data/lib/generators/red_base/templates/angularjs/index.html.erb +59 -0
- data/lib/generators/red_base/templates/angularjs/module.js.erb +259 -0
- data/lib/generators/red_base/templates/angularjs/new.html.erb +43 -0
- data/lib/generators/red_base/templates/api/controller.rb.erb +54 -0
- data/lib/generators/red_base/templates/api/controller.rb.erb~ +37 -0
- data/lib/generators/red_base/templates/devise.rb +251 -0
- data/lib/generators/red_base/templates/devise.rb~ +238 -0
- data/lib/generators/red_base/templates/fast_gettext.rb +4 -0
- data/lib/generators/red_base/templates/features/api.feature +92 -0
- data/lib/generators/red_base/templates/features/api.step.rb +7 -0
- data/lib/generators/red_base/templates/features/step_definitions/email_steps.rb +206 -0
- data/lib/generators/red_base/templates/features/support/email_spec.rb +1 -0
- data/lib/generators/red_base/templates/features/support/env.rb +79 -0
- data/lib/generators/red_base/templates/formtastic.rb +76 -0
- data/lib/generators/red_base/templates/js_scaffold.README +25 -0
- data/lib/generators/red_base/templates/red_base.rb +14 -0
- data/lib/generators/red_base/templates/red_base.rb~ +251 -0
- data/lib/generators/red_base/templates/seeds.rb +1 -0
- data/lib/generators/red_base/templates/spec/factories/groups.rb +5 -0
- data/lib/generators/red_base/templates/spec/factories/users.rb +10 -0
- data/lib/generators/red_base/templates/spec/spec_helper.rb +69 -0
- data/lib/generators/red_base/templates/spec/support/devise.rb +3 -0
- data/lib/generators/red_base/templates/views/create.json.jbuilder.erb +2 -0
- data/lib/generators/red_base/templates/views/destroy.json.jbuilder.erb +1 -0
- data/lib/generators/red_base/templates/views/index.json.jbuilder.erb +10 -0
- data/lib/generators/red_base/templates/views/index.json.jbuilder.erb~ +0 -0
- data/lib/generators/red_base/templates/views/show.json.jbuilder.erb +6 -0
- data/lib/generators/red_base/templates/views/update.json.jbuilder.erb +6 -0
- data/lib/generators/red_base/views_generator.rb +41 -0
- data/lib/red_base/active_record.rb +78 -0
- data/lib/red_base/active_record.rb~ +0 -0
- data/lib/red_base/api/groups_api.rb +41 -0
- data/lib/red_base/api/permissions_api.rb +24 -0
- data/lib/red_base/api/root.rb +15 -0
- data/lib/red_base/api/users_api.rb +20 -0
- data/lib/red_base/api.rb +61 -0
- data/lib/red_base/cucumber/auth.rb +45 -0
- data/lib/red_base/cucumber/exceptions.rb +40 -0
- data/lib/red_base/cucumber/interaction.rb +43 -0
- data/lib/red_base/cucumber/query.rb +28 -0
- data/lib/red_base/cucumber/urls.rb +76 -0
- data/lib/red_base/cucumber.rb +25 -0
- data/lib/red_base/dashboard/controller.rb +42 -0
- data/lib/red_base/dashboard/module.rb +45 -0
- data/lib/red_base/dashboard/module.rb~ +25 -0
- data/lib/red_base/dashboard.rb +60 -0
- data/lib/red_base/dashboard.rb~ +18 -0
- data/lib/red_base/engine.rb +132 -0
- data/lib/red_base/exceptions.rb +26 -0
- data/lib/red_base/i18n.rb +35 -0
- data/lib/red_base/initialize.rb +7 -0
- data/lib/red_base/omniauth/callbacks.rb +58 -0
- data/lib/red_base/omniauth/callbakcs.rb~ +7 -0
- data/lib/red_base/omniauth.rb +24 -0
- data/lib/red_base/omniauth.rb~ +1 -0
- data/lib/red_base/plugins.rb +44 -0
- data/lib/red_base/version.rb +22 -0
- data/lib/red_base.rb +30 -0
- data/lib/tasks/grunt/Gruntfile.js +25 -0
- data/lib/tasks/red_base_tasks.rake +23 -0
- data/spec/dummy/README.rdoc +28 -0
- data/spec/dummy/Rakefile +6 -0
- data/spec/dummy/app/assets/javascripts/application.js +13 -0
- data/spec/dummy/app/assets/stylesheets/application.css +13 -0
- data/spec/dummy/app/controllers/application_controller.rb +5 -0
- data/spec/dummy/app/helpers/application_helper.rb +2 -0
- data/spec/dummy/app/views/layouts/application.html.erb +14 -0
- data/spec/dummy/bin/bundle +3 -0
- data/spec/dummy/bin/rails +4 -0
- data/spec/dummy/bin/rake +4 -0
- data/spec/dummy/config/application.rb +23 -0
- data/spec/dummy/config/boot.rb +5 -0
- data/spec/dummy/config/database.yml +25 -0
- data/spec/dummy/config/environment.rb +5 -0
- data/spec/dummy/config/environments/development.rb +29 -0
- data/spec/dummy/config/environments/production.rb +80 -0
- data/spec/dummy/config/environments/test.rb +36 -0
- data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/spec/dummy/config/initializers/filter_parameter_logging.rb +4 -0
- data/spec/dummy/config/initializers/inflections.rb +16 -0
- data/spec/dummy/config/initializers/mime_types.rb +5 -0
- data/spec/dummy/config/initializers/secret_token.rb +12 -0
- data/spec/dummy/config/initializers/session_store.rb +3 -0
- data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/spec/dummy/config/locales/en.yml +23 -0
- data/spec/dummy/config/routes.rb +4 -0
- data/spec/dummy/config.ru +4 -0
- data/spec/dummy/public/404.html +58 -0
- data/spec/dummy/public/422.html +58 -0
- data/spec/dummy/public/500.html +57 -0
- data/spec/dummy/public/favicon.ico +0 -0
- data/spec/spec_helper.rb +52 -0
- metadata +661 -0
|
@@ -0,0 +1,238 @@
|
|
|
1
|
+
# Use this hook to configure devise mailer, warden hooks and so forth.
|
|
2
|
+
# Many of these configuration options can be set straight in your model.
|
|
3
|
+
Devise.setup do |config|
|
|
4
|
+
# The secret key used by Devise. Devise uses this key to generate
|
|
5
|
+
# random tokens. Changing this key will render invalid all existing
|
|
6
|
+
# confirmation, reset password and unlock tokens in the database.
|
|
7
|
+
#config.secret_key = '6c91fdd19ede26e86c7aed4a8df74d2abdc35973cd82df7c4d8f50d7644de99ea56b341097f748a8a2beb486691caa64cb1e5ffec3991375561494288efb7ff2'
|
|
8
|
+
|
|
9
|
+
# ==> Mailer Configuration
|
|
10
|
+
# Configure the e-mail address which will be shown in Devise::Mailer,
|
|
11
|
+
# note that it will be overwritten if you use your own mailer class
|
|
12
|
+
# with default "from" parameter.
|
|
13
|
+
config.mailer_sender = 'please-change-me-at-config-initializers-devise@example.com'
|
|
14
|
+
|
|
15
|
+
# Configure the class responsible to send e-mails.
|
|
16
|
+
# config.mailer = 'Devise::Mailer'
|
|
17
|
+
|
|
18
|
+
# ==> Configuration for any authentication mechanism
|
|
19
|
+
# Configure which keys are used when authenticating a user. The default is
|
|
20
|
+
# just :email. You can configure it to use [:username, :subdomain], so for
|
|
21
|
+
# authenticating a user, both parameters are required. Remember that those
|
|
22
|
+
# parameters are used only when authenticating and not when retrieving from
|
|
23
|
+
# session. If you need permissions, you should implement that in a before filter.
|
|
24
|
+
# You can also supply a hash where the value is a boolean determining whether
|
|
25
|
+
# or not authentication should be aborted when the value is not present.
|
|
26
|
+
# config.authentication_keys = [ :email ]
|
|
27
|
+
|
|
28
|
+
# Configure parameters from the request object used for authentication. Each entry
|
|
29
|
+
# given should be a request method and it will automatically be passed to the
|
|
30
|
+
# find_for_authentication method and considered in your model lookup. For instance,
|
|
31
|
+
# if you set :request_keys to [:subdomain], :subdomain will be used on authentication.
|
|
32
|
+
# The same considerations mentioned for authentication_keys also apply to request_keys.
|
|
33
|
+
# config.request_keys = []
|
|
34
|
+
|
|
35
|
+
# Configure which authentication keys should be case-insensitive.
|
|
36
|
+
# These keys will be downcased upon creating or modifying a user and when used
|
|
37
|
+
# to authenticate or find a user. Default is :email.
|
|
38
|
+
config.case_insensitive_keys = [ :email ]
|
|
39
|
+
|
|
40
|
+
# Configure which authentication keys should have whitespace stripped.
|
|
41
|
+
# These keys will have whitespace before and after removed upon creating or
|
|
42
|
+
# modifying a user and when used to authenticate or find a user. Default is :email.
|
|
43
|
+
config.strip_whitespace_keys = [ :email ]
|
|
44
|
+
|
|
45
|
+
# Tell if authentication through request.params is enabled. True by default.
|
|
46
|
+
# It can be set to an array that will enable params authentication only for the
|
|
47
|
+
# given strategies, for example, `config.params_authenticatable = [:database]` will
|
|
48
|
+
# enable it only for database (email + password) authentication.
|
|
49
|
+
# config.params_authenticatable = true
|
|
50
|
+
|
|
51
|
+
# Tell if authentication through HTTP Auth is enabled. False by default.
|
|
52
|
+
# It can be set to an array that will enable http authentication only for the
|
|
53
|
+
# given strategies, for example, `config.http_authenticatable = [:token]` will
|
|
54
|
+
# enable it only for token authentication. The supported strategies are:
|
|
55
|
+
# :database = Support basic authentication with authentication key + password
|
|
56
|
+
# :token = Support basic authentication with token authentication key
|
|
57
|
+
# :token_options = Support token authentication with options as defined in
|
|
58
|
+
# http://api.rubyonrails.org/classes/ActionController/HttpAuthentication/Token.html
|
|
59
|
+
# config.http_authenticatable = false
|
|
60
|
+
|
|
61
|
+
# If http headers should be returned for AJAX requests. True by default.
|
|
62
|
+
# config.http_authenticatable_on_xhr = true
|
|
63
|
+
|
|
64
|
+
# The realm used in Http Basic Authentication. 'Application' by default.
|
|
65
|
+
# config.http_authentication_realm = 'Application'
|
|
66
|
+
|
|
67
|
+
# It will change confirmation, password recovery and other workflows
|
|
68
|
+
# to behave the same regardless if the e-mail provided was right or wrong.
|
|
69
|
+
# Does not affect registerable.
|
|
70
|
+
# config.paranoid = true
|
|
71
|
+
|
|
72
|
+
# By default Devise will store the user in session. You can skip storage for
|
|
73
|
+
# :http_auth and :token_auth by adding those symbols to the array below.
|
|
74
|
+
# Notice that if you are skipping storage for all authentication paths, you
|
|
75
|
+
# may want to disable generating routes to Devise's sessions controller by
|
|
76
|
+
# passing :skip => :sessions to `devise_for` in your config/routes.rb
|
|
77
|
+
config.skip_session_storage = [:http_auth]
|
|
78
|
+
|
|
79
|
+
# By default, Devise cleans up the CSRF token on authentication to
|
|
80
|
+
# avoid CSRF token fixation attacks. This means that, when using AJAX
|
|
81
|
+
# requests for sign in and sign up, you need to get a new CSRF token
|
|
82
|
+
# from the server. You can disable this option at your own risk.
|
|
83
|
+
# config.clean_up_csrf_token_on_authentication = true
|
|
84
|
+
|
|
85
|
+
# ==> Configuration for :database_authenticatable
|
|
86
|
+
# For bcrypt, this is the cost for hashing the password and defaults to 10. If
|
|
87
|
+
# using other encryptors, it sets how many times you want the password re-encrypted.
|
|
88
|
+
#
|
|
89
|
+
# Limiting the stretches to just one in testing will increase the performance of
|
|
90
|
+
# your test suite dramatically. However, it is STRONGLY RECOMMENDED to not use
|
|
91
|
+
# a value less than 10 in other environments.
|
|
92
|
+
config.stretches = Rails.env.test? ? 1 : 10
|
|
93
|
+
|
|
94
|
+
# Setup a pepper to generate the encrypted password.
|
|
95
|
+
# config.pepper = "ae612b705eeacb74b81eaa3d1590f4292bef3fefb373c47e2fdae44ea7183fcfdf0741e312fead38503e13dd42aeba8cba06fa45c13737e889ee8331bbd2c209"
|
|
96
|
+
|
|
97
|
+
# ==> Configuration for :confirmable
|
|
98
|
+
# A period that the user is allowed to access the website even without
|
|
99
|
+
# confirming his account. For instance, if set to 2.days, the user will be
|
|
100
|
+
# able to access the website for two days without confirming his account,
|
|
101
|
+
# access will be blocked just in the third day. Default is 0.days, meaning
|
|
102
|
+
# the user cannot access the website without confirming his account.
|
|
103
|
+
# config.allow_unconfirmed_access_for = 2.days
|
|
104
|
+
|
|
105
|
+
# A period that the user is allowed to confirm their account before their
|
|
106
|
+
# token becomes invalid. For example, if set to 3.days, the user can confirm
|
|
107
|
+
# their account within 3 days after the mail was sent, but on the fourth day
|
|
108
|
+
# their account can't be confirmed with the token any more.
|
|
109
|
+
# Default is nil, meaning there is no restriction on how long a user can take
|
|
110
|
+
# before confirming their account.
|
|
111
|
+
# config.confirm_within = 3.days
|
|
112
|
+
|
|
113
|
+
# If true, requires any email changes to be confirmed (exactly the same way as
|
|
114
|
+
# initial account confirmation) to be applied. Requires additional unconfirmed_email
|
|
115
|
+
# db field (see migrations). Until confirmed new email is stored in
|
|
116
|
+
# unconfirmed email column, and copied to email column on successful confirmation.
|
|
117
|
+
config.reconfirmable = true
|
|
118
|
+
|
|
119
|
+
# Defines which key will be used when confirming an account
|
|
120
|
+
# config.confirmation_keys = [ :email ]
|
|
121
|
+
|
|
122
|
+
# ==> Configuration for :rememberable
|
|
123
|
+
# The time the user will be remembered without asking for credentials again.
|
|
124
|
+
# config.remember_for = 2.weeks
|
|
125
|
+
|
|
126
|
+
# If true, extends the user's remember period when remembered via cookie.
|
|
127
|
+
# config.extend_remember_period = false
|
|
128
|
+
|
|
129
|
+
# Options to be passed to the created cookie. For instance, you can set
|
|
130
|
+
# :secure => true in order to force SSL only cookies.
|
|
131
|
+
# config.rememberable_options = {}
|
|
132
|
+
|
|
133
|
+
# ==> Configuration for :validatable
|
|
134
|
+
# Range for password length. Default is 8..128.
|
|
135
|
+
config.password_length = 8..128
|
|
136
|
+
|
|
137
|
+
# Email regex used to validate email formats. It simply asserts that
|
|
138
|
+
# one (and only one) @ exists in the given string. This is mainly
|
|
139
|
+
# to give user feedback and not to assert the e-mail validity.
|
|
140
|
+
# config.email_regexp = /\A[^@]+@[^@]+\z/
|
|
141
|
+
|
|
142
|
+
# ==> Configuration for :timeoutable
|
|
143
|
+
# The time you want to timeout the user session without activity. After this
|
|
144
|
+
# time the user will be asked for credentials again. Default is 30 minutes.
|
|
145
|
+
# config.timeout_in = 30.minutes
|
|
146
|
+
|
|
147
|
+
# If true, expires auth token on session timeout.
|
|
148
|
+
# config.expire_auth_token_on_timeout = false
|
|
149
|
+
|
|
150
|
+
# ==> Configuration for :lockable
|
|
151
|
+
# Defines which strategy will be used to lock an account.
|
|
152
|
+
# :failed_attempts = Locks an account after a number of failed attempts to sign in.
|
|
153
|
+
# :none = No lock strategy. You should handle locking by yourself.
|
|
154
|
+
# config.lock_strategy = :failed_attempts
|
|
155
|
+
|
|
156
|
+
# Defines which key will be used when locking and unlocking an account
|
|
157
|
+
# config.unlock_keys = [ :email ]
|
|
158
|
+
|
|
159
|
+
# Defines which strategy will be used to unlock an account.
|
|
160
|
+
# :email = Sends an unlock link to the user email
|
|
161
|
+
# :time = Re-enables login after a certain amount of time (see :unlock_in below)
|
|
162
|
+
# :both = Enables both strategies
|
|
163
|
+
# :none = No unlock strategy. You should handle unlocking by yourself.
|
|
164
|
+
# config.unlock_strategy = :both
|
|
165
|
+
|
|
166
|
+
# Number of authentication tries before locking an account if lock_strategy
|
|
167
|
+
# is failed attempts.
|
|
168
|
+
# config.maximum_attempts = 20
|
|
169
|
+
|
|
170
|
+
# Time interval to unlock the account if :time is enabled as unlock_strategy.
|
|
171
|
+
# config.unlock_in = 1.hour
|
|
172
|
+
|
|
173
|
+
# ==> Configuration for :recoverable
|
|
174
|
+
#
|
|
175
|
+
# Defines which key will be used when recovering the password for an account
|
|
176
|
+
# config.reset_password_keys = [ :email ]
|
|
177
|
+
|
|
178
|
+
# Time interval you can reset your password with a reset password key.
|
|
179
|
+
# Don't put a too small interval or your users won't have the time to
|
|
180
|
+
# change their passwords.
|
|
181
|
+
config.reset_password_within = 6.hours
|
|
182
|
+
|
|
183
|
+
# ==> Configuration for :encryptable
|
|
184
|
+
# Allow you to use another encryption algorithm besides bcrypt (default). You can use
|
|
185
|
+
# :sha1, :sha512 or encryptors from others authentication tools as :clearance_sha1,
|
|
186
|
+
# :authlogic_sha512 (then you should set stretches above to 20 for default behavior)
|
|
187
|
+
# and :restful_authentication_sha1 (then you should set stretches to 10, and copy
|
|
188
|
+
# REST_AUTH_SITE_KEY to pepper).
|
|
189
|
+
#
|
|
190
|
+
# Require the `devise-encryptable` gem when using anything other than bcrypt
|
|
191
|
+
# config.encryptor = :sha512
|
|
192
|
+
|
|
193
|
+
# ==> Configuration for :token_authenticatable
|
|
194
|
+
# Defines name of the authentication token params key
|
|
195
|
+
# config.token_authentication_key = :auth_token
|
|
196
|
+
|
|
197
|
+
# ==> Scopes configuration
|
|
198
|
+
# Turn scoped views on. Before rendering "sessions/new", it will first check for
|
|
199
|
+
# "users/sessions/new". It's turned off by default because it's slower if you
|
|
200
|
+
# are using only default views.
|
|
201
|
+
# config.scoped_views = false
|
|
202
|
+
|
|
203
|
+
# Configure the default scope given to Warden. By default it's the first
|
|
204
|
+
# devise role declared in your routes (usually :user).
|
|
205
|
+
# config.default_scope = :user
|
|
206
|
+
|
|
207
|
+
# Set this configuration to false if you want /users/sign_out to sign out
|
|
208
|
+
# only the current scope. By default, Devise signs out all scopes.
|
|
209
|
+
# config.sign_out_all_scopes = true
|
|
210
|
+
|
|
211
|
+
# ==> Navigation configuration
|
|
212
|
+
# Lists the formats that should be treated as navigational. Formats like
|
|
213
|
+
# :html, should redirect to the sign in page when the user does not have
|
|
214
|
+
# access, but formats like :xml or :json, should return 401.
|
|
215
|
+
#
|
|
216
|
+
# If you have any extra navigational formats, like :iphone or :mobile, you
|
|
217
|
+
# should add them to the navigational formats lists.
|
|
218
|
+
#
|
|
219
|
+
# The "*/*" below is required to match Internet Explorer requests.
|
|
220
|
+
# config.navigational_formats = ['*/*', :html]
|
|
221
|
+
|
|
222
|
+
# The default HTTP method used to sign out a resource. Default is :delete.
|
|
223
|
+
config.sign_out_via = :delete
|
|
224
|
+
|
|
225
|
+
# ==> OmniAuth
|
|
226
|
+
# Add a new OmniAuth provider. Check the wiki for more information on setting
|
|
227
|
+
# up on your models and hooks.
|
|
228
|
+
# config.omniauth :github, 'APP_ID', 'APP_SECRET', :scope => 'user,public_repo'
|
|
229
|
+
|
|
230
|
+
# ==> Warden configuration
|
|
231
|
+
# If you want to use other strategies, that are not supported by Devise, or
|
|
232
|
+
# change the failure app, you can configure them inside the config.warden block.
|
|
233
|
+
#
|
|
234
|
+
# config.warden do |manager|
|
|
235
|
+
# manager.intercept_401 = false
|
|
236
|
+
# manager.default_strategies(:scope => :user).unshift :some_external_strategy
|
|
237
|
+
# end
|
|
238
|
+
end
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
Feature: <%= resource.pluralize %> API
|
|
2
|
+
In order to intract with <%= resource.pluralize.underscore %> from dashboard
|
|
3
|
+
<%= resource.pluralize %> API should be accessable by logged in users
|
|
4
|
+
And anonymous user should not have accesss to API
|
|
5
|
+
|
|
6
|
+
Scenario: Anonymous User should not have access to API
|
|
7
|
+
Given I am not authenticated
|
|
8
|
+
And there is a <%= resource.underscore %> named "Iran" in database
|
|
9
|
+
When format is json and I go to the api v1 <%= resource.pluralize.underscore %> page
|
|
10
|
+
Then I should get "401" status code
|
|
11
|
+
When format is json and I go to "/api/v1/<%= resource.pluralize.underscore %>/1"
|
|
12
|
+
Then I should get "401" status code
|
|
13
|
+
When format is json and I send patch to "/api/v1/<%= resource.pluralize.underscore %>/1" with:
|
|
14
|
+
"""
|
|
15
|
+
<%= random_json_data %>
|
|
16
|
+
"""
|
|
17
|
+
Then I should get "401" status code
|
|
18
|
+
When format is json and I send post to "/api/v1/<%= resource.pluralize.underscore %>" with:
|
|
19
|
+
"""
|
|
20
|
+
<%= random_json_data %>
|
|
21
|
+
"""
|
|
22
|
+
Then I should get "401" status code
|
|
23
|
+
When format is json and I send delete to "/api/v1/<%= resource.pluralize.underscore %>/1"
|
|
24
|
+
Then I should get "401" status code
|
|
25
|
+
|
|
26
|
+
Scenario: Default response should be json
|
|
27
|
+
Given I am authenticated
|
|
28
|
+
When I go to the api v1 <%= resource.pluralize.underscore %> page
|
|
29
|
+
Then response type should be application/json
|
|
30
|
+
|
|
31
|
+
Scenario: Anonymous User via HTTP
|
|
32
|
+
Given I am not authenticated
|
|
33
|
+
When format is html and I go to the api v1 <%= resource.pluralize.underscore %> page
|
|
34
|
+
Then I should be in sign in page
|
|
35
|
+
|
|
36
|
+
Scenario: Anonymous USer via JSON format
|
|
37
|
+
Given I am not authenticated
|
|
38
|
+
When format is json and I go to the api v1 <%= resource.pluralize.underscore %> page
|
|
39
|
+
Then I should get "401" status code
|
|
40
|
+
|
|
41
|
+
Scenario: Logged in User via HTTP
|
|
42
|
+
Given I am authenticated
|
|
43
|
+
When format is html and I go to the api v1 <%= resource.pluralize.underscore %> page
|
|
44
|
+
Then I should get unknown format exception
|
|
45
|
+
#Then I should get "406" status code
|
|
46
|
+
|
|
47
|
+
Scenario: Logged in User via JSON format
|
|
48
|
+
Given I am authenticated
|
|
49
|
+
When format is json and I go to the api v1 <%= resource.pluralize.underscore %> page
|
|
50
|
+
Then the JSON should have 0 keys
|
|
51
|
+
|
|
52
|
+
Scenario: Logged in User via JSON format And Initial Data
|
|
53
|
+
Given I am authenticated
|
|
54
|
+
And there is a <%= resource.underscore %> named "XYZ" in database
|
|
55
|
+
When format is json and I go to the api v1 <%= resource.pluralize.underscore %> page
|
|
56
|
+
Then the JSON should have 1 keys
|
|
57
|
+
And the JSON at "0/name" should be "XYZ"
|
|
58
|
+
|
|
59
|
+
Scenario: API should not response to "/new"
|
|
60
|
+
Given I am authenticated
|
|
61
|
+
When format is json and I go to "/api/v1/<%= resource.pluralize.underscore %>/new"
|
|
62
|
+
Then action should not be found
|
|
63
|
+
|
|
64
|
+
@javascript
|
|
65
|
+
Scenario: Add New <%= resource.underscore %>
|
|
66
|
+
Given I am authenticated
|
|
67
|
+
When I go to "/dashboard#/<%= resource.pluralize.underscore %>/new"
|
|
68
|
+
And fill in "name" with "XYZ"
|
|
69
|
+
And click on "save"
|
|
70
|
+
And wait for ajax to return
|
|
71
|
+
Then there should be a <%= resource.underscore %> with "XYZ" as "name"
|
|
72
|
+
|
|
73
|
+
@javascript
|
|
74
|
+
Scenario: Edit <%= resource.underscore %>
|
|
75
|
+
Given I am authenticated
|
|
76
|
+
And there shouldn't be any <%= resource.underscore %>
|
|
77
|
+
And there is a <%= resource.underscore %> named "XYZ" in database
|
|
78
|
+
Then there should be a <%= resource.underscore %> with "XYZ" as "name"
|
|
79
|
+
When I go to "/dashboard#/<%= resource.pluralize.underscore %>/1/edit"
|
|
80
|
+
And fill in "name" with "XYZW"
|
|
81
|
+
Then field "name" contains "XYZW"
|
|
82
|
+
When click on "save"
|
|
83
|
+
And wait for ajax to return
|
|
84
|
+
Then there should be a <%= resource.underscore %> with "XYZW" as "name"
|
|
85
|
+
|
|
86
|
+
Scenario: Delete <%= resource.underscore %>
|
|
87
|
+
Given I am authenticated
|
|
88
|
+
And there is a <%= resource.underscore %> named "ABC" in database
|
|
89
|
+
And there is a <%= resource.underscore %> named "XYZ" in database
|
|
90
|
+
When format is json and I send delete to "/api/v1/<%= resource.pluralize.underscore %>/1,2"
|
|
91
|
+
Then the JSON at "msg" should be "Items removed successfully."
|
|
92
|
+
And there shouldn't be any <%= resource.underscore %>
|
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
# Commonly used email steps
|
|
2
|
+
#
|
|
3
|
+
# To add your own steps make a custom_email_steps.rb
|
|
4
|
+
# The provided methods are:
|
|
5
|
+
#
|
|
6
|
+
# last_email_address
|
|
7
|
+
# reset_mailer
|
|
8
|
+
# open_last_email
|
|
9
|
+
# visit_in_email
|
|
10
|
+
# unread_emails_for
|
|
11
|
+
# mailbox_for
|
|
12
|
+
# current_email
|
|
13
|
+
# open_email
|
|
14
|
+
# read_emails_for
|
|
15
|
+
# find_email
|
|
16
|
+
#
|
|
17
|
+
# General form for email scenarios are:
|
|
18
|
+
# - clear the email queue (done automatically by email_spec)
|
|
19
|
+
# - execute steps that sends an email
|
|
20
|
+
# - check the user received an/no/[0-9] emails
|
|
21
|
+
# - open the email
|
|
22
|
+
# - inspect the email contents
|
|
23
|
+
# - interact with the email (e.g. click links)
|
|
24
|
+
#
|
|
25
|
+
# The Cucumber steps below are setup in this order.
|
|
26
|
+
|
|
27
|
+
module EmailHelpers
|
|
28
|
+
def current_email_address
|
|
29
|
+
# Replace with your a way to find your current email. e.g @current_user.email
|
|
30
|
+
# last_email_address will return the last email address used by email spec to find an email.
|
|
31
|
+
# Note that last_email_address will be reset after each Scenario.
|
|
32
|
+
last_email_address || "example@example.com"
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
World(EmailHelpers)
|
|
37
|
+
|
|
38
|
+
#
|
|
39
|
+
# Reset the e-mail queue within a scenario.
|
|
40
|
+
# This is done automatically before each scenario.
|
|
41
|
+
#
|
|
42
|
+
|
|
43
|
+
Given /^(?:a clear email queue|no emails have been sent)$/ do
|
|
44
|
+
reset_mailer
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
#
|
|
48
|
+
# Check how many emails have been sent/received
|
|
49
|
+
#
|
|
50
|
+
|
|
51
|
+
Then /^(?:I|they|"([^"]*?)") should receive (an|no|\d+) emails?$/ do |address, amount|
|
|
52
|
+
unread_emails_for(address).size.should == parse_email_count(amount)
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
Then /^(?:I|they|"([^"]*?)") should have (an|no|\d+) emails?$/ do |address, amount|
|
|
56
|
+
mailbox_for(address).size.should == parse_email_count(amount)
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
Then /^(?:I|they|"([^"]*?)") should receive (an|no|\d+) emails? with subject "([^"]*?)"$/ do |address, amount, subject|
|
|
60
|
+
unread_emails_for(address).select { |m| m.subject =~ Regexp.new(Regexp.escape(subject)) }.size.should == parse_email_count(amount)
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
Then /^(?:I|they|"([^"]*?)") should receive (an|no|\d+) emails? with subject \/([^"]*?)\/$/ do |address, amount, subject|
|
|
64
|
+
unread_emails_for(address).select { |m| m.subject =~ Regexp.new(subject) }.size.should == parse_email_count(amount)
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
Then /^(?:I|they|"([^"]*?)") should receive an email with the following body:$/ do |address, expected_body|
|
|
68
|
+
open_email(address, :with_text => expected_body)
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
#
|
|
72
|
+
# Accessing emails
|
|
73
|
+
#
|
|
74
|
+
|
|
75
|
+
# Opens the most recently received email
|
|
76
|
+
When /^(?:I|they|"([^"]*?)") opens? the email$/ do |address|
|
|
77
|
+
open_email(address)
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
When /^(?:I|they|"([^"]*?)") opens? the email with subject "([^"]*?)"$/ do |address, subject|
|
|
81
|
+
open_email(address, :with_subject => subject)
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
When /^(?:I|they|"([^"]*?)") opens? the email with subject \/([^"]*?)\/$/ do |address, subject|
|
|
85
|
+
open_email(address, :with_subject => Regexp.new(subject))
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
When /^(?:I|they|"([^"]*?)") opens? the email with text "([^"]*?)"$/ do |address, text|
|
|
89
|
+
open_email(address, :with_text => text)
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
When /^(?:I|they|"([^"]*?)") opens? the email with text \/([^"]*?)\/$/ do |address, text|
|
|
93
|
+
open_email(address, :with_text => Regexp.new(text))
|
|
94
|
+
end
|
|
95
|
+
|
|
96
|
+
#
|
|
97
|
+
# Inspect the Email Contents
|
|
98
|
+
#
|
|
99
|
+
|
|
100
|
+
Then /^(?:I|they) should see "([^"]*?)" in the email subject$/ do |text|
|
|
101
|
+
current_email.should have_subject(text)
|
|
102
|
+
end
|
|
103
|
+
|
|
104
|
+
Then /^(?:I|they) should see \/([^"]*?)\/ in the email subject$/ do |text|
|
|
105
|
+
current_email.should have_subject(Regexp.new(text))
|
|
106
|
+
end
|
|
107
|
+
|
|
108
|
+
Then /^(?:I|they) should see "([^"]*?)" in the email body$/ do |text|
|
|
109
|
+
current_email.default_part_body.to_s.should include(text)
|
|
110
|
+
end
|
|
111
|
+
|
|
112
|
+
Then /^(?:I|they) should see \/([^"]*?)\/ in the email body$/ do |text|
|
|
113
|
+
current_email.default_part_body.to_s.should =~ Regexp.new(text)
|
|
114
|
+
end
|
|
115
|
+
|
|
116
|
+
Then /^(?:I|they) should see the email delivered from "([^"]*?)"$/ do |text|
|
|
117
|
+
current_email.should be_delivered_from(text)
|
|
118
|
+
end
|
|
119
|
+
|
|
120
|
+
Then /^(?:I|they) should see "([^\"]*)" in the email "([^"]*?)" header$/ do |text, name|
|
|
121
|
+
current_email.should have_header(name, text)
|
|
122
|
+
end
|
|
123
|
+
|
|
124
|
+
Then /^(?:I|they) should see \/([^\"]*)\/ in the email "([^"]*?)" header$/ do |text, name|
|
|
125
|
+
current_email.should have_header(name, Regexp.new(text))
|
|
126
|
+
end
|
|
127
|
+
|
|
128
|
+
Then /^I should see it is a multi\-part email$/ do
|
|
129
|
+
current_email.should be_multipart
|
|
130
|
+
end
|
|
131
|
+
|
|
132
|
+
Then /^(?:I|they) should see "([^"]*?)" in the email html part body$/ do |text|
|
|
133
|
+
current_email.html_part.body.to_s.should include(text)
|
|
134
|
+
end
|
|
135
|
+
|
|
136
|
+
Then /^(?:I|they) should see "([^"]*?)" in the email text part body$/ do |text|
|
|
137
|
+
current_email.text_part.body.to_s.should include(text)
|
|
138
|
+
end
|
|
139
|
+
|
|
140
|
+
#
|
|
141
|
+
# Inspect the Email Attachments
|
|
142
|
+
#
|
|
143
|
+
|
|
144
|
+
Then /^(?:I|they) should see (an|no|\d+) attachments? with the email$/ do |amount|
|
|
145
|
+
current_email_attachments.size.should == parse_email_count(amount)
|
|
146
|
+
end
|
|
147
|
+
|
|
148
|
+
Then /^there should be (an|no|\d+) attachments? named "([^"]*?)"$/ do |amount, filename|
|
|
149
|
+
current_email_attachments.select { |a| a.filename == filename }.size.should == parse_email_count(amount)
|
|
150
|
+
end
|
|
151
|
+
|
|
152
|
+
Then /^attachment (\d+) should be named "([^"]*?)"$/ do |index, filename|
|
|
153
|
+
current_email_attachments[(index.to_i - 1)].filename.should == filename
|
|
154
|
+
end
|
|
155
|
+
|
|
156
|
+
Then /^there should be (an|no|\d+) attachments? of type "([^"]*?)"$/ do |amount, content_type|
|
|
157
|
+
current_email_attachments.select { |a| a.content_type.include?(content_type) }.size.should == parse_email_count(amount)
|
|
158
|
+
end
|
|
159
|
+
|
|
160
|
+
Then /^attachment (\d+) should be of type "([^"]*?)"$/ do |index, content_type|
|
|
161
|
+
current_email_attachments[(index.to_i - 1)].content_type.should include(content_type)
|
|
162
|
+
end
|
|
163
|
+
|
|
164
|
+
Then /^all attachments should not be blank$/ do
|
|
165
|
+
current_email_attachments.each do |attachment|
|
|
166
|
+
attachment.read.size.should_not == 0
|
|
167
|
+
end
|
|
168
|
+
end
|
|
169
|
+
|
|
170
|
+
Then /^show me a list of email attachments$/ do
|
|
171
|
+
EmailSpec::EmailViewer::save_and_open_email_attachments_list(current_email)
|
|
172
|
+
end
|
|
173
|
+
|
|
174
|
+
#
|
|
175
|
+
# Interact with Email Contents
|
|
176
|
+
#
|
|
177
|
+
|
|
178
|
+
When /^(?:I|they|"([^"]*?)") follows? "([^"]*?)" in the email$/ do |address, link|
|
|
179
|
+
visit_in_email(link, address)
|
|
180
|
+
end
|
|
181
|
+
|
|
182
|
+
When /^(?:I|they) click the first link in the email$/ do
|
|
183
|
+
click_first_link_in_email
|
|
184
|
+
end
|
|
185
|
+
|
|
186
|
+
#
|
|
187
|
+
# Debugging
|
|
188
|
+
# These only work with Rails and OSx ATM since EmailViewer uses RAILS_ROOT and OSx's 'open' command.
|
|
189
|
+
# Patches accepted. ;)
|
|
190
|
+
#
|
|
191
|
+
|
|
192
|
+
Then /^save and open current email$/ do
|
|
193
|
+
EmailSpec::EmailViewer::save_and_open_email(current_email)
|
|
194
|
+
end
|
|
195
|
+
|
|
196
|
+
Then /^save and open all text emails$/ do
|
|
197
|
+
EmailSpec::EmailViewer::save_and_open_all_text_emails
|
|
198
|
+
end
|
|
199
|
+
|
|
200
|
+
Then /^save and open all html emails$/ do
|
|
201
|
+
EmailSpec::EmailViewer::save_and_open_all_html_emails
|
|
202
|
+
end
|
|
203
|
+
|
|
204
|
+
Then /^save and open all raw emails$/ do
|
|
205
|
+
EmailSpec::EmailViewer::save_and_open_all_raw_emails
|
|
206
|
+
end
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
require 'email_spec/cucumber'
|
|
@@ -0,0 +1,79 @@
|
|
|
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
|
+
require 'cucumber/rails'
|
|
8
|
+
require 'capybara/rails'
|
|
9
|
+
require 'capybara/cucumber'
|
|
10
|
+
require 'capybara/session'
|
|
11
|
+
require "json_spec/cucumber"
|
|
12
|
+
require "red_base/cucumber"
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
def last_json
|
|
16
|
+
page.source
|
|
17
|
+
end
|
|
18
|
+
# Capybara defaults to CSS3 selectors rather than XPath.
|
|
19
|
+
# If you'd prefer to use XPath, just uncomment this line and adjust any
|
|
20
|
+
# selectors in your step definitions to use the XPath syntax.
|
|
21
|
+
# Capybara.default_selector = :xpath
|
|
22
|
+
|
|
23
|
+
# By default, any exception happening in your Rails application will bubble up
|
|
24
|
+
# to Cucumber so that your scenario will fail. This is a different from how
|
|
25
|
+
# your application behaves in the production environment, where an error page will
|
|
26
|
+
# be rendered instead.
|
|
27
|
+
#
|
|
28
|
+
# Sometimes we want to override this default behaviour and allow Rails to rescue
|
|
29
|
+
# exceptions and display an error page (just like when the app is running in production).
|
|
30
|
+
# Typical scenarios where you want to do this is when you test your error pages.
|
|
31
|
+
# There are two ways to allow Rails to rescue exceptions:
|
|
32
|
+
#
|
|
33
|
+
# 1) Tag your scenario (or feature) with @allow-rescue
|
|
34
|
+
#
|
|
35
|
+
# 2) Set the value below to true. Beware that doing this globally is not
|
|
36
|
+
# recommended as it will mask a lot of errors for you!
|
|
37
|
+
#
|
|
38
|
+
ActionController::Base.allow_rescue = false
|
|
39
|
+
|
|
40
|
+
# Remove/comment out the lines below if your app doesn't have a database.
|
|
41
|
+
# For some databases (like MongoDB and CouchDB) you may need to use :truncation instead.
|
|
42
|
+
|
|
43
|
+
begin
|
|
44
|
+
require 'database_cleaner'
|
|
45
|
+
require 'database_cleaner/cucumber'
|
|
46
|
+
|
|
47
|
+
DatabaseCleaner.strategy = :transaction
|
|
48
|
+
rescue NameError
|
|
49
|
+
raise "You need to add database_cleaner to your Gemfile (in the :test group) if you wish to use it."
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
Before do
|
|
53
|
+
DatabaseCleaner.start
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
After do |scenario|
|
|
57
|
+
DatabaseCleaner.clean
|
|
58
|
+
end
|
|
59
|
+
# You may also want to configure DatabaseCleaner to use different strategies for certain features and scenarios.
|
|
60
|
+
# See the DatabaseCleaner documentation for details. Example:
|
|
61
|
+
#
|
|
62
|
+
Before('@no-txn,@selenium,@culerity,@celerity,@javascript') do
|
|
63
|
+
# # { :except => [:widgets] } may not do what you expect here
|
|
64
|
+
# # as Cucumber::Rails::Database.javascript_strategy overrides
|
|
65
|
+
# # this setting.
|
|
66
|
+
DatabaseCleaner.strategy = :truncation
|
|
67
|
+
end
|
|
68
|
+
#
|
|
69
|
+
Before('~@no-txn', '~@selenium', '~@culerity', '~@celerity', '~@javascript') do
|
|
70
|
+
DatabaseCleaner.strategy = :transaction
|
|
71
|
+
end
|
|
72
|
+
#
|
|
73
|
+
|
|
74
|
+
# Possible values are :truncation and :transaction
|
|
75
|
+
# The :transaction strategy is faster, but might give you threading problems.
|
|
76
|
+
# See https://github.com/cucumber/cucumber-rails/blob/master/features/choose_javascript_database_strategy.feature
|
|
77
|
+
Cucumber::Rails::Database.javascript_strategy = :truncation
|
|
78
|
+
#Capybara.default_driver = :webkit
|
|
79
|
+
Capybara.javascript_driver = :webkit
|