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,41 @@
|
|
1
|
+
module Faalis
|
2
|
+
module API
|
3
|
+
class GroupsAPI < Grape::API
|
4
|
+
|
5
|
+
resource :groups do
|
6
|
+
|
7
|
+
desc "Return all the groups"
|
8
|
+
get do
|
9
|
+
authenticated_user
|
10
|
+
# TODO: Check for admin user only
|
11
|
+
Faalis::Group.includes(:permissions)
|
12
|
+
end
|
13
|
+
|
14
|
+
delete do
|
15
|
+
authenticated_user
|
16
|
+
|
17
|
+
#if can? :delete, Group
|
18
|
+
#end
|
19
|
+
Group.delete(params[:id].split(","))
|
20
|
+
end
|
21
|
+
|
22
|
+
post do
|
23
|
+
authenticated_user
|
24
|
+
|
25
|
+
permissions = [];
|
26
|
+
|
27
|
+
params[:permissions].each do |perm_string|
|
28
|
+
perm, model = perm_string.split "|"
|
29
|
+
permission = Permission.find_or_create_by_model_and_permission_type(model, perm)
|
30
|
+
permissions << permission
|
31
|
+
end
|
32
|
+
|
33
|
+
Group.create!({
|
34
|
+
name: params[:name],
|
35
|
+
permissions: permissions,
|
36
|
+
})
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module Faalis
|
2
|
+
module API
|
3
|
+
class PermissionsAPI < Grape::API
|
4
|
+
|
5
|
+
resource :permissions do
|
6
|
+
|
7
|
+
desc "Return all permissions available"
|
8
|
+
get do
|
9
|
+
authenticated_user
|
10
|
+
# TODO: Check for admin user only
|
11
|
+
permissions = []
|
12
|
+
|
13
|
+
Faalis::Engine.models_with_permission.each do |model|
|
14
|
+
model = Object.const_get(model)
|
15
|
+
permissions.concat(model::Permissions.permission_strings(model))
|
16
|
+
end
|
17
|
+
|
18
|
+
permissions
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require_dependency "faalis/api/users_api"
|
2
|
+
require_dependency "faalis/api/groups_api"
|
3
|
+
require_dependency "faalis/api/permissions_api"
|
4
|
+
|
5
|
+
module Faalis
|
6
|
+
module API
|
7
|
+
class Root < Grape::API
|
8
|
+
|
9
|
+
mount API::UsersAPI
|
10
|
+
mount API::GroupsAPI
|
11
|
+
mount API::PermissionsAPI
|
12
|
+
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module Faalis
|
2
|
+
module API
|
3
|
+
class UsersAPI < Grape::API
|
4
|
+
|
5
|
+
|
6
|
+
resource :users do
|
7
|
+
|
8
|
+
desc "Return all the users"
|
9
|
+
get do
|
10
|
+
authenticated_user
|
11
|
+
# TODO: Check for admin user only
|
12
|
+
Faalis::User.all
|
13
|
+
end
|
14
|
+
|
15
|
+
end
|
16
|
+
|
17
|
+
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# -----------------------------------------------------------------------------
|
2
|
+
# Red Base - Basic website skel engine
|
3
|
+
# Copyright (C) 2012-2013 Yellowen
|
4
|
+
#
|
5
|
+
# This program is free software; you can redistribute it and/or modify
|
6
|
+
# it under the terms of the GNU General Public License as published by
|
7
|
+
# the Free Software Foundation; either version 2 of the License, or
|
8
|
+
# (at your option) any later version.
|
9
|
+
#
|
10
|
+
# This program is distributed in the hope that it will be useful,
|
11
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
13
|
+
# GNU General Public License for more details.
|
14
|
+
#
|
15
|
+
# You should have received a copy of the GNU General Public License along
|
16
|
+
# with this program; if not, write to the Free Software Foundation, Inc.,
|
17
|
+
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
18
|
+
# -----------------------------------------------------------------------------
|
19
|
+
|
20
|
+
# Some useful steps for cucumber scenarios
|
21
|
+
require 'faalis/cucumber/auth'
|
22
|
+
require 'faalis/cucumber/urls'
|
23
|
+
require 'faalis/cucumber/interaction'
|
24
|
+
require 'faalis/cucumber/exceptions'
|
25
|
+
require 'faalis/cucumber/query'
|
@@ -0,0 +1,45 @@
|
|
1
|
+
# -----------------------------------------------------------------------------
|
2
|
+
# Red Base - Basic website skel engine
|
3
|
+
# Copyright (C) 2012-2013 Yellowen
|
4
|
+
#
|
5
|
+
# This program is free software; you can redistribute it and/or modify
|
6
|
+
# it under the terms of the GNU General Public License as published by
|
7
|
+
# the Free Software Foundation; either version 2 of the License, or
|
8
|
+
# (at your option) any later version.
|
9
|
+
#
|
10
|
+
# This program is distributed in the hope that it will be useful,
|
11
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
13
|
+
# GNU General Public License for more details.
|
14
|
+
#
|
15
|
+
# You should have received a copy of the GNU General Public License along
|
16
|
+
# with this program; if not, write to the Free Software Foundation, Inc.,
|
17
|
+
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
18
|
+
# -----------------------------------------------------------------------------
|
19
|
+
|
20
|
+
# Some useful steps for cucumber scenarios
|
21
|
+
Given(/^I am not authenticated$/) do
|
22
|
+
#Capybara.reset_sessions!
|
23
|
+
#delete "/users/sign_out"
|
24
|
+
page.driver.submit :delete, "/users/sign_out", {}
|
25
|
+
end
|
26
|
+
|
27
|
+
|
28
|
+
Given(/^I am authenticated$/) do
|
29
|
+
group = Faalis::Group.new(:name => "admin")
|
30
|
+
group.save!
|
31
|
+
email = 'admin@example.com'
|
32
|
+
password = '123123123'
|
33
|
+
Faalis::User.new(:email => email, :password => password, :password_confirmation => password,
|
34
|
+
:group => group).save!
|
35
|
+
|
36
|
+
visit '/users/sign_in'
|
37
|
+
fill_in "user_email", :with => email
|
38
|
+
fill_in "user_password", :with => password
|
39
|
+
click_button "Sign in"
|
40
|
+
should_not have_content("Sign in")
|
41
|
+
end
|
42
|
+
|
43
|
+
Then(/^I should be in sign in page$/) do
|
44
|
+
should have_content("Sign in")
|
45
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
# -----------------------------------------------------------------------------
|
2
|
+
# Red Base - Basic website skel engine
|
3
|
+
# Copyright (C) 2012-2013 Yellowen
|
4
|
+
#
|
5
|
+
# This program is free software; you can redistribute it and/or modify
|
6
|
+
# it under the terms of the GNU General Public License as published by
|
7
|
+
# the Free Software Foundation; either version 2 of the License, or
|
8
|
+
# (at your option) any later version.
|
9
|
+
#
|
10
|
+
# This program is distributed in the hope that it will be useful,
|
11
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
13
|
+
# GNU General Public License for more details.
|
14
|
+
#
|
15
|
+
# You should have received a copy of the GNU General Public License along
|
16
|
+
# with this program; if not, write to the Free Software Foundation, Inc.,
|
17
|
+
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
18
|
+
# -----------------------------------------------------------------------------
|
19
|
+
|
20
|
+
# Some useful steps for cucumber scenarios
|
21
|
+
|
22
|
+
Then(/^I should get unknown format exception$/) do
|
23
|
+
|
24
|
+
#Then ("I should get '406' status code")
|
25
|
+
# @exception.should_not be_nil
|
26
|
+
# @exception.class.should be(ActionController::UnknownFormat)
|
27
|
+
end
|
28
|
+
|
29
|
+
Then(/^action should not be found$/) do
|
30
|
+
if Capybara.current_driver == :webkit
|
31
|
+
page.status_code should == 404
|
32
|
+
else
|
33
|
+
@exception.should_not be_nil
|
34
|
+
@exception.class.should be(AbstractController::ActionNotFound)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
Then(/^I debug/) do
|
39
|
+
binding.pry
|
40
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
# -----------------------------------------------------------------------------
|
2
|
+
# Red Base - Basic website skel engine
|
3
|
+
# Copyright (C) 2012-2013 Yellowen
|
4
|
+
#
|
5
|
+
# This program is free software; you can redistribute it and/or modify
|
6
|
+
# it under the terms of the GNU General Public License as published by
|
7
|
+
# the Free Software Foundation; either version 2 of the License, or
|
8
|
+
# (at your option) any later version.
|
9
|
+
#
|
10
|
+
# This program is distributed in the hope that it will be useful,
|
11
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
13
|
+
# GNU General Public License for more details.
|
14
|
+
#
|
15
|
+
# You should have received a copy of the GNU General Public License along
|
16
|
+
# with this program; if not, write to the Free Software Foundation, Inc.,
|
17
|
+
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
18
|
+
# -----------------------------------------------------------------------------
|
19
|
+
# Some useful steps for cucumber scenarios
|
20
|
+
def wait_for_ajax
|
21
|
+
Timeout.timeout(Capybara.default_wait_time) do
|
22
|
+
active = page.evaluate_script('$("#flash").is(":visible")')
|
23
|
+
until active == true
|
24
|
+
active = page.evaluate_script('$("#flash").is(":visible")')
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
When(/^fill in "(.*?)" with "(.*?)"$/) do |input, value|
|
30
|
+
fill_in input, with: value
|
31
|
+
end
|
32
|
+
|
33
|
+
When(/^click on "(.*?)"$/) do |link|
|
34
|
+
|
35
|
+
click_on link
|
36
|
+
end
|
37
|
+
|
38
|
+
When(/^wait for ajax to return$/) do
|
39
|
+
wait_for_ajax
|
40
|
+
end
|
41
|
+
Then (/^field "(.+)" contains "(.+)"$/) do |field, value|
|
42
|
+
find_field('name').value.should eq value
|
43
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# -----------------------------------------------------------------------------
|
2
|
+
# Red Base - Basic website skel engine
|
3
|
+
# Copyright (C) 2012-2013 Yellowen
|
4
|
+
#
|
5
|
+
# This program is free software; you can redistribute it and/or modify
|
6
|
+
# it under the terms of the GNU General Public License as published by
|
7
|
+
# the Free Software Foundation; either version 2 of the License, or
|
8
|
+
# (at your option) any later version.
|
9
|
+
#
|
10
|
+
# This program is distributed in the hope that it will be useful,
|
11
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
13
|
+
# GNU General Public License for more details.
|
14
|
+
#
|
15
|
+
# You should have received a copy of the GNU General Public License along
|
16
|
+
# with this program; if not, write to the Free Software Foundation, Inc.,
|
17
|
+
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
18
|
+
# -----------------------------------------------------------------------------
|
19
|
+
|
20
|
+
# Some useful steps for cucumber scenarios
|
21
|
+
Then(/^there should be an? (.+) with "(.+)" as "(.+)"/) do |model_name, values, fields|
|
22
|
+
model = model_name.singularize.classify.constantize
|
23
|
+
keys = fields.split(",").each.collect {|k| k.to_sym}
|
24
|
+
values = values.split(",")
|
25
|
+
conditions = Hash[keys.zip(values)]
|
26
|
+
obj = model.where(**conditions)
|
27
|
+
obj.count.should == 1
|
28
|
+
end
|
@@ -0,0 +1,76 @@
|
|
1
|
+
# -----------------------------------------------------------------------------
|
2
|
+
# Red Base - Basic website skel engine
|
3
|
+
# Copyright (C) 2012-2013 Yellowen
|
4
|
+
#
|
5
|
+
# This program is free software; you can redistribute it and/or modify
|
6
|
+
# it under the terms of the GNU General Public License as published by
|
7
|
+
# the Free Software Foundation; either version 2 of the License, or
|
8
|
+
# (at your option) any later version.
|
9
|
+
#
|
10
|
+
# This program is distributed in the hope that it will be useful,
|
11
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
13
|
+
# GNU General Public License for more details.
|
14
|
+
#
|
15
|
+
# You should have received a copy of the GNU General Public License along
|
16
|
+
# with this program; if not, write to the Free Software Foundation, Inc.,
|
17
|
+
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
18
|
+
# -----------------------------------------------------------------------------
|
19
|
+
|
20
|
+
# Some useful steps for cucumber scenarios
|
21
|
+
Then /^I should be on (.+?)$/ do |page_name|
|
22
|
+
current_path.should == path_to(page_name)
|
23
|
+
response.should be_success
|
24
|
+
end
|
25
|
+
|
26
|
+
Then(/^I should redirect to (.+?)$/) do |path_name|
|
27
|
+
Then "I should be on #{path_name}"
|
28
|
+
end
|
29
|
+
|
30
|
+
#When(/^I go to (.*?) using (.*?) format$/) do |path_name, format|
|
31
|
+
# visit "#{path_to(path_name)}.#{format}"
|
32
|
+
#end
|
33
|
+
|
34
|
+
When(/^I go to (.+)$/) do |path_name|
|
35
|
+
begin
|
36
|
+
visit "#{path_to(path_name)}"
|
37
|
+
rescue ActionController::UnknownFormat => e
|
38
|
+
@exception = e
|
39
|
+
rescue AbstractController::ActionNotFound => e
|
40
|
+
@exception = e
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
When(/^format is (.+) and I go to (.+)$/) do |format, path_name|
|
45
|
+
begin
|
46
|
+
visit "#{path_to(path_name)}.#{format}"
|
47
|
+
rescue ActionController::UnknownFormat => e
|
48
|
+
@exception = e
|
49
|
+
rescue AbstractController::ActionNotFound => e
|
50
|
+
@exception = e
|
51
|
+
end
|
52
|
+
end
|
53
|
+
Then(/^I should get "(.*?)" status code$/) do |status_code|
|
54
|
+
page.status_code.should == status_code.to_i
|
55
|
+
end
|
56
|
+
|
57
|
+
Then(/^response type should be (.+?)$/) do |response_type|
|
58
|
+
page.response_headers['Content-Type'].should include(response_type)
|
59
|
+
end
|
60
|
+
|
61
|
+
|
62
|
+
When(/^format is (.+) and I send (.+) to (.+) with\:$/) do |format, method, path_name, raw_data|
|
63
|
+
path = "#{path_to(path_name)}.#{format}"
|
64
|
+
data = ""
|
65
|
+
raw_data.split(/\n/).each do |phrase|
|
66
|
+
data += phrase.strip
|
67
|
+
end
|
68
|
+
|
69
|
+
page.driver.submit(method, path, data)
|
70
|
+
|
71
|
+
end
|
72
|
+
|
73
|
+
When(/^format is (.+) and I send delete to (.+)$/) do |format, path_name|
|
74
|
+
path = "#{path_to(path_name)}"
|
75
|
+
page.driver.submit :delete, path, {}
|
76
|
+
end
|
@@ -0,0 +1,60 @@
|
|
1
|
+
# -----------------------------------------------------------------------------
|
2
|
+
# Red Base - Basic website skel engine
|
3
|
+
# Copyright (C) 2012-2013 Yellowen
|
4
|
+
#
|
5
|
+
# This program is free software; you can redistribute it and/or modify
|
6
|
+
# it under the terms of the GNU General Public License as published by
|
7
|
+
# the Free Software Foundation; either version 2 of the License, or
|
8
|
+
# (at your option) any later version.
|
9
|
+
#
|
10
|
+
# This program is distributed in the hope that it will be useful,
|
11
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
13
|
+
# GNU General Public License for more details.
|
14
|
+
#
|
15
|
+
# You should have received a copy of the GNU General Public License along
|
16
|
+
# with this program; if not, write to the Free Software Foundation, Inc.,
|
17
|
+
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
18
|
+
# -----------------------------------------------------------------------------
|
19
|
+
|
20
|
+
module Faalis
|
21
|
+
|
22
|
+
# This Module is the base module for dashboard
|
23
|
+
class Dashboard
|
24
|
+
include Singleton
|
25
|
+
|
26
|
+
@@modules = {}
|
27
|
+
@@sections = {}
|
28
|
+
|
29
|
+
def register_module(section, dashboard_module)
|
30
|
+
|
31
|
+
if not @@modules.include? dashboard_module.name
|
32
|
+
@@modules[dashboard_module.name.to_sym] = dashboard_module
|
33
|
+
|
34
|
+
if not @@sections.include? section.to_sym
|
35
|
+
@@sections[section.to_sym] = []
|
36
|
+
end
|
37
|
+
@@sections[section.to_sym] << dashboard_module.name
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
# Return content for given section by calling related
|
42
|
+
# method in each registered module which registered to
|
43
|
+
# specified section
|
44
|
+
def content_for(section)
|
45
|
+
|
46
|
+
result = []
|
47
|
+
if @@sections.include? section
|
48
|
+
@@sections[section].each do |module_name|
|
49
|
+
# Get module object form @@modules
|
50
|
+
result << [@@modules[module_name].priority,
|
51
|
+
@@modules[modue_name].send("content_for_#{section}")]
|
52
|
+
end
|
53
|
+
end
|
54
|
+
result.sort.reverse.join("\n").html_safe
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
require "faalis/dashboard/module"
|
60
|
+
require "faalis/dashboard/controller"
|
@@ -0,0 +1,42 @@
|
|
1
|
+
# -----------------------------------------------------------------------------
|
2
|
+
# Red Base - Basic website skel engine
|
3
|
+
# Copyright (C) 2012-2013 Yellowen
|
4
|
+
#
|
5
|
+
# This program is free software; you can redistribute it and/or modify
|
6
|
+
# it under the terms of the GNU General Public License as published by
|
7
|
+
# the Free Software Foundation; either version 2 of the License, or
|
8
|
+
# (at your option) any later version.
|
9
|
+
#
|
10
|
+
# This program is distributed in the hope that it will be useful,
|
11
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
13
|
+
# GNU General Public License for more details.
|
14
|
+
#
|
15
|
+
# You should have received a copy of the GNU General Public License along
|
16
|
+
# with this program; if not, write to the Free Software Foundation, Inc.,
|
17
|
+
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
18
|
+
# -----------------------------------------------------------------------------
|
19
|
+
|
20
|
+
module Faalis
|
21
|
+
class Dashboard
|
22
|
+
module Controller
|
23
|
+
|
24
|
+
def self.included(base)
|
25
|
+
base.extend(ClassMethods)
|
26
|
+
end
|
27
|
+
|
28
|
+
module ClassMethods
|
29
|
+
# List of controllers which dashboard should load before rendering
|
30
|
+
# dashboard
|
31
|
+
def dashboard_modules(modules)
|
32
|
+
modules.each do |module_name|
|
33
|
+
logger.info "Loading Dashboard Module [#{module_name}]."
|
34
|
+
const_get(module_name)
|
35
|
+
#require "#{module_name}"
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|