voluntary 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/MIT-LICENSE +20 -0
- data/README.rdoc +48 -0
- data/Rakefile +27 -0
- data/app/assets/javascripts/voluntary/application.js +6 -0
- data/app/assets/javascripts/voluntary/base.js.coffee +34 -0
- data/app/assets/javascripts/voluntary/bootstrap.js.coffee +4 -0
- data/app/assets/javascripts/voluntary/functions.js +24 -0
- data/app/assets/javascripts/voluntary/users.js.coffee +12 -0
- data/app/assets/stylesheets/voluntary/application.css +15 -0
- data/app/assets/stylesheets/voluntary/base.css.scss +40 -0
- data/app/assets/stylesheets/voluntary/bootstrap_and_overrides.css.less +67 -0
- data/app/controllers/areas_controller.rb +66 -0
- data/app/controllers/candidatures_controller.rb +79 -0
- data/app/controllers/comments_controller.rb +70 -0
- data/app/controllers/devise_extensions/registrations_controller.rb +37 -0
- data/app/controllers/home_controller.rb +7 -0
- data/app/controllers/organizations_controller.rb +67 -0
- data/app/controllers/pages_controller.rb +54 -0
- data/app/controllers/products_controller.rb +62 -0
- data/app/controllers/professions_controller.rb +66 -0
- data/app/controllers/projects_controller.rb +56 -0
- data/app/controllers/results_controller.rb +93 -0
- data/app/controllers/stories_controller.rb +96 -0
- data/app/controllers/tasks_controller.rb +88 -0
- data/app/controllers/users_controller.rb +52 -0
- data/app/controllers/vacancies_controller.rb +79 -0
- data/app/controllers/voluntary/application_controller.rb +92 -0
- data/app/controllers/workflow/candidatures_controller.rb +20 -0
- data/app/controllers/workflow/products_controller.rb +6 -0
- data/app/controllers/workflow/project_owner_controller.rb +33 -0
- data/app/controllers/workflow/stories_controller.rb +6 -0
- data/app/controllers/workflow/tasks_controller.rb +147 -0
- data/app/controllers/workflow/user_controller.rb +6 -0
- data/app/controllers/workflow/vacancies_controller.rb +17 -0
- data/app/controllers/workflow_controller.rb +7 -0
- data/app/helpers/application_helper.rb +65 -0
- data/app/helpers/collection_helper.rb +31 -0
- data/app/helpers/comments_helper.rb +11 -0
- data/app/helpers/form_helper.rb +39 -0
- data/app/helpers/language_helper.rb +15 -0
- data/app/helpers/layout_helper.rb +24 -0
- data/app/helpers/product_helper.rb +32 -0
- data/app/helpers/show_helper.rb +65 -0
- data/app/helpers/wizard_helper.rb +27 -0
- data/app/models/area.rb +19 -0
- data/app/models/area_user.rb +19 -0
- data/app/models/candidature.rb +35 -0
- data/app/models/comment.rb +16 -0
- data/app/models/history_tracker.rb +3 -0
- data/app/models/mongo_db_document.rb +11 -0
- data/app/models/organization.rb +19 -0
- data/app/models/page.rb +30 -0
- data/app/models/product.rb +99 -0
- data/app/models/product/new_product.rb +3 -0
- data/app/models/product/project_management.rb +29 -0
- data/app/models/profession.rb +13 -0
- data/app/models/project.rb +66 -0
- data/app/models/project_user.rb +13 -0
- data/app/models/result.rb +55 -0
- data/app/models/role.rb +8 -0
- data/app/models/role/admin.rb +2 -0
- data/app/models/role/master.rb +2 -0
- data/app/models/role/project_owner.rb +2 -0
- data/app/models/role/user.rb +2 -0
- data/app/models/state_machines/candidature.rb +42 -0
- data/app/models/state_machines/page.rb +18 -0
- data/app/models/state_machines/story.rb +51 -0
- data/app/models/state_machines/task.rb +46 -0
- data/app/models/state_machines/vacancy.rb +41 -0
- data/app/models/story.rb +82 -0
- data/app/models/task.rb +85 -0
- data/app/models/user.rb +95 -0
- data/app/models/user_role.rb +6 -0
- data/app/models/vacancy.rb +41 -0
- data/app/observers/candidature_observer.rb +29 -0
- data/app/observers/story_observer.rb +6 -0
- data/app/observers/task_observer.rb +34 -0
- data/app/presenters/layout/application_presenter.rb +3 -0
- data/app/presenters/layout_presenter.rb +9 -0
- data/app/presenters/presenter.rb +46 -0
- data/app/presenters/resource_presenter.rb +30 -0
- data/app/presenters/resources/general/wizard_presenter.rb +17 -0
- data/app/presenters/resources/general/wizards/story/steps/activate_presenter.rb +3 -0
- data/app/presenters/resources/general/wizards/story/steps/setup_tasks_presenter.rb +5 -0
- data/app/presenters/resources/general/wizards/story_presenter.rb +3 -0
- data/app/presenters/resources/user/form_presenter.rb +16 -0
- data/app/presenters/shared/collection/table_presenter.rb +33 -0
- data/app/views/areas/_form.html.erb +11 -0
- data/app/views/areas/edit.html.erb +3 -0
- data/app/views/areas/index.html.erb +5 -0
- data/app/views/areas/new.html.erb +3 -0
- data/app/views/areas/show.html.erb +6 -0
- data/app/views/candidatures/_form.html.erb +13 -0
- data/app/views/candidatures/edit.html.erb +3 -0
- data/app/views/candidatures/index.html.erb +11 -0
- data/app/views/candidatures/new.html.erb +3 -0
- data/app/views/candidatures/show.html.erb +18 -0
- data/app/views/comments/_form.html.erb +16 -0
- data/app/views/comments/_resource.html.erb +16 -0
- data/app/views/comments/edit.html.erb +3 -0
- data/app/views/comments/new.html.erb +3 -0
- data/app/views/devise/mailer/confirmation_instructions.html.erb +10 -0
- data/app/views/devise/registrations/new.html.erb +5 -0
- data/app/views/general/wizard.html.erb +16 -0
- data/app/views/kaminari/_first_page.html.erb +13 -0
- data/app/views/kaminari/_gap.html.erb +8 -0
- data/app/views/kaminari/_last_page.html.erb +13 -0
- data/app/views/kaminari/_next_page.html.erb +13 -0
- data/app/views/kaminari/_page.html.erb +12 -0
- data/app/views/kaminari/_paginator.html.erb +25 -0
- data/app/views/kaminari/_prev_page.html.erb +13 -0
- data/app/views/layouts/application.html.erb +48 -0
- data/app/views/layouts/shared/_flash_messages.html.erb +7 -0
- data/app/views/layouts/shared/_navigation.html.erb +7 -0
- data/app/views/organizations/_form.html.erb +11 -0
- data/app/views/organizations/edit.html.erb +3 -0
- data/app/views/organizations/index.html.erb +5 -0
- data/app/views/organizations/new.html.erb +3 -0
- data/app/views/organizations/show.html.erb +6 -0
- data/app/views/pages/_form.html.erb +12 -0
- data/app/views/pages/edit.html.erb +3 -0
- data/app/views/pages/index.html.erb +5 -0
- data/app/views/pages/new.html.erb +3 -0
- data/app/views/pages/show.html.erb +10 -0
- data/app/views/products/_form.html.erb +28 -0
- data/app/views/products/edit.html.erb +3 -0
- data/app/views/products/index.html.erb +5 -0
- data/app/views/products/mixins/_keywords.html.erb +4 -0
- data/app/views/products/new.html.erb +3 -0
- data/app/views/products/show.html.erb +11 -0
- data/app/views/products/types/text_creation/stories/_form.html.erb +19 -0
- data/app/views/products/types/text_creation/stories/_task_fields.html.erb +7 -0
- data/app/views/projects/_form.html.erb +16 -0
- data/app/views/projects/edit.html.erb +3 -0
- data/app/views/projects/index.html.erb +5 -0
- data/app/views/projects/new.html.erb +3 -0
- data/app/views/projects/show.html.erb +13 -0
- data/app/views/shared/_comments.html.erb +7 -0
- data/app/views/shared/collection/_list.html.erb +37 -0
- data/app/views/shared/collection/_table.html.erb +36 -0
- data/app/views/shared/form/_error_messages.html.erb +10 -0
- data/app/views/shared/resource/_actions.html.erb +26 -0
- data/app/views/shared/resource/_event_elements.html.erb +7 -0
- data/app/views/stories/_collection.html.erb +8 -0
- data/app/views/stories/_form.html.erb +19 -0
- data/app/views/stories/_task_fields.html.erb +11 -0
- data/app/views/stories/index.html.erb +1 -0
- data/app/views/stories/show.html.erb +13 -0
- data/app/views/stories/steps/_activate.html.erb +17 -0
- data/app/views/stories/steps/_setup_tasks.html.erb +35 -0
- data/app/views/stories/tasks.html.erb +0 -0
- data/app/views/tasks/_collection.html.erb +12 -0
- data/app/views/users/_form.html.erb +43 -0
- data/app/views/users/edit.html.erb +3 -0
- data/app/views/users/index.html.erb +6 -0
- data/app/views/users/new.html.erb +3 -0
- data/app/views/users/preferences.html.erb +11 -0
- data/app/views/users/show.html.erb +6 -0
- data/app/views/vacancies/_form.html.erb +15 -0
- data/app/views/vacancies/edit.html.erb +3 -0
- data/app/views/vacancies/index.html.erb +7 -0
- data/app/views/vacancies/new.html.erb +3 -0
- data/app/views/vacancies/show.html.erb +17 -0
- data/app/views/workflow/index.html.erb +0 -0
- data/app/views/workflow/products/show.html.erb +34 -0
- data/app/views/workflow/project_owner/_candidatures.html.erb +31 -0
- data/app/views/workflow/project_owner/_stories.html.erb +29 -0
- data/app/views/workflow/project_owner/_tasks.html.erb +34 -0
- data/app/views/workflow/project_owner/_vacancies.html.erb +27 -0
- data/app/views/workflow/project_owner/index.html.erb +24 -0
- data/app/views/workflow/tasks/_work_form.html.erb +8 -0
- data/app/views/workflow/tasks/_work_head.html.erb +15 -0
- data/app/views/workflow/tasks/edit.html.erb +3 -0
- data/app/views/workflow/tasks/index.html.erb +31 -0
- data/app/views/workflow/tasks/next.html.erb +0 -0
- data/app/views/workflow/tasks/steps/_complete.html.erb +11 -0
- data/app/views/workflow/tasks/steps/_review.html.erb +13 -0
- data/app/views/workflow/tasks/steps/_work.html.erb +17 -0
- data/app/views/workflow/user/_tasks.html.erb +30 -0
- data/app/views/workflow/user/index.html.erb +14 -0
- data/config/initializers/1_initialize_app_config.rb +5 -0
- data/config/initializers/devise.rb +193 -0
- data/config/initializers/locale_settings.rb +42 -0
- data/config/initializers/mongoid-history.rb +2 -0
- data/config/initializers/recaptcha.rb +7 -0
- data/config/initializers/simple_form.rb +178 -0
- data/config/initializers/simple_navigation.rb +2 -0
- data/config/locales/devise.en.yml +59 -0
- data/config/locales/en.yml +26 -0
- data/config/locales/general/en.yml +71 -0
- data/config/locales/resources/area/en.yml +12 -0
- data/config/locales/resources/candidature/en.yml +19 -0
- data/config/locales/resources/comment/en.yml +11 -0
- data/config/locales/resources/organization/en.yml +11 -0
- data/config/locales/resources/page/en.yml +11 -0
- data/config/locales/resources/product/en.yml +23 -0
- data/config/locales/resources/project/en.yml +9 -0
- data/config/locales/resources/result/en.yml +9 -0
- data/config/locales/resources/story/en.yml +34 -0
- data/config/locales/resources/task/en.yml +36 -0
- data/config/locales/resources/user/en.yml +14 -0
- data/config/locales/resources/vacancy/en.yml +29 -0
- data/config/locales/simple_form.en.yml +26 -0
- data/config/locales/workflow/en.yml +37 -0
- data/config/routes.rb +188 -0
- data/db/migrate/20120907144853_create_schema.rb +217 -0
- data/db/migrate/20120911093743_remove_timestamps_from_habtm_tables.rb +21 -0
- data/db/migrate/20120919161831_add_unique_index_for_one_user_candidature_per_vacancy.rb +9 -0
- data/db/migrate/20120922201955_create_mongo_db_documents.rb +13 -0
- data/db/migrate/20120923140109_add_product_to_project.rb +6 -0
- data/db/migrate/20121004061413_add_extra_user_attributes.rb +9 -0
- data/db/migrate/20121004132105_create_professions.rb +13 -0
- data/db/migrate/20121006162913_add_public_attribute_to_roles.rb +6 -0
- data/db/migrate/20121006170407_add_type_attribute_to_roles.rb +5 -0
- data/db/migrate/20121007071543_add_foreign_languages_to_user.rb +6 -0
- data/db/migrate/20121028073712_create_organizations.rb +13 -0
- data/db/seeds.rb +14 -0
- data/lib/applicat/mvc/controller.rb +171 -0
- data/lib/applicat/mvc/controller/error_handling.rb +40 -0
- data/lib/applicat/mvc/controller/resource.rb +19 -0
- data/lib/applicat/mvc/controller/transition_actions.rb +43 -0
- data/lib/applicat/mvc/model/resource/base.rb +56 -0
- data/lib/applicat/mvc/model/tokenable.rb +24 -0
- data/lib/applicat/mvc/model/tree.rb +82 -0
- data/lib/db_seed.rb +150 -0
- data/lib/environment_configuration.rb +54 -0
- data/lib/generators/voluntary/install/install_generator.rb +118 -0
- data/lib/generators/voluntary/install/templates/app/controllers/application_controller.rb +3 -0
- data/lib/generators/voluntary/install/templates/app/models/ability.rb +49 -0
- data/lib/generators/voluntary/install/templates/app/models/app_config.rb +32 -0
- data/lib/generators/voluntary/install/templates/app/views/layouts/application.html.erb +50 -0
- data/lib/generators/voluntary/install/templates/config/application.yml +147 -0
- data/lib/generators/voluntary/install/templates/config/cucumber.yml +8 -0
- data/lib/generators/voluntary/install/templates/config/database.example.yml +28 -0
- data/lib/generators/voluntary/install/templates/config/deploy.rb +59 -0
- data/lib/generators/voluntary/install/templates/config/email.example.yml +9 -0
- data/lib/generators/voluntary/install/templates/config/initializers/recaptcha_example +4 -0
- data/lib/generators/voluntary/install/templates/config/locale_settings.yml +121 -0
- data/lib/generators/voluntary/install/templates/config/main_navigation.rb +262 -0
- data/lib/generators/voluntary/install/templates/config/mongoid.yml +78 -0
- data/lib/generators/voluntary/install/templates/config/nginx.conf +27 -0
- data/lib/generators/voluntary/install/templates/config/unicorn.rb +9 -0
- data/lib/generators/voluntary/install/templates/config/unicorn_init.sh +84 -0
- data/lib/generators/voluntary/install/templates/db/seeds.rb +14 -0
- data/lib/generators/voluntary/install/templates/features/step_definitions/email_steps.rb +89 -0
- data/lib/generators/voluntary/install/templates/features/step_definitions/factory_steps.rb +120 -0
- data/lib/generators/voluntary/install/templates/features/step_definitions/javascript_steps.rb +15 -0
- data/lib/generators/voluntary/install/templates/features/step_definitions/navigation_steps.rb +3 -0
- data/lib/generators/voluntary/install/templates/features/step_definitions/resources_steps.rb +8 -0
- data/lib/generators/voluntary/install/templates/features/step_definitions/session_steps.rb +35 -0
- data/lib/generators/voluntary/install/templates/features/step_definitions/web_steps.rb +271 -0
- data/lib/generators/voluntary/install/templates/features/support/database_cleaner_patches.rb +24 -0
- data/lib/generators/voluntary/install/templates/features/support/env.rb +83 -0
- data/lib/generators/voluntary/install/templates/features/support/integration_sessions_controller.rb +32 -0
- data/lib/generators/voluntary/install/templates/features/support/integration_sessions_form.html.erb +1 -0
- data/lib/generators/voluntary/install/templates/features/support/paths.rb +98 -0
- data/lib/generators/voluntary/install/templates/features/support/selectors.rb +44 -0
- data/lib/generators/voluntary/install/templates/features/support/spork_env +72 -0
- data/lib/generators/voluntary/install/templates/features/support/user_cuke_helpers.rb +78 -0
- data/lib/generators/voluntary/install/templates/lib/volontariat_seed.rb +36 -0
- data/lib/generators/voluntary/install/templates/spec/spec_helper.rb +72 -0
- data/lib/generators/voluntary/install/templates/spec/support/deferred_garbage_collector.rb +45 -0
- data/lib/generators/voluntary/install/templates/spec/support/devise.rb +3 -0
- data/lib/generators/voluntary/install/templates/spec/support/mongo_database_cleaner.rb +19 -0
- data/lib/generators/voluntary/install/templates/vendor/assets/javascripts/jquery.tokeninput.js +915 -0
- data/lib/generators/voluntary/install/templates/vendor/assets/stylesheets/token-input-facebook.css +122 -0
- data/lib/generators/voluntary/install/templates/vendor/assets/stylesheets/token-input-mac.css +204 -0
- data/lib/generators/voluntary/install/templates/vendor/assets/stylesheets/token-input.css +127 -0
- data/lib/i18n_interpolation_fallbacks.rb +21 -0
- data/lib/model/mongo_db/commentable.rb +17 -0
- data/lib/model/mongo_db/core_extensions.rb +10 -0
- data/lib/model/mongo_db/customizable.rb +23 -0
- data/lib/model/mongo_db/product/keywords.rb +31 -0
- data/lib/model/mongo_db/state_version_attributes.rb +15 -0
- data/lib/tasks/cucumber.rake +65 -0
- data/lib/tasks/voluntary_tasks.rake +4 -0
- data/lib/vendors/active_model/naming.rb +14 -0
- data/lib/vendors/simple_navigation/renderer/breadcrumbs_without_method_links.rb +30 -0
- data/lib/vendors/simple_navigation/renderer/twitter_sidenav.rb +34 -0
- data/lib/voluntary.rb +87 -0
- data/lib/voluntary/engine.rb +11 -0
- data/lib/voluntary/helpers/application.rb +69 -0
- data/lib/voluntary/helpers/collection.rb +35 -0
- data/lib/voluntary/helpers/comments.rb +15 -0
- data/lib/voluntary/helpers/form.rb +43 -0
- data/lib/voluntary/helpers/language.rb +19 -0
- data/lib/voluntary/helpers/layout.rb +28 -0
- data/lib/voluntary/helpers/product.rb +36 -0
- data/lib/voluntary/helpers/show.rb +69 -0
- data/lib/voluntary/helpers/wizard.rb +31 -0
- data/lib/voluntary/version.rb +3 -0
- data/lib/wizard.rb +58 -0
- data/lib/wizard/controller/concerns/paths.rb +31 -0
- data/lib/wizard/controller/concerns/steps.rb +142 -0
- metadata +1217 -0
@@ -0,0 +1,78 @@
|
|
1
|
+
development:
|
2
|
+
# Configure available database sessions. (required)
|
3
|
+
sessions:
|
4
|
+
# Defines the default session. (required)
|
5
|
+
default:
|
6
|
+
# Defines the name of the default database that Mongoid can connect to.
|
7
|
+
# (required).
|
8
|
+
database: volontariat_development
|
9
|
+
# Provides the hosts the default session can connect to. Must be an array
|
10
|
+
# of host:port pairs. (required)
|
11
|
+
hosts:
|
12
|
+
- localhost:27017
|
13
|
+
options:
|
14
|
+
# Change whether the session persists in safe mode by default.
|
15
|
+
# (default: false)
|
16
|
+
# safe: false
|
17
|
+
|
18
|
+
# Change the default consistency model to :eventual or :strong.
|
19
|
+
# :eventual will send reads to secondaries, :strong sends everything
|
20
|
+
# to master. (default: :eventual)
|
21
|
+
consistency: :strong
|
22
|
+
# Configure Mongoid specific options. (optional)
|
23
|
+
options:
|
24
|
+
# Configuration for whether or not to allow access to fields that do
|
25
|
+
# not have a field definition on the model. (default: true)
|
26
|
+
# allow_dynamic_fields: true
|
27
|
+
|
28
|
+
# Enable the identity map, needed for eager loading. (default: false)
|
29
|
+
# identity_map_enabled: false
|
30
|
+
|
31
|
+
# Includes the root model name in json serialization. (default: false)
|
32
|
+
# include_root_in_json: false
|
33
|
+
|
34
|
+
# Include the _type field in serializaion. (default: false)
|
35
|
+
# include_type_for_serialization: false
|
36
|
+
|
37
|
+
# Preload all models in development, needed when models use
|
38
|
+
# inheritance. (default: false)
|
39
|
+
# preload_models: false
|
40
|
+
|
41
|
+
# Protect id and type from mass assignment. (default: true)
|
42
|
+
# protect_sensitive_fields: true
|
43
|
+
|
44
|
+
# Raise an error when performing a #find and the document is not found.
|
45
|
+
# (default: true)
|
46
|
+
# raise_not_found_error: true
|
47
|
+
|
48
|
+
# Raise an error when defining a scope with the same name as an
|
49
|
+
# existing method. (default: false)
|
50
|
+
# scope_overwrite_exception: false
|
51
|
+
|
52
|
+
# Skip the database version check, used when connecting to a db without
|
53
|
+
# admin access. (default: false)
|
54
|
+
# skip_version_check: false
|
55
|
+
|
56
|
+
# User Active Support's time zone in conversions. (default: true)
|
57
|
+
# use_activesupport_time_zone: true
|
58
|
+
|
59
|
+
# Ensure all times are UTC in the app side. (default: false)
|
60
|
+
# use_utc: false
|
61
|
+
test:
|
62
|
+
sessions:
|
63
|
+
default:
|
64
|
+
database: volontariat_test
|
65
|
+
hosts:
|
66
|
+
- localhost:27017
|
67
|
+
options:
|
68
|
+
consistency: :strong
|
69
|
+
|
70
|
+
production:
|
71
|
+
sessions:
|
72
|
+
default:
|
73
|
+
database: volontariat_production
|
74
|
+
hosts:
|
75
|
+
- localhost:27017
|
76
|
+
options:
|
77
|
+
consistency: :strong
|
78
|
+
|
@@ -0,0 +1,27 @@
|
|
1
|
+
upstream unicorn {
|
2
|
+
server unix:/tmp/unicorn.volontariat.sock fail_timeout=0;
|
3
|
+
}
|
4
|
+
|
5
|
+
server {
|
6
|
+
listen 80 default deferred;
|
7
|
+
server_name volontari.at;
|
8
|
+
root /home/deployer/apps/volontariat/current/public;
|
9
|
+
|
10
|
+
location ^~ /assets/ {
|
11
|
+
gzip_static on;
|
12
|
+
expires max;
|
13
|
+
add_header Cache-Control public;
|
14
|
+
}
|
15
|
+
|
16
|
+
try_files $uri/index.html $uri @unicorn;
|
17
|
+
location @unicorn {
|
18
|
+
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
19
|
+
proxy_set_header Host $http_host;
|
20
|
+
proxy_redirect off;
|
21
|
+
proxy_pass http://unicorn;
|
22
|
+
}
|
23
|
+
|
24
|
+
error_page 500 502 503 504 /500.html;
|
25
|
+
client_max_body_size 4G;
|
26
|
+
keepalive_timeout 10;
|
27
|
+
}
|
@@ -0,0 +1,9 @@
|
|
1
|
+
root = "/home/deployer/apps/volontariat/current"
|
2
|
+
working_directory root
|
3
|
+
pid "#{root}/tmp/pids/unicorn.pid"
|
4
|
+
stderr_path "#{root}/log/unicorn.log"
|
5
|
+
stdout_path "#{root}/log/unicorn.log"
|
6
|
+
|
7
|
+
listen "/tmp/unicorn.volontariat.sock"
|
8
|
+
worker_processes 2
|
9
|
+
timeout 30
|
@@ -0,0 +1,84 @@
|
|
1
|
+
#!/bin/sh
|
2
|
+
### BEGIN INIT INFO
|
3
|
+
# Provides: unicorn
|
4
|
+
# Required-Start: $remote_fs $syslog
|
5
|
+
# Required-Stop: $remote_fs $syslog
|
6
|
+
# Default-Start: 2 3 4 5
|
7
|
+
# Default-Stop: 0 1 6
|
8
|
+
# Short-Description: Manage unicorn server
|
9
|
+
# Description: Start, stop, restart unicorn server for a specific application.
|
10
|
+
### END INIT INFO
|
11
|
+
set -e
|
12
|
+
|
13
|
+
# Feel free to change any of the following variables for your app:
|
14
|
+
TIMEOUT=${TIMEOUT-60}
|
15
|
+
APP_ROOT=/home/deployer/apps/volontariat/current
|
16
|
+
PID=$APP_ROOT/tmp/pids/unicorn.pid
|
17
|
+
CMD="cd $APP_ROOT; bundle exec unicorn -D -c $APP_ROOT/config/unicorn.rb -E production"
|
18
|
+
AS_USER=deployer
|
19
|
+
set -u
|
20
|
+
|
21
|
+
OLD_PIN="$PID.oldbin"
|
22
|
+
|
23
|
+
sig () {
|
24
|
+
test -s "$PID" && kill -$1 `cat $PID`
|
25
|
+
}
|
26
|
+
|
27
|
+
oldsig () {
|
28
|
+
test -s $OLD_PIN && kill -$1 `cat $OLD_PIN`
|
29
|
+
}
|
30
|
+
|
31
|
+
run () {
|
32
|
+
if [ "$(id -un)" = "$AS_USER" ]; then
|
33
|
+
eval $1
|
34
|
+
else
|
35
|
+
su -c "$1" - $AS_USER
|
36
|
+
fi
|
37
|
+
}
|
38
|
+
|
39
|
+
case "$1" in
|
40
|
+
start)
|
41
|
+
sig 0 && echo >&2 "Already running" && exit 0
|
42
|
+
run "$CMD"
|
43
|
+
;;
|
44
|
+
stop)
|
45
|
+
sig QUIT && exit 0
|
46
|
+
echo >&2 "Not running"
|
47
|
+
;;
|
48
|
+
force-stop)
|
49
|
+
sig TERM && exit 0
|
50
|
+
echo >&2 "Not running"
|
51
|
+
;;
|
52
|
+
restart|reload)
|
53
|
+
sig HUP && echo reloaded OK && exit 0
|
54
|
+
echo >&2 "Couldn't reload, starting '$CMD' instead"
|
55
|
+
run "$CMD"
|
56
|
+
;;
|
57
|
+
upgrade)
|
58
|
+
if sig USR2 && sleep 2 && sig 0 && oldsig QUIT
|
59
|
+
then
|
60
|
+
n=$TIMEOUT
|
61
|
+
while test -s $OLD_PIN && test $n -ge 0
|
62
|
+
do
|
63
|
+
printf '.' && sleep 1 && n=$(( $n - 1 ))
|
64
|
+
done
|
65
|
+
echo
|
66
|
+
|
67
|
+
if test $n -lt 0 && test -s $OLD_PIN
|
68
|
+
then
|
69
|
+
echo >&2 "$OLD_PIN still exists after $TIMEOUT seconds"
|
70
|
+
exit 1
|
71
|
+
fi
|
72
|
+
exit 0
|
73
|
+
fi
|
74
|
+
echo >&2 "Couldn't upgrade, starting '$CMD' instead"
|
75
|
+
run "$CMD"
|
76
|
+
;;
|
77
|
+
reopen-logs)
|
78
|
+
sig USR1
|
79
|
+
;;
|
80
|
+
*)
|
81
|
+
echo >&2 "Usage: $0 <start|stop|restart|upgrade|force-stop|reopen-logs>"
|
82
|
+
exit 1
|
83
|
+
;;
|
84
|
+
esac
|
@@ -0,0 +1,14 @@
|
|
1
|
+
# This file should contain all the record creation needed to seed the database with its default values.
|
2
|
+
# The data can then be loaded with the rake db:seed (or created alongside the db with db:setup).
|
3
|
+
#
|
4
|
+
# Examples:
|
5
|
+
#
|
6
|
+
# cities = City.create([{ name: 'Chicago' }, { name: 'Copenhagen' }])
|
7
|
+
# Mayor.create(name: 'Emanuel', city: cities.first)
|
8
|
+
delivery_method_was = ActionMailer::Base.delivery_method
|
9
|
+
ActionMailer::Base.delivery_method = :test
|
10
|
+
|
11
|
+
db_seed = VolontariatSeed.new
|
12
|
+
db_seed.create_fixtures
|
13
|
+
|
14
|
+
ActionMailer::Base.delivery_method = delivery_method_was
|
@@ -0,0 +1,89 @@
|
|
1
|
+
Before do
|
2
|
+
ActionMailer::Base.deliveries.clear
|
3
|
+
end
|
4
|
+
|
5
|
+
Given /^I have an empty inbox$/ do
|
6
|
+
ActionMailer::Base.deliveries.clear
|
7
|
+
end
|
8
|
+
|
9
|
+
Then /^(an|no) email should have been sent((?: |and|with|from "[^"]+"|to "[^"]+"|the subject "[^"]+"|the body "[^"]+"|the attachments "[^"]+")+)$/ do |mode, query|
|
10
|
+
conditions = {}
|
11
|
+
conditions[:to] = $1 if query =~ /to "([^"]+)"/
|
12
|
+
conditions[:from] = $1 if query =~ /from "([^"]+)"/
|
13
|
+
conditions[:subject] = $1 if query =~ /the subject "([^"]+)"/
|
14
|
+
conditions[:body] = $1 if query =~ /the body "([^"]+)"/
|
15
|
+
conditions[:attachments] = $1 if query =~ /the attachments "([^"]+)"/
|
16
|
+
|
17
|
+
@mail = TestMails.find(conditions)
|
18
|
+
expectation = mode == 'no' ? 'should_not' : 'should'
|
19
|
+
@mail.send(expectation, be_present)
|
20
|
+
end
|
21
|
+
|
22
|
+
When /^I follow the (first|second|third)? ?link in the email$/ do |index_in_words|
|
23
|
+
# Caveat: will not only take a-href but also img-src and other http-values
|
24
|
+
mail = @mail || ActionMailer::Base.deliveries.last
|
25
|
+
# index = { nil => 0, 'first' => 0, 'second' => 1, 'third' => 2 }[index_in_words]
|
26
|
+
# visit mail.body.scan(Patterns::URL)[index][2]
|
27
|
+
visit mail.body.to_s.scan(/http(?:s?):\/\/[^"\s]+/).send(index_in_words).split(':3000').last
|
28
|
+
end
|
29
|
+
|
30
|
+
Then /^no email should have been sent$/ do
|
31
|
+
ActionMailer::Base.deliveries.should be_empty
|
32
|
+
end
|
33
|
+
|
34
|
+
Then /^show me the emails$/ do
|
35
|
+
#raise ActionMailer::Base.deliveries.length.inspect
|
36
|
+
puts "emails count:" + ActionMailer::Base.deliveries.length.inspect
|
37
|
+
|
38
|
+
ActionMailer::Base.deliveries.each do |mail|
|
39
|
+
p [mail.from, mail.to, mail.subject, mail.body]
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
Then /^that mail should have "([^"]*)" in the body$/ do |word|
|
44
|
+
@mail.body.include?(word).should be_true
|
45
|
+
end
|
46
|
+
#
|
47
|
+
#
|
48
|
+
class TestMails
|
49
|
+
class << self
|
50
|
+
|
51
|
+
attr_accessor :user_identity
|
52
|
+
|
53
|
+
def find(conditions)
|
54
|
+
ActionMailer::Base.deliveries.detect do |mail|
|
55
|
+
[ conditions[:to].nil? || mail.to.include?(resolve_email conditions[:to]),
|
56
|
+
conditions[:from].nil? || mail.from.include?(resolve_email conditions[:from]),
|
57
|
+
conditions[:subject].nil? || mail.subject.include?(conditions[:subject]),
|
58
|
+
conditions[:body].nil? || mail.body.include?(conditions[:body]),
|
59
|
+
conditions[:attachments].nil? || conditions[:attachments].split(/\s*,\s*/).sort == Array(mail.attachments).collect(&:original_filename).sort
|
60
|
+
].all?
|
61
|
+
end.tap do |mail|
|
62
|
+
puts "Die Mail: #{mail}"
|
63
|
+
log(mail)
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
def resolve_email(identity)
|
68
|
+
if identity =~ /^.+\@.+$/
|
69
|
+
identity
|
70
|
+
else
|
71
|
+
User.send("find_by_#{user_identity || 'email'}!", identity).email
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
def log(mail)
|
76
|
+
puts "Aufruf: #{mail}"
|
77
|
+
if mail.present?
|
78
|
+
File.open("log/test_mails.log", "a") do |file|
|
79
|
+
file << "From: #{mail.from}\n"
|
80
|
+
file << "To: #{mail.to.join(', ')}\n"
|
81
|
+
file << "Subject: #{mail.subject}\n\n"
|
82
|
+
file << mail.body
|
83
|
+
file << "\n-------------------------\n\n"
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
end
|
89
|
+
end
|
@@ -0,0 +1,120 @@
|
|
1
|
+
module FactoryMethods
|
2
|
+
def create_from_table(model_name, table, extra = {})
|
3
|
+
factory_name = model_name.gsub(/\W+/, '_').downcase.singularize.to_sym
|
4
|
+
is_singular = model_name.to_s.singularize == model_name.to_s
|
5
|
+
|
6
|
+
hashes = if is_singular
|
7
|
+
if table.kind_of?(Hash)
|
8
|
+
[table]
|
9
|
+
else
|
10
|
+
[table.rows_hash]
|
11
|
+
end
|
12
|
+
elsif table.is_a?(Array)
|
13
|
+
table
|
14
|
+
else
|
15
|
+
table.hashes
|
16
|
+
end
|
17
|
+
|
18
|
+
@klass = factory_name.to_s.classify.constantize
|
19
|
+
@they = hashes.map do |hash|
|
20
|
+
hash = hash.merge(extra).inject({}) do |h,(k,v)|
|
21
|
+
k = k.gsub(/\W+/,'_')
|
22
|
+
|
23
|
+
# mongo db model classes are not responding to serialized attributes
|
24
|
+
# TODO: take care of serialized attributes in future mongo db model implementations here
|
25
|
+
if @klass.respond_to?(:serialized_attributes) && @klass.serialized_attributes[k] == Array
|
26
|
+
v = v.split(/\s*,\s*/)
|
27
|
+
end
|
28
|
+
|
29
|
+
h.update(k.to_sym => v)
|
30
|
+
end
|
31
|
+
|
32
|
+
hash.keys.each do |attribute|
|
33
|
+
set_value(hash, attribute)
|
34
|
+
end
|
35
|
+
|
36
|
+
eval("set_#{factory_name}_defaults(hash)") if "#{factory_name.to_s.classify}FactoryMethods".constantize rescue nil
|
37
|
+
|
38
|
+
object = nil
|
39
|
+
|
40
|
+
object = @klass.where(name: hash[:name]).first if hash.has_key? :name
|
41
|
+
object = object ? object : Factory.build(factory_name, hash)
|
42
|
+
|
43
|
+
yield object if block_given?
|
44
|
+
|
45
|
+
object.save!
|
46
|
+
|
47
|
+
object
|
48
|
+
end
|
49
|
+
|
50
|
+
if is_singular
|
51
|
+
@it = @they.last
|
52
|
+
instance_variable_set("@#{factory_name}", @it)
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
private
|
57
|
+
|
58
|
+
def set_value(hash, attribute)
|
59
|
+
value = hash[attribute]
|
60
|
+
|
61
|
+
if value.match '@'
|
62
|
+
if eval(value)
|
63
|
+
hash[attribute] = eval(value)
|
64
|
+
else
|
65
|
+
hash.delete attribute
|
66
|
+
end
|
67
|
+
elsif @klass.reflections.values.select{|v| v.macro == :belongs_to }.map(&:name).include? attribute
|
68
|
+
reflection_value = @klass.reflections.values.select{|v| v.name == attribute }.first
|
69
|
+
|
70
|
+
if reflection_value.options[:polymorphic]
|
71
|
+
polymorphic_type = "#{@klass.name}::#{attribute.to_s.upcase}_TYPES".constantize.first
|
72
|
+
resource = polymorphic_type.classify.constantize.find_by_name(value)
|
73
|
+
hash[attribute] = resource || create_from_table(polymorphic_type.tableize, [{ 'name' => value }])
|
74
|
+
else
|
75
|
+
resource = attribute.to_s.classify.constantize.find_by_name(value)
|
76
|
+
hash[attribute] = resource || create_from_table(attribute.to_s.tableize, [{ 'name' => value }])
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
World(FactoryMethods)
|
83
|
+
|
84
|
+
Given %r{^I have a (.+)$} do |model_name|
|
85
|
+
create_from_table(model_name, {}, 'user' => @me)
|
86
|
+
end
|
87
|
+
|
88
|
+
Given %r{^I have the following (.+):$} do |child, table|
|
89
|
+
step "that me has the following #{child}:", table
|
90
|
+
end
|
91
|
+
|
92
|
+
Given %r{^the following (.+):$} do |model_name, table|
|
93
|
+
create_from_table(model_name, table)
|
94
|
+
end
|
95
|
+
|
96
|
+
Given %r{^that (.+) has the following (.+):$} do |parent, child, table|
|
97
|
+
child= child.gsub(/\W+/,'_')
|
98
|
+
parent = parent.gsub(/\W+/,'_').downcase.sub(/^_/, '')
|
99
|
+
parent_instance = instance_variable_get("@#{parent}")
|
100
|
+
parent_class = parent_instance.class
|
101
|
+
|
102
|
+
if assoc = parent_class.reflect_on_association(child.to_sym) || parent_class.reflect_on_association(child.pluralize.to_sym)
|
103
|
+
parent = (assoc.options[:as] || parent).to_s
|
104
|
+
child = (assoc.options[:class_name] || child).to_s
|
105
|
+
end
|
106
|
+
|
107
|
+
if child.classify.constantize.method_defined?(parent.pluralize)
|
108
|
+
create_from_table(child, table, parent.pluralize => [parent_instance])
|
109
|
+
elsif child.classify.constantize.method_defined?(parent)
|
110
|
+
create_from_table(child, table, parent => parent_instance)
|
111
|
+
else
|
112
|
+
create_from_table(child, table)
|
113
|
+
|
114
|
+
if assoc.macro == :has_many
|
115
|
+
parent_instance.send("#{assoc.name}=", @they)
|
116
|
+
else
|
117
|
+
parent_instance.send("#{assoc.name}=", @they.first)
|
118
|
+
end
|
119
|
+
end
|
120
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
When /^I confirm all future JS confirm dialogs on this page$/ do
|
2
|
+
page.evaluate_script('window.confirm = function() { return true; }')
|
3
|
+
end
|
4
|
+
|
5
|
+
When /^I cancel all future JS confirm dialogs on this page$/ do
|
6
|
+
page.evaluate_script('window.confirm = function() { return false; }')
|
7
|
+
end
|
8
|
+
|
9
|
+
When /^I confirm popup$/ do
|
10
|
+
page.driver.browser.switch_to.alert.accept
|
11
|
+
end
|
12
|
+
|
13
|
+
When /^I dismiss popup$/ do
|
14
|
+
page.driver.browser.switch_to.alert.dismiss
|
15
|
+
end
|