faalis 0.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/LICENSE +339 -0
- data/README.md +45 -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/images/faalis/select2-spinner.gif +0 -0
- data/app/assets/images/faalis/select2.png +0 -0
- data/app/assets/images/faalis/select2x2.png +0 -0
- data/app/assets/javascripts/faalis/application.js +20 -0
- data/app/assets/javascripts/faalis/dashboard/angular.js +9 -0
- data/app/assets/javascripts/faalis/dashboard/app.js +75 -0
- data/app/assets/javascripts/faalis/dashboard/application.js.erb +21 -0
- data/app/assets/javascripts/faalis/dashboard/functions.js.erb +91 -0
- data/app/assets/javascripts/faalis/dashboard/init.js +38 -0
- data/app/assets/javascripts/faalis/dashboard/lib/angular-animate.js +1226 -0
- data/app/assets/javascripts/faalis/dashboard/lib/angular-gettext.js +202 -0
- data/app/assets/javascripts/faalis/dashboard/lib/angular-resource.js +578 -0
- data/app/assets/javascripts/faalis/dashboard/lib/angular-route.js +880 -0
- data/app/assets/javascripts/faalis/dashboard/lib/angular.js +20031 -0
- data/app/assets/javascripts/faalis/dashboard/lib/lodash.underscore.js +4893 -0
- data/app/assets/javascripts/faalis/dashboard/lib/ng-grid.js +3260 -0
- data/app/assets/javascripts/faalis/dashboard/lib/ng-quick-date.js +297 -0
- data/app/assets/javascripts/faalis/dashboard/lib/restangular.js +1066 -0
- data/app/assets/javascripts/faalis/dashboard/lib/select2.js +3255 -0
- data/app/assets/javascripts/faalis/dashboard/lib/ui.select2.js +217 -0
- data/app/assets/javascripts/faalis/dashboard/locale/translations.js +5 -0
- data/app/assets/javascripts/faalis/dashboard/modules/anim.js +32 -0
- data/app/assets/javascripts/faalis/dashboard/modules/api.js +32 -0
- data/app/assets/javascripts/faalis/dashboard/modules/auth/auth.js +34 -0
- data/app/assets/javascripts/faalis/dashboard/modules/auth/group.js +174 -0
- data/app/assets/javascripts/faalis/dashboard/modules/auth/profile.js +59 -0
- data/app/assets/javascripts/faalis/dashboard/modules/auth/user.js +123 -0
- data/app/assets/javascripts/faalis/dashboard/modules/errors.js +47 -0
- data/app/assets/javascripts/faalis/dashboard/modules/filter.js +44 -0
- data/app/assets/javascripts/faalis/dashboard/modules/list-view.js +310 -0
- data/app/assets/javascripts/faalis/dashboard/modules/logs.js +41 -0
- data/app/assets/javascripts/faalis/dashboard/modules/modules.js +50 -0
- data/app/assets/javascripts/faalis/dashboard/modules/nav.js.erb +97 -0
- data/app/assets/javascripts/faalis/dashboard/templates/application.handlebars.erb +42 -0
- data/app/assets/javascripts/faalis/dashboard/templates/auth/groups/details.handlebars.erb +15 -0
- data/app/assets/javascripts/faalis/dashboard/templates/auth/groups/index.handlebars.erb +7 -0
- data/app/assets/javascripts/faalis/dashboard/templates/auth/groups/new.handlebars.erb +39 -0
- data/app/assets/javascripts/faalis/dashboard/templates/auth/index.handlebars.erb +31 -0
- data/app/assets/javascripts/faalis/dashboard/templates/auth/users/details.handlebars.erb +15 -0
- data/app/assets/javascripts/faalis/dashboard/templates/auth/users/index.handlebars.erb +11 -0
- data/app/assets/javascripts/faalis/dashboard/templates/auth/users/new.handlebars.erb +33 -0
- data/app/assets/javascripts/faalis/dashboard/templates/components/list-view.handlebars.erb +59 -0
- data/app/assets/javascripts/faalis/dashboard/templates/components/model-form.handlebars.erb +3 -0
- data/app/assets/javascripts/faalis/dashboard/templates/modules.handlebars.erb +15 -0
- data/app/assets/javascripts/faalis/dashboard/templates/navigation.handlebars.erb +43 -0
- data/app/assets/javascripts/faalis/dashboard/templates/widgets.handlebars +23 -0
- data/app/assets/javascripts/faalis/dashboard/variables.js.erb +17 -0
- data/app/assets/javascripts/faalis/groups.js +2 -0
- data/app/assets/javascripts/faalis/home.js +2 -0
- data/app/assets/javascripts/faalis/i18n.js +13 -0
- data/app/assets/javascripts/faalis/locale/en.json +27 -0
- data/app/assets/javascripts/faalis/locale/fa.json +27 -0
- data/app/assets/javascripts/faalis/users.js +2 -0
- data/app/assets/stylesheets/faalis/base.css.scss +264 -0
- data/app/assets/stylesheets/faalis/dashboard/dashboard.css.scss +226 -0
- data/app/assets/stylesheets/faalis/dashboard/list_view.css.scss +169 -0
- data/app/assets/stylesheets/faalis/dashboard/ltr/application.css +26 -0
- data/app/assets/stylesheets/faalis/dashboard/ltr/base.css.scss.erb +28 -0
- data/app/assets/stylesheets/faalis/dashboard/ltr/buttons.css.scss.erb +48 -0
- data/app/assets/stylesheets/faalis/dashboard/ltr/direction.css.scss +38 -0
- data/app/assets/stylesheets/faalis/dashboard/ltr/foundation_and_overrides.css.scss +1014 -0
- data/app/assets/stylesheets/faalis/dashboard/ng-grid.css.scss +442 -0
- data/app/assets/stylesheets/faalis/dashboard/ng-quick-date-default-theme.css.scss +20 -0
- data/app/assets/stylesheets/faalis/dashboard/ng-quick-date.css.scss +19 -0
- data/app/assets/stylesheets/faalis/dashboard/rtl/application.css +26 -0
- data/app/assets/stylesheets/faalis/dashboard/rtl/base.css.scss.erb +31 -0
- data/app/assets/stylesheets/faalis/dashboard/rtl/base.css_flymake.scss +25 -0
- data/app/assets/stylesheets/faalis/dashboard/rtl/buttons.css.scss.erb +45 -0
- data/app/assets/stylesheets/faalis/dashboard/rtl/direction.css.scss +37 -0
- data/app/assets/stylesheets/faalis/dashboard/rtl/foundation_and_overrides.css.scss +1014 -0
- data/app/assets/stylesheets/faalis/dashboard/select2.css.scss.erb +618 -0
- data/app/assets/stylesheets/faalis/dashboard/sidebar.css.scss +93 -0
- data/app/assets/stylesheets/faalis/devise.css.scss +34 -0
- data/app/assets/stylesheets/faalis/groups.css +4 -0
- data/app/assets/stylesheets/faalis/home.css.scss +14 -0
- data/app/assets/stylesheets/faalis/ltr/application.css +20 -0
- data/app/assets/stylesheets/faalis/ltr/buttons.css.scss.erb +48 -0
- data/app/assets/stylesheets/faalis/ltr/foundation_and_overrides.scss.erb +1012 -0
- data/app/assets/stylesheets/faalis/mixins.css.scss +15 -0
- data/app/assets/stylesheets/faalis/rtl/application.css +20 -0
- data/app/assets/stylesheets/faalis/rtl/buttons.css.scss.erb +48 -0
- data/app/assets/stylesheets/faalis/rtl/foundation_and_overrides.scss.erb +1012 -0
- data/app/assets/stylesheets/faalis/users.css +4 -0
- data/app/assets/stylesheets/faalis/variables.css.scss +102 -0
- data/app/controllers/faalis/api/v1/groups_controller.rb +75 -0
- data/app/controllers/faalis/api/v1/logs_controller.rb +12 -0
- data/app/controllers/faalis/api/v1/permissions_controller.rb +17 -0
- data/app/controllers/faalis/api/v1/profiles_controller.rb +42 -0
- data/app/controllers/faalis/api/v1/users_controller.rb +75 -0
- data/app/controllers/faalis/api_controller.rb +51 -0
- data/app/controllers/faalis/application_controller.rb +34 -0
- data/app/controllers/faalis/dashboard_controller.rb +44 -0
- data/app/controllers/faalis/home_controller.rb +19 -0
- data/app/controllers/faalis/omniauth/callbacks_controller.rb +43 -0
- data/app/helpers/faalis/application_helper.rb +4 -0
- data/app/helpers/faalis/dashboard_helper.rb +5 -0
- data/app/helpers/faalis/groups_helper.rb +4 -0
- data/app/helpers/faalis/home_helper.rb +4 -0
- data/app/helpers/faalis/users_helper.rb +4 -0
- data/app/models/ability.rb +42 -0
- data/app/models/faalis/group.rb +27 -0
- data/app/models/faalis/permission.rb +15 -0
- data/app/models/faalis/user.rb +81 -0
- data/app/views/angularjs_templates/#index.html# +8 -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 +41 -0
- data/app/views/angularjs_templates/auth/index.html +30 -0
- data/app/views/angularjs_templates/auth/profile/edit.html +54 -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 +56 -0
- data/app/views/angularjs_templates/filter/index.html +15 -0
- data/app/views/angularjs_templates/index.html +8 -0
- data/app/views/angularjs_templates/list-view/index.html +81 -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/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/faalis/api/v1/groups/create.json.jbuilder +4 -0
- data/app/views/faalis/api/v1/groups/destroy.html.erb +2 -0
- data/app/views/faalis/api/v1/groups/destroy.json.jbuilder +1 -0
- data/app/views/faalis/api/v1/groups/edit.html.erb +2 -0
- data/app/views/faalis/api/v1/groups/index.html.erb +2 -0
- data/app/views/faalis/api/v1/groups/index.json.jbuilder +6 -0
- data/app/views/faalis/api/v1/groups/new.html.erb +2 -0
- data/app/views/faalis/api/v1/groups/show.html.erb +2 -0
- data/app/views/faalis/api/v1/groups/show.json.jbuilder +5 -0
- data/app/views/faalis/api/v1/groups/update.json.jbuilder +4 -0
- data/app/views/faalis/api/v1/logs/index.json.jbuilder +1 -0
- data/app/views/faalis/api/v1/permissions/index.json.jbuilder +1 -0
- data/app/views/faalis/api/v1/users/create.html.erb +2 -0
- data/app/views/faalis/api/v1/users/create.json.jbuilder +1 -0
- data/app/views/faalis/api/v1/users/destroy.json.jbuilder +1 -0
- data/app/views/faalis/api/v1/users/distroy.html.erb +2 -0
- data/app/views/faalis/api/v1/users/edit.html.erb +2 -0
- data/app/views/faalis/api/v1/users/index.html.erb +2 -0
- data/app/views/faalis/api/v1/users/index.json.jbuilder +4 -0
- data/app/views/faalis/api/v1/users/show.html.erb +2 -0
- data/app/views/faalis/api/v1/users/show.json.jbuilder +2 -0
- data/app/views/faalis/api/v1/users/update.json.jbuilder +1 -0
- data/app/views/faalis/dashboard/index.html.erb +37 -0
- data/app/views/faalis/dashboard/login_required_page.html.erb +5 -0
- data/app/views/faalis/home/index.html.erb +119 -0
- data/app/views/layouts/faalis/application.html.erb +90 -0
- data/app/views/layouts/faalis/dashboard.html.erb +21 -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/faalis.mo +0 -0
- data/config/locales/fa/faalis.po +181 -0
- data/config/locales/fa/messages.mo +0 -0
- data/config/locales/faalis.pot +181 -0
- data/config/routes.rb +36 -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/faalis.rb +30 -0
- data/lib/faalis/active_record.rb +64 -0
- data/lib/faalis/api.rb +61 -0
- data/lib/faalis/api/groups_api.rb +41 -0
- data/lib/faalis/api/permissions_api.rb +24 -0
- data/lib/faalis/api/root.rb +15 -0
- data/lib/faalis/api/users_api.rb +20 -0
- data/lib/faalis/cucumber.rb +25 -0
- data/lib/faalis/cucumber/auth.rb +45 -0
- data/lib/faalis/cucumber/exceptions.rb +40 -0
- data/lib/faalis/cucumber/interaction.rb +43 -0
- data/lib/faalis/cucumber/query.rb +28 -0
- data/lib/faalis/cucumber/urls.rb +76 -0
- data/lib/faalis/dashboard.rb +60 -0
- data/lib/faalis/dashboard/controller.rb +42 -0
- data/lib/faalis/dashboard/module.rb +45 -0
- data/lib/faalis/engine.rb +128 -0
- data/lib/faalis/exceptions.rb +26 -0
- data/lib/faalis/i18n.rb +35 -0
- data/lib/faalis/initialize.rb +7 -0
- data/lib/faalis/omniauth.rb +24 -0
- data/lib/faalis/omniauth/callbacks.rb +58 -0
- data/lib/faalis/plugins.rb +44 -0
- data/lib/faalis/version.rb +22 -0
- data/lib/faalis_plugin.rb +476 -0
- data/lib/generators/faalis/USAGE +8 -0
- data/lib/generators/faalis/angularjs_resource_generator.rb +74 -0
- data/lib/generators/faalis/install_all_generator.rb +38 -0
- data/lib/generators/faalis/install_generator.rb +42 -0
- data/lib/generators/faalis/install_specs_generator.rb +48 -0
- data/lib/generators/faalis/js_scaffold_generator.rb +273 -0
- data/lib/generators/faalis/templates/README +41 -0
- data/lib/generators/faalis/templates/SPECS +13 -0
- data/lib/generators/faalis/templates/angularjs/details.html.erb +20 -0
- data/lib/generators/faalis/templates/angularjs/index.html.erb +62 -0
- data/lib/generators/faalis/templates/angularjs/module.js.erb +309 -0
- data/lib/generators/faalis/templates/angularjs/new.html.erb +105 -0
- data/lib/generators/faalis/templates/api/controller.rb.erb +56 -0
- data/lib/generators/faalis/templates/devise.rb +251 -0
- data/lib/generators/faalis/templates/faalis.rb +14 -0
- data/lib/generators/faalis/templates/fast_gettext.rb +4 -0
- data/lib/generators/faalis/templates/features/api.feature +92 -0
- data/lib/generators/faalis/templates/features/api.step.rb +7 -0
- data/lib/generators/faalis/templates/features/step_definitions/email_steps.rb +206 -0
- data/lib/generators/faalis/templates/features/support/email_spec.rb +1 -0
- data/lib/generators/faalis/templates/features/support/env.rb +79 -0
- data/lib/generators/faalis/templates/formtastic.rb +76 -0
- data/lib/generators/faalis/templates/js_scaffold.README +25 -0
- data/lib/generators/faalis/templates/seeds.rb +1 -0
- data/lib/generators/faalis/templates/spec/factories/groups.rb +5 -0
- data/lib/generators/faalis/templates/spec/factories/users.rb +10 -0
- data/lib/generators/faalis/templates/spec/spec_helper.rb +69 -0
- data/lib/generators/faalis/templates/spec/support/devise.rb +3 -0
- data/lib/generators/faalis/templates/views/create.json.jbuilder.erb +2 -0
- data/lib/generators/faalis/templates/views/destroy.json.jbuilder.erb +1 -0
- data/lib/generators/faalis/templates/views/index.json.jbuilder.erb +10 -0
- data/lib/generators/faalis/templates/views/show.json.jbuilder.erb +7 -0
- data/lib/generators/faalis/templates/views/update.json.jbuilder.erb +6 -0
- data/lib/generators/faalis/views_generator.rb +41 -0
- data/lib/tasks/faalis_tasks.rake +23 -0
- data/lib/tasks/grunt/Gruntfile.js +25 -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.ru +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/db/test.sqlite3 +0 -0
- data/spec/dummy/log/development.log +0 -0
- data/spec/dummy/log/test.log +15 -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/dummy/tmp/ember-rails/ember-data.js +10204 -0
- data/spec/dummy/tmp/ember-rails/ember.js +36991 -0
- data/spec/spec_helper.rb +52 -0
- metadata +678 -0
@@ -0,0 +1,105 @@
|
|
1
|
+
<% if any_tabs? %><section class="tabs"><% tab_count = 1 %>
|
2
|
+
<ul><% tabs.each do |name, fields| %>
|
3
|
+
<li ng-click="activate_tab(<%= tab_count %>)" ng-class="{active: current_tab == <%= tab_count %>, tab<%= tab_count %>: current_tab == <%= tab_count %>}"><span translate><%= name %></span></li> |<% tab_count += 1 %>
|
4
|
+
<% end %></ul>
|
5
|
+
</section><% end %>
|
6
|
+
<% unless any_tabs? %>
|
7
|
+
<form novalidate name="form">
|
8
|
+
<div class="newform">
|
9
|
+
<fieldset class="form">
|
10
|
+
|
11
|
+
<legend ng-if="!editing"><span translate>New <%= resource.underscore.pluralize.humanize %></span></legend>
|
12
|
+
<legend ng-if="editing"><span translate>Edit <%= resource.underscore.pluralize.humanize %></span></legend>
|
13
|
+
|
14
|
+
<% first = true %>
|
15
|
+
<% fields.each do |field_name, field_type| %>
|
16
|
+
<% if first %><div class="row"><% end %>
|
17
|
+
<div class="small-4 columns <% if not first %>float-left small-offset-2<% end %>">
|
18
|
+
<label><% if required_fields.include? field_name %><i class="inline fa fa-asterisk"></i> <% end %><span translate><%= field_name.to_s.humanize.capitalize %></span> :</label>
|
19
|
+
<% case field_type
|
20
|
+
when "belongs_to" %>
|
21
|
+
<select ui-select2="select2options" id="id_<%= field_name %>" ng-model="<%= field_name %>" name="<%= field_name %>" <% if required_fields.include? field_name %>required<% end %>>
|
22
|
+
<option ng-repeat="item in all_<%= field_type.resource_name %>" value="{{ item.id }}" title="{{ item.name || item }}" ng-selected="item.id === <%= field_name %>.id">{{ item.name || item }}</option>
|
23
|
+
</select>
|
24
|
+
<% when "has_many" %>
|
25
|
+
<select ui-select2="select2options" ng-model="<%= field_name %>" id="id_<%= field_name %>" name="<%= field_name %>" multiple <% if required_fields.include? field_name %>required<% end %>>
|
26
|
+
<option ng-repeat="item in all_<%= field_type.resource_name %>" value="{{ item.id }}" title="{{ item.name || item }}" ng-selected="have('<%= field_name %>', item.id)">{{ item.name || item }}</option>
|
27
|
+
</select>
|
28
|
+
<% when "in" %>
|
29
|
+
<select id="id_<%= field_name %>" ui-select2="select2options" ng-model="<%= field_name %>" name="<%= field_name %>" <% if required_fields.include? field_name %>required<% end %>>
|
30
|
+
<option ng-repeat="item in <%= field_name %>_choices" value="{{ item.name }}" title="{{ item.title }}" ng-selected="<%= field_name %> === item.name">{{ item.title }}</option>
|
31
|
+
</select>
|
32
|
+
<% when "text" %>
|
33
|
+
<textarea id="id_<%= field_name %>" class="rounded" ng-model="<%= field_name %>" name="<%= field_name %>" <% if required_fields.include? field_name %>required<% end %>></textarea>
|
34
|
+
<% when "boolean" %>
|
35
|
+
<input id="id_<%= field_name %>" ng-model="<%= field_name %>" type="checkbox" name="<%= field_name %>" class="rounded <%= field_type %>_field" <% if required_fields.include? field_name %>required<% end %> />
|
36
|
+
<% when "datetime" %>
|
37
|
+
<datepicker id="id_<%= field_name %>" ng-model="<%= field_name %>" class="datetime_field" name="<%= field_name %>" placeholder="{{ 'Click to pick a date' | translate }}" <% if required_fields.include? field_name %>required<% end %> />
|
38
|
+
<% when "string", nil %>
|
39
|
+
<input id="id_<%= field_name %>" ng-model="<%= field_name %>" name="<%= field_name %>" type="text" class="rounded <%= field_type %>_field" <% if required_fields.include? field_name %>required<% end %> />
|
40
|
+
<% else %>
|
41
|
+
<input id="id_<%= field_name %>" ng-model="<%= field_name %>" type="<%= field_type %>" name="<%= field_name %>" class="rounded <%= field_type %>_field" <% if required_fields.include? field_name %>required<% end %> />
|
42
|
+
<% end %>
|
43
|
+
<small id="id_<%= field_name %>_msg"></small>
|
44
|
+
</div>
|
45
|
+
<% if not first %></div><% end %>
|
46
|
+
<% first = !first %>
|
47
|
+
<% end %>
|
48
|
+
</fieldset>
|
49
|
+
</form>
|
50
|
+
|
51
|
+
|
52
|
+
|
53
|
+
<% else %><% tab_count = 1 %><% tabs.each do |name, field_names| %>
|
54
|
+
<form novalidate name="form">
|
55
|
+
<div class="newform">
|
56
|
+
<fieldset class="form" ng-if="current_tab == <%= tab_count %>">
|
57
|
+
<legend ng-if="!editing"><span translate>New <%= name %></span></legend>
|
58
|
+
<legend ng-if="editing"><span translate>Edit <%= name %></span></legend><% first = true %>
|
59
|
+
<% fields.each do |field_name, field_type| %><% if tabs[name].include? field_name or tabs[name].include? "__all__" %>
|
60
|
+
<% if first %><div class="row"><% end %>
|
61
|
+
<div class="small-4 columns <% if not first %>float-left small-offset-2<% end %>">
|
62
|
+
<label><% if required_fields.include? field_name %><i class="inline fa fa-asterisk"></i> <% end %><span translate><%= field_name.to_s.humanize.capitalize %></span> :</label>
|
63
|
+
<% case field_type
|
64
|
+
when "belongs_to" %>
|
65
|
+
<select ui-select2="select2options" id="id_<%= field_name %>" ng-model="<%= field_name %>" name="<%= field_name %>" <% if required_fields.include? field_name %>required<% end %>>
|
66
|
+
<option ng-repeat="item in all_<%= field_type.resource_name %>" value="{{ item.id }}" title="{{ item.name || item }}" ng-selected="item.id === <%= field_name %>.id">{{ item.name || item }}</option>
|
67
|
+
</select>
|
68
|
+
<% when "has_many" %>
|
69
|
+
<select ui-select2="select2options" ng-model="<%= field_name %>" id="id_<%= field_name %>" name="<%= field_name %>" multiple <% if required_fields.include? field_name %>required<% end %>>
|
70
|
+
<option ng-repeat="item in all_<%= field_type.resource_name %>" value="{{ item.id }}" title="{{ item.name || item }}" ng-selected="have('<%= field_name %>', item.id)">{{ item.name || item }}</option>
|
71
|
+
</select>
|
72
|
+
<% when "in" %>
|
73
|
+
<select ui-select2="select2options" id="id_<%= field_name %>" ng-model="<%= field_name %>" name="<%= field_name %>" <% if required_fields.include? field_name %>required<% end %>>
|
74
|
+
<option ng-repeat="item in <%= field_name %>_choices" value="{{ item.name }}" title="{{ item.title }}" ng-selected="<%= field_name %> === item.name">{{ item.title }}</option>
|
75
|
+
</select>
|
76
|
+
<% when "text" %>
|
77
|
+
<textarea id="id_<%= field_name %>" ng-model="<%= field_name %>" class="rounded" name="<%= field_name %>" <% if required_fields.include? field_name %>required<% end %>></textarea>
|
78
|
+
<% when "boolean" %>
|
79
|
+
<input id="id_<%= field_name %>" ng-model="<%= field_name %>" type="checkbox" name="<%= field_name %>" class="rounded <%= field_type %>_field" <% if required_fields.include? field_name %>required<% end %> />
|
80
|
+
<% when "datetime" %>
|
81
|
+
<datepicker id="id_<%= field_name %>" ng-model="<%= field_name %>" class="datetime_field" name="<%= field_name %>" placeholder="{{ 'Click to pick a date' | translate }}" <% if required_fields.include? field_name %>required<% end %> />
|
82
|
+
<% when "string", nil %>
|
83
|
+
<input id="id_<%= field_name %>" ng-model="<%= field_name %>" name="<%= field_name %>" type="text" class="rounded <%= field_type %>_field" <% if required_fields.include? field_name %>required<% end %> />
|
84
|
+
<% else %>
|
85
|
+
<input id="id_<%= field_name %>" ng-model="<%= field_name %>" type="<%= field_type %>" name="<%= field_name %>" class="rounded <%= field_type %>_field" <% if required_fields.include? field_name %>required<% end %> />
|
86
|
+
<% end %>
|
87
|
+
<small id="id_<%= field_name %>_msg"></small>
|
88
|
+
</div>
|
89
|
+
<% if not first %></div><% end %>
|
90
|
+
<% first = !first %>
|
91
|
+
<% end %>
|
92
|
+
<% end %>
|
93
|
+
</fieldset><% tab_count += 1 %>
|
94
|
+
<% end %>
|
95
|
+
</form>
|
96
|
+
<% end %>
|
97
|
+
|
98
|
+
<div class="row">
|
99
|
+
<div class="small-6 columns">
|
100
|
+
<button class="btn small green" ng-click="save(false)" ng-disabled="form.$invalid || !form.$dirty"><i class="fa fa-check"></i> <span translate>Save</span></button>
|
101
|
+
<button class="btn small blue" ng-click="save(true)" ng-disabled="form.$invalid || !form.$dirty"><i class="fa fa-check"></i> <span translate>Save & Add Another</span></button>
|
102
|
+
<button class="btn small red" ng-click="cancel()"><i class="fa fa-times"></i> <span translate>Cancel</span></button>
|
103
|
+
</div>
|
104
|
+
</div>
|
105
|
+
</div>
|
@@ -0,0 +1,56 @@
|
|
1
|
+
class API::V1::<%= resource.pluralize %>Controller < Faalis::APIController
|
2
|
+
before_filter :build_resource, :only => :create
|
3
|
+
load_and_authorize_resource :except => [:destory]
|
4
|
+
|
5
|
+
# GET /api/v1/<%= resource.pluralize.underscore %>
|
6
|
+
def index
|
7
|
+
respond_with(@<%= resource.pluralize.underscore %>)
|
8
|
+
end
|
9
|
+
|
10
|
+
def create
|
11
|
+
<% fields.each do |name, type| %><% if type == "has_many" %>
|
12
|
+
<%= name.underscore %> = <%= name.singularize.camelize %>.where({:id => params[:<%= resource.underscore %>][:<%= name %>]})
|
13
|
+
@<%= resource.underscore %>.<%= name.underscore %> = <%= name.underscore %><% end %><% end %>
|
14
|
+
if @<%= resource.underscore %>.save
|
15
|
+
respond_with(@<%= resource.underscore %>)
|
16
|
+
else
|
17
|
+
respond_to do |format|
|
18
|
+
format.json { render :json => {:fields => @<%= resource.underscore %>.errors}, :status => :unprocessable_entity }
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
def show
|
24
|
+
respond_with(@<%= resource.underscore %>)
|
25
|
+
end
|
26
|
+
|
27
|
+
def update
|
28
|
+
<% fields.each do |name, type| %><% if type == "has_many" %>
|
29
|
+
<%= name.underscore %> = <%= name.singularize.camelize %>.where({:id => params[:<%= resource.underscore %>][:<%= name %>]})
|
30
|
+
@<%= resource.underscore %>.<%= name.underscore %> = <%= name.underscore %><% end %><% end %>
|
31
|
+
|
32
|
+
if @<%= resource.underscore %>.update(resource_params)
|
33
|
+
respond_with(@<%= resource.underscore %>)
|
34
|
+
else
|
35
|
+
respond_to do |format|
|
36
|
+
format.json { render :json => {:fields => @<%= resource.underscore %>.errors}, :status => :unprocessable_entity }
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
def destroy
|
42
|
+
ids = params[:id].split(",")
|
43
|
+
@<%= resource.pluralize.underscore %> = ::<%= resource %>.where(:id => ids)
|
44
|
+
authorize! :destroy, @<%= resource.pluralize.underscore %>
|
45
|
+
@<%= resource.pluralize.underscore %>.destroy_all
|
46
|
+
end
|
47
|
+
|
48
|
+
def build_resource
|
49
|
+
@<%= resource.underscore %> = ::<%= resource %>.new(resource_params)
|
50
|
+
end
|
51
|
+
|
52
|
+
def resource_params
|
53
|
+
params.require(:<%= resource.underscore %>).permit(:id<%= fields_as_params(:relations => true) %>)
|
54
|
+
end
|
55
|
+
|
56
|
+
end
|
@@ -0,0 +1,251 @@
|
|
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 = '<%= SecureRandom.hex(64) %>'
|
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
|
+
# ==> ORM configuration
|
19
|
+
# Load and configure the ORM. Supports :active_record (default) and
|
20
|
+
# :mongoid (bson_ext recommended) by default. Other ORMs may be
|
21
|
+
# available as additional gems.
|
22
|
+
require 'devise/orm/<%= options[:orm] %>'
|
23
|
+
|
24
|
+
# ==> Configuration for any authentication mechanism
|
25
|
+
# Configure which keys are used when authenticating a user. The default is
|
26
|
+
# just :email. You can configure it to use [:username, :subdomain], so for
|
27
|
+
# authenticating a user, both parameters are required. Remember that those
|
28
|
+
# parameters are used only when authenticating and not when retrieving from
|
29
|
+
# session. If you need permissions, you should implement that in a before filter.
|
30
|
+
# You can also supply a hash where the value is a boolean determining whether
|
31
|
+
# or not authentication should be aborted when the value is not present.
|
32
|
+
# config.authentication_keys = [ :email ]
|
33
|
+
|
34
|
+
# Configure parameters from the request object used for authentication. Each entry
|
35
|
+
# given should be a request method and it will automatically be passed to the
|
36
|
+
# find_for_authentication method and considered in your model lookup. For instance,
|
37
|
+
# if you set :request_keys to [:subdomain], :subdomain will be used on authentication.
|
38
|
+
# The same considerations mentioned for authentication_keys also apply to request_keys.
|
39
|
+
# config.request_keys = []
|
40
|
+
|
41
|
+
# Configure which authentication keys should be case-insensitive.
|
42
|
+
# These keys will be downcased upon creating or modifying a user and when used
|
43
|
+
# to authenticate or find a user. Default is :email.
|
44
|
+
config.case_insensitive_keys = [ :email ]
|
45
|
+
|
46
|
+
# Configure which authentication keys should have whitespace stripped.
|
47
|
+
# These keys will have whitespace before and after removed upon creating or
|
48
|
+
# modifying a user and when used to authenticate or find a user. Default is :email.
|
49
|
+
config.strip_whitespace_keys = [ :email ]
|
50
|
+
|
51
|
+
# Tell if authentication through request.params is enabled. True by default.
|
52
|
+
# It can be set to an array that will enable params authentication only for the
|
53
|
+
# given strategies, for example, `config.params_authenticatable = [:database]` will
|
54
|
+
# enable it only for database (email + password) authentication.
|
55
|
+
# config.params_authenticatable = true
|
56
|
+
|
57
|
+
# Tell if authentication through HTTP Auth is enabled. False by default.
|
58
|
+
# It can be set to an array that will enable http authentication only for the
|
59
|
+
# given strategies, for example, `config.http_authenticatable = [:database]` will
|
60
|
+
# enable it only for database authentication. The supported strategies are:
|
61
|
+
# :database = Support basic authentication with authentication key + password
|
62
|
+
# config.http_authenticatable = false
|
63
|
+
|
64
|
+
# If http headers should be returned for AJAX requests. True by default.
|
65
|
+
# config.http_authenticatable_on_xhr = true
|
66
|
+
|
67
|
+
# The realm used in Http Basic Authentication. 'Application' by default.
|
68
|
+
# config.http_authentication_realm = 'Application'
|
69
|
+
|
70
|
+
# It will change confirmation, password recovery and other workflows
|
71
|
+
# to behave the same regardless if the e-mail provided was right or wrong.
|
72
|
+
# Does not affect registerable.
|
73
|
+
# config.paranoid = true
|
74
|
+
|
75
|
+
# By default Devise will store the user in session. You can skip storage for
|
76
|
+
# particular strategies by setting this option.
|
77
|
+
# Notice that if you are skipping storage for all authentication paths, you
|
78
|
+
# may want to disable generating routes to Devise's sessions controller by
|
79
|
+
# passing :skip => :sessions to `devise_for` in your config/routes.rb
|
80
|
+
config.skip_session_storage = [:http_auth]
|
81
|
+
|
82
|
+
# By default, Devise cleans up the CSRF token on authentication to
|
83
|
+
# avoid CSRF token fixation attacks. This means that, when using AJAX
|
84
|
+
# requests for sign in and sign up, you need to get a new CSRF token
|
85
|
+
# from the server. You can disable this option at your own risk.
|
86
|
+
# config.clean_up_csrf_token_on_authentication = true
|
87
|
+
|
88
|
+
# ==> Configuration for :database_authenticatable
|
89
|
+
# For bcrypt, this is the cost for hashing the password and defaults to 10. If
|
90
|
+
# using other encryptors, it sets how many times you want the password re-encrypted.
|
91
|
+
#
|
92
|
+
# Limiting the stretches to just one in testing will increase the performance of
|
93
|
+
# your test suite dramatically. However, it is STRONGLY RECOMMENDED to not use
|
94
|
+
# a value less than 10 in other environments.
|
95
|
+
config.stretches = Rails.env.test? ? 1 : 10
|
96
|
+
|
97
|
+
# Setup a pepper to generate the encrypted password.
|
98
|
+
# config.pepper = '<%= SecureRandom.hex(64) %>'
|
99
|
+
|
100
|
+
# ==> Configuration for :confirmable
|
101
|
+
# A period that the user is allowed to access the website even without
|
102
|
+
# confirming his account. For instance, if set to 2.days, the user will be
|
103
|
+
# able to access the website for two days without confirming his account,
|
104
|
+
# access will be blocked just in the third day. Default is 0.days, meaning
|
105
|
+
# the user cannot access the website without confirming his account.
|
106
|
+
# config.allow_unconfirmed_access_for = 2.days
|
107
|
+
|
108
|
+
# A period that the user is allowed to confirm their account before their
|
109
|
+
# token becomes invalid. For example, if set to 3.days, the user can confirm
|
110
|
+
# their account within 3 days after the mail was sent, but on the fourth day
|
111
|
+
# their account can't be confirmed with the token any more.
|
112
|
+
# Default is nil, meaning there is no restriction on how long a user can take
|
113
|
+
# before confirming their account.
|
114
|
+
# config.confirm_within = 3.days
|
115
|
+
|
116
|
+
# If true, requires any email changes to be confirmed (exactly the same way as
|
117
|
+
# initial account confirmation) to be applied. Requires additional unconfirmed_email
|
118
|
+
# db field (see migrations). Until confirmed new email is stored in
|
119
|
+
# unconfirmed email column, and copied to email column on successful confirmation.
|
120
|
+
config.reconfirmable = true
|
121
|
+
|
122
|
+
# Defines which key will be used when confirming an account
|
123
|
+
# config.confirmation_keys = [ :email ]
|
124
|
+
|
125
|
+
# ==> Configuration for :rememberable
|
126
|
+
# The time the user will be remembered without asking for credentials again.
|
127
|
+
# config.remember_for = 2.weeks
|
128
|
+
|
129
|
+
# If true, extends the user's remember period when remembered via cookie.
|
130
|
+
# config.extend_remember_period = false
|
131
|
+
|
132
|
+
# Options to be passed to the created cookie. For instance, you can set
|
133
|
+
# :secure => true in order to force SSL only cookies.
|
134
|
+
# config.rememberable_options = {}
|
135
|
+
|
136
|
+
# ==> Configuration for :validatable
|
137
|
+
# Range for password length. Default is 8..128.
|
138
|
+
config.password_length = 8..128
|
139
|
+
|
140
|
+
# Email regex used to validate email formats. It simply asserts that
|
141
|
+
# one (and only one) @ exists in the given string. This is mainly
|
142
|
+
# to give user feedback and not to assert the e-mail validity.
|
143
|
+
# config.email_regexp = /\A[^@]+@[^@]+\z/
|
144
|
+
|
145
|
+
# ==> Configuration for :timeoutable
|
146
|
+
# The time you want to timeout the user session without activity. After this
|
147
|
+
# time the user will be asked for credentials again. Default is 30 minutes.
|
148
|
+
# config.timeout_in = 30.minutes
|
149
|
+
|
150
|
+
# If true, expires auth token on session timeout.
|
151
|
+
# config.expire_auth_token_on_timeout = false
|
152
|
+
|
153
|
+
# ==> Configuration for :lockable
|
154
|
+
# Defines which strategy will be used to lock an account.
|
155
|
+
# :failed_attempts = Locks an account after a number of failed attempts to sign in.
|
156
|
+
# :none = No lock strategy. You should handle locking by yourself.
|
157
|
+
# config.lock_strategy = :failed_attempts
|
158
|
+
|
159
|
+
# Defines which key will be used when locking and unlocking an account
|
160
|
+
# config.unlock_keys = [ :email ]
|
161
|
+
|
162
|
+
# Defines which strategy will be used to unlock an account.
|
163
|
+
# :email = Sends an unlock link to the user email
|
164
|
+
# :time = Re-enables login after a certain amount of time (see :unlock_in below)
|
165
|
+
# :both = Enables both strategies
|
166
|
+
# :none = No unlock strategy. You should handle unlocking by yourself.
|
167
|
+
# config.unlock_strategy = :both
|
168
|
+
|
169
|
+
# Number of authentication tries before locking an account if lock_strategy
|
170
|
+
# is failed attempts.
|
171
|
+
# config.maximum_attempts = 20
|
172
|
+
|
173
|
+
# Time interval to unlock the account if :time is enabled as unlock_strategy.
|
174
|
+
# config.unlock_in = 1.hour
|
175
|
+
|
176
|
+
# ==> Configuration for :recoverable
|
177
|
+
#
|
178
|
+
# Defines which key will be used when recovering the password for an account
|
179
|
+
# config.reset_password_keys = [ :email ]
|
180
|
+
|
181
|
+
# Time interval you can reset your password with a reset password key.
|
182
|
+
# Don't put a too small interval or your users won't have the time to
|
183
|
+
# change their passwords.
|
184
|
+
config.reset_password_within = 6.hours
|
185
|
+
|
186
|
+
# ==> Configuration for :encryptable
|
187
|
+
# Allow you to use another encryption algorithm besides bcrypt (default). You can use
|
188
|
+
# :sha1, :sha512 or encryptors from others authentication tools as :clearance_sha1,
|
189
|
+
# :authlogic_sha512 (then you should set stretches above to 20 for default behavior)
|
190
|
+
# and :restful_authentication_sha1 (then you should set stretches to 10, and copy
|
191
|
+
# REST_AUTH_SITE_KEY to pepper).
|
192
|
+
#
|
193
|
+
# Require the `devise-encryptable` gem when using anything other than bcrypt
|
194
|
+
# config.encryptor = :sha512
|
195
|
+
|
196
|
+
# ==> Scopes configuration
|
197
|
+
# Turn scoped views on. Before rendering "sessions/new", it will first check for
|
198
|
+
# "users/sessions/new". It's turned off by default because it's slower if you
|
199
|
+
# are using only default views.
|
200
|
+
# config.scoped_views = false
|
201
|
+
|
202
|
+
# Configure the default scope given to Warden. By default it's the first
|
203
|
+
# devise role declared in your routes (usually :user).
|
204
|
+
# config.default_scope = :user
|
205
|
+
|
206
|
+
# Set this configuration to false if you want /users/sign_out to sign out
|
207
|
+
# only the current scope. By default, Devise signs out all scopes.
|
208
|
+
# config.sign_out_all_scopes = true
|
209
|
+
|
210
|
+
# ==> Navigation configuration
|
211
|
+
# Lists the formats that should be treated as navigational. Formats like
|
212
|
+
# :html, should redirect to the sign in page when the user does not have
|
213
|
+
# access, but formats like :xml or :json, should return 401.
|
214
|
+
#
|
215
|
+
# If you have any extra navigational formats, like :iphone or :mobile, you
|
216
|
+
# should add them to the navigational formats lists.
|
217
|
+
#
|
218
|
+
# The "*/*" below is required to match Internet Explorer requests.
|
219
|
+
# config.navigational_formats = ['*/*', :html]
|
220
|
+
|
221
|
+
# The default HTTP method used to sign out a resource. Default is :delete.
|
222
|
+
config.sign_out_via = :delete
|
223
|
+
|
224
|
+
# ==> OmniAuth
|
225
|
+
# Add a new OmniAuth provider. Check the wiki for more information on setting
|
226
|
+
# up on your models and hooks.
|
227
|
+
# config.omniauth :github, 'APP_ID', 'APP_SECRET', :scope => 'user,public_repo'
|
228
|
+
|
229
|
+
# ==> Warden configuration
|
230
|
+
# If you want to use other strategies, that are not supported by Devise, or
|
231
|
+
# change the failure app, you can configure them inside the config.warden block.
|
232
|
+
#
|
233
|
+
# config.warden do |manager|
|
234
|
+
# manager.intercept_401 = false
|
235
|
+
# manager.default_strategies(:scope => :user).unshift :some_external_strategy
|
236
|
+
# end
|
237
|
+
|
238
|
+
# ==> Mountable engine configurations
|
239
|
+
# When using Devise inside an engine, let's call it `MyEngine`, and this engine
|
240
|
+
# is mountable, there are some extra configurations to be taken into account.
|
241
|
+
# The following options are available, assuming the engine is mounted as:
|
242
|
+
#
|
243
|
+
# mount MyEngine, at: '/my_engine'
|
244
|
+
#
|
245
|
+
# The router that invoked `devise_for`, in the example above, would be:
|
246
|
+
# config.router_name = :my_engine
|
247
|
+
#
|
248
|
+
# When using omniauth, Devise cannot automatically set Omniauth path,
|
249
|
+
# so you need to do it manually. For the users scope, it would be:
|
250
|
+
# config.omniauth_path_prefix = '/my_engine/users/auth'
|
251
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
Faalis::Engine.setup do |config|
|
2
|
+
# Logger settings for Faalis.
|
3
|
+
# Default value is the rails logger
|
4
|
+
# config.logger = Logger.new(STDOUT)
|
5
|
+
|
6
|
+
# Add your models which want to manage their permissions
|
7
|
+
config.models_with_permission = []
|
8
|
+
|
9
|
+
# Url prefix for dashboard section. default is '/dashboard'
|
10
|
+
# config.dashboard_namespace = :dashboard
|
11
|
+
|
12
|
+
# If you want to use red base layout in rtl mode
|
13
|
+
# config.layout_direction = :rtl
|
14
|
+
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 %>
|