guara 0.0.1.rc
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +23 -0
- data/.rspec +2 -0
- data/.travis.yml +33 -0
- data/Gemfile +82 -0
- data/Gemfile.lock +323 -0
- data/Guardfile +32 -0
- data/MIT-LICENSE +20 -0
- data/README.md +8 -0
- data/Rakefile +7 -0
- data/app/admin/business_activities.rb +3 -0
- data/app/admin/business_departments.rb +3 -0
- data/app/admin/business_segments.rb +13 -0
- data/app/admin/cities.rb +3 -0
- data/app/admin/company_businesses.rb +3 -0
- data/app/admin/dashboard.rb +39 -0
- data/app/admin/districts.rb +3 -0
- data/app/admin/states.rb +3 -0
- data/app/admin/task_types.rb +3 -0
- data/app/admin/user_groups.rb +3 -0
- data/app/admin/users.rb +3 -0
- data/app/assets/images/close.gif +0 -0
- data/app/assets/images/custom/logo.png +0 -0
- data/app/assets/images/custom/nav_logo.png +0 -0
- data/app/assets/images/custom/nav_logo.psd +0 -0
- data/app/assets/images/rails.png +0 -0
- data/app/assets/javascripts/active_admin.js +5 -0
- data/app/assets/javascripts/application.js +97 -0
- data/app/assets/javascripts/business_departments.js.coffee +3 -0
- data/app/assets/javascripts/company_businesses.js.coffee +3 -0
- data/app/assets/javascripts/crm.js.coffee +14 -0
- data/app/assets/javascripts/fcbk.js +556 -0
- data/app/assets/javascripts/jquery-ui-timepicker-addon.js +1326 -0
- data/app/assets/javascripts/jquery.mask.1.3.js +7 -0
- data/app/assets/javascripts/jquery.multiselect.filter.xjs +173 -0
- data/app/assets/javascripts/jquery.multiselect.xjs +668 -0
- data/app/assets/javascripts/system_task_status.js.coffee +3 -0
- data/app/assets/javascripts/tests/ajaxes.js.coffee +3 -0
- data/app/assets/stylesheets/abilities.css.scss +6 -0
- data/app/assets/stylesheets/active_admin.css.scss +65 -0
- data/app/assets/stylesheets/application.css +19 -0
- data/app/assets/stylesheets/business_departments.css.scss +3 -0
- data/app/assets/stylesheets/company_businesses.css.scss +3 -0
- data/app/assets/stylesheets/custom.css.scss +322 -0
- data/app/assets/stylesheets/customer.scss +7 -0
- data/app/assets/stylesheets/fcbk.css +165 -0
- data/app/assets/stylesheets/guara.css.scss +159 -0
- data/app/assets/stylesheets/jquery-ui.css +567 -0
- data/app/assets/stylesheets/jquery_bootstrap.css.scss +92 -0
- data/app/assets/stylesheets/jquery_multiselect_filter.xcss +3 -0
- data/app/assets/stylesheets/scaffolds.css.scss +42 -0
- data/app/assets/stylesheets/users.css.scss +10 -0
- data/app/controllers/abilities_controller.rb +37 -0
- data/app/controllers/application_controller.rb +12 -0
- data/app/controllers/business_activities_controller.rb +87 -0
- data/app/controllers/business_departments_controller.rb +90 -0
- data/app/controllers/business_segments_controller.rb +88 -0
- data/app/controllers/company_businesses_controller.rb +46 -0
- data/app/controllers/contacts_controller.rb +105 -0
- data/app/controllers/customers_controller.rb +117 -0
- data/app/controllers/microposts_controller.rb +31 -0
- data/app/controllers/sessions_controller.rb +32 -0
- data/app/controllers/static_pages_controller.rb +23 -0
- data/app/controllers/system_task_status_controller.rb +84 -0
- data/app/controllers/task_feedbacks_controller.rb +6 -0
- data/app/controllers/task_types_controller.rb +85 -0
- data/app/controllers/tasks_controller.rb +107 -0
- data/app/controllers/tests/ajaxes_controller.rb +115 -0
- data/app/controllers/tests/lab_ajax_controller.rb +27 -0
- data/app/controllers/users_controller.rb +62 -0
- data/app/helpers/ability_helper.rb +15 -0
- data/app/helpers/application_helper.rb +32 -0
- data/app/helpers/business_activities_helper.rb +2 -0
- data/app/helpers/business_departments_helper.rb +2 -0
- data/app/helpers/business_segments_helper.rb +2 -0
- data/app/helpers/company_businesses_helper.rb +2 -0
- data/app/helpers/contacts_helper.rb +2 -0
- data/app/helpers/customers_helper.rb +23 -0
- data/app/helpers/email_helper.rb +8 -0
- data/app/helpers/form_ajax_helper.rb +8 -0
- data/app/helpers/guara_views_helper.rb +38 -0
- data/app/helpers/locale_helper.rb +24 -0
- data/app/helpers/menu_helper.rb +55 -0
- data/app/helpers/sessions_helper.rb +56 -0
- data/app/helpers/tasks_helper.rb +20 -0
- data/app/helpers/tests/ajaxes_helper.rb +2 -0
- data/app/helpers/user_abilities_helper.rb +12 -0
- data/app/helpers/users_helper.rb +29 -0
- data/app/mailers/.gitkeep +0 -0
- data/app/models/.gitkeep +0 -0
- data/app/models/ability.rb +52 -0
- data/app/models/address.rb +7 -0
- data/app/models/business_activity.rb +5 -0
- data/app/models/business_department.rb +3 -0
- data/app/models/business_segment.rb +5 -0
- data/app/models/city.rb +7 -0
- data/app/models/company_business.rb +6 -0
- data/app/models/contact.rb +69 -0
- data/app/models/customer.rb +117 -0
- data/app/models/customer_activity.rb +9 -0
- data/app/models/customer_financial.rb +10 -0
- data/app/models/customer_has_customers.rb +7 -0
- data/app/models/customer_pf.rb +13 -0
- data/app/models/customer_pj.rb +71 -0
- data/app/models/customer_pj_has_customers_pj.rb +7 -0
- data/app/models/customer_product.rb +3 -0
- data/app/models/customer_segment.rb +9 -0
- data/app/models/district.rb +6 -0
- data/app/models/email.rb +7 -0
- data/app/models/micropost.rb +10 -0
- data/app/models/relationship.rb +9 -0
- data/app/models/search.rb +17 -0
- data/app/models/state.rb +3 -0
- data/app/models/system_ability.rb +16 -0
- data/app/models/system_module.rb +16 -0
- data/app/models/system_task_resolution.rb +26 -0
- data/app/models/system_task_status.rb +19 -0
- data/app/models/task.rb +76 -0
- data/app/models/task_feedback.rb +11 -0
- data/app/models/task_type.rb +12 -0
- data/app/models/tests.rb +5 -0
- data/app/models/tests/ajax.rb +3 -0
- data/app/models/user.rb +126 -0
- data/app/models/user_ability.rb +23 -0
- data/app/models/user_group.rb +9 -0
- data/app/models/user_type.rb +9 -0
- data/app/models/users_has_groups.rb +9 -0
- data/app/validators/customer_cnpj_validator.rb +14 -0
- data/app/validators/email_validator.rb +21 -0
- data/app/views/abilities/index.html.erb +25 -0
- data/app/views/active_extend/_one_to_many_inputs.html.erb +7 -0
- data/app/views/active_extend/_one_to_many_inputs_fields.html.erb +10 -0
- data/app/views/active_extend/_one_to_many_inputs_with_glyph.html.erb +21 -0
- data/app/views/business_activities/_business_activity.html.erb +0 -0
- data/app/views/business_activities/_form.html.erb +25 -0
- data/app/views/business_activities/edit.html.erb +6 -0
- data/app/views/business_activities/index.html.erb +33 -0
- data/app/views/business_activities/new.html.erb +5 -0
- data/app/views/business_activities/show.html.erb +15 -0
- data/app/views/business_departments/_form.html.erb +10 -0
- data/app/views/business_departments/edit.html.erb +6 -0
- data/app/views/business_departments/index.html.erb +33 -0
- data/app/views/business_departments/new.html.erb +5 -0
- data/app/views/business_departments/show.html.erb +15 -0
- data/app/views/business_segments/_business_segment.html.erb +8 -0
- data/app/views/business_segments/_form.html.erb +25 -0
- data/app/views/business_segments/edit.html.erb +6 -0
- data/app/views/business_segments/index.html.erb +33 -0
- data/app/views/business_segments/new.html.erb +5 -0
- data/app/views/business_segments/show.html.erb +15 -0
- data/app/views/company_businesses/_form.html.erb +10 -0
- data/app/views/company_businesses/edit.html.erb +6 -0
- data/app/views/company_businesses/index.html.erb +25 -0
- data/app/views/company_businesses/new.html.erb +5 -0
- data/app/views/company_businesses/show.html.erb +15 -0
- data/app/views/contacts/_form.html.erb +53 -0
- data/app/views/contacts/_header.html.erb +3 -0
- data/app/views/contacts/_list.html.erb +46 -0
- data/app/views/contacts/_side_panel.html.erb +61 -0
- data/app/views/contacts/edit.html.erb +6 -0
- data/app/views/contacts/index.html.erb +72 -0
- data/app/views/contacts/new.html.erb +5 -0
- data/app/views/contacts/show.html.erb +52 -0
- data/app/views/customers/_businesses_done.html.erb +18 -0
- data/app/views/customers/_customer_segment.html.erb +9 -0
- data/app/views/customers/_form.html.erb +177 -0
- data/app/views/customers/_form_search.html.erb +119 -0
- data/app/views/customers/_modules.html.erb +6 -0
- data/app/views/customers/_navbar.html.erb +23 -0
- data/app/views/customers/_segment.html.erb +10 -0
- data/app/views/customers/edit.html.erb +8 -0
- data/app/views/customers/index.html.erb +46 -0
- data/app/views/customers/new.pj.html.erb +4 -0
- data/app/views/customers/show.pj.html.erb +200 -0
- data/app/views/devise/confirmations/new.html.erb +12 -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 +16 -0
- data/app/views/devise/passwords/new.html.erb +12 -0
- data/app/views/devise/registrations/edit.html.erb +25 -0
- data/app/views/devise/registrations/new.html.erb +18 -0
- data/app/views/devise/sessions/new.html.erb +24 -0
- data/app/views/devise/shared/_links.erb +25 -0
- data/app/views/devise/unlocks/new.html.erb +12 -0
- data/app/views/emails/_email_fields.html.erb +1 -0
- data/app/views/layouts/_active_admin_footer.html.erb +4 -0
- data/app/views/layouts/_active_admin_header.html.erb +5 -0
- data/app/views/layouts/_footer.html.erb +12 -0
- data/app/views/layouts/_header.html.erb +51 -0
- data/app/views/layouts/_shim.html.erb +3 -0
- data/app/views/layouts/active_admin.html.arb +1 -0
- data/app/views/layouts/application.html.erb +24 -0
- data/app/views/microposts/_micropost.html.erb +11 -0
- data/app/views/sessions/new.html.erb +18 -0
- data/app/views/shared/_calendar.html.erb +17 -0
- data/app/views/shared/_error_messages.html.erb +13 -0
- data/app/views/shared/_feed.html.erb +10 -0
- data/app/views/shared/_feed_item.html.erb +15 -0
- data/app/views/shared/_micropost_form.html.erb +7 -0
- data/app/views/shared/_multi_selection.html.erb +16 -0
- data/app/views/shared/_multi_selection.html_checkbox.erb +11 -0
- data/app/views/shared/_multi_selection_autocomple.html.erb +5 -0
- data/app/views/shared/_notifies.html.erb +17 -0
- data/app/views/shared/_user_info.html.erb +14 -0
- data/app/views/static_pages/about.html.erb +5 -0
- data/app/views/static_pages/contact.html.erb +5 -0
- data/app/views/static_pages/help.html.erb +5 -0
- data/app/views/static_pages/home.html.erb +37 -0
- data/app/views/static_pages/news.html.erb +2 -0
- data/app/views/system_task_status/_form.html.erb +9 -0
- data/app/views/system_task_status/edit.html.erb +6 -0
- data/app/views/system_task_status/index.html.erb +23 -0
- data/app/views/system_task_status/new.html.erb +5 -0
- data/app/views/system_task_status/show.html.erb +10 -0
- data/app/views/task_feedbacks/_list.html.erb +51 -0
- data/app/views/task_feedbacks/_side_form.html.erb +56 -0
- data/app/views/task_feedbacks/_side_panel.html.erb +64 -0
- data/app/views/task_types/_form.html.erb +10 -0
- data/app/views/task_types/edit.html.erb +6 -0
- data/app/views/task_types/index.html.erb +23 -0
- data/app/views/task_types/new.html.erb +5 -0
- data/app/views/task_types/show.html.erb +10 -0
- data/app/views/tasks/_form.html.erb +52 -0
- data/app/views/tasks/_header.html.erb +3 -0
- data/app/views/tasks/_list.html.erb +50 -0
- data/app/views/tasks/_side_panel.html.erb +64 -0
- data/app/views/tasks/create.js.erb +1 -0
- data/app/views/tasks/edit.html.erb +6 -0
- data/app/views/tasks/index.html.erb +61 -0
- data/app/views/tasks/new.html.erb +5 -0
- data/app/views/tasks/show.html.erb +46 -0
- data/app/views/tests/ajaxes/_form.html.erb +10 -0
- data/app/views/tests/ajaxes/_list.html.erb +6 -0
- data/app/views/tests/ajaxes/add_and_update.html.erb +22 -0
- data/app/views/tests/ajaxes/all.js.erb +2 -0
- data/app/views/tests/ajaxes/edit.html.erb +6 -0
- data/app/views/tests/ajaxes/index.html.erb +25 -0
- data/app/views/tests/ajaxes/new.html.erb +5 -0
- data/app/views/tests/ajaxes/show.html.erb +15 -0
- data/app/views/tests/js.js +51 -0
- data/app/views/tests/lab_ajax/multiselection.html.erb +84 -0
- data/app/views/users/_user.html.erb +8 -0
- data/app/views/users/edit.html.erb +27 -0
- data/app/views/users/index.html.erb +9 -0
- data/app/views/users/new.html.erb +24 -0
- data/app/views/users/show.html.erb +26 -0
- data/bundle +0 -0
- data/config.ru +4 -0
- data/config/application.rb +73 -0
- data/config/boot.rb +6 -0
- data/config/database.yml +38 -0
- data/config/environment.rb +31 -0
- data/config/environments/development.rb +42 -0
- data/config/environments/production.rb +68 -0
- data/config/environments/test.rb +39 -0
- data/config/guara/menus.rb +34 -0
- data/config/initializers/active_admin.rb +210 -0
- data/config/initializers/backtrace_silencers.rb +7 -0
- data/config/initializers/cmgb_rules.rb +2 -0
- data/config/initializers/devise.rb +216 -0
- data/config/initializers/formtastic.rb +77 -0
- data/config/initializers/inflections.rb +19 -0
- data/config/initializers/json_paches_utf8.rb +13 -0
- data/config/initializers/kaminari.rb +21 -0
- data/config/initializers/locale.rb +7 -0
- data/config/initializers/meta_search.rb +10 -0
- data/config/initializers/mime_types.rb +5 -0
- data/config/initializers/secret_token.rb +7 -0
- data/config/initializers/session_store.rb +8 -0
- data/config/initializers/string.rb +9 -0
- data/config/initializers/wrap_parameters.rb +14 -0
- data/config/locales/devise.en.yml +57 -0
- data/config/locales/devise.pt-BR.yml +62 -0
- data/config/locales/pt-BR.yml +404 -0
- data/config/routes.rb +129 -0
- data/db/migrate/20120610142404_create_users.rb +10 -0
- data/db/migrate/20120610183820_add_index_to_users_email.rb +5 -0
- data/db/migrate/20120610185217_add_password_digest_to_users.rb +5 -0
- data/db/migrate/20120612000411_add_remember_token_to_users.rb +6 -0
- data/db/migrate/20120616162515_add_admin_to_users.rb +5 -0
- data/db/migrate/20120616215835_create_microposts.rb +11 -0
- data/db/migrate/20120617224530_create_relationships.rb +14 -0
- data/db/migrate/20120621095918_create_customers.rb +36 -0
- data/db/migrate/20120621100528_create_customer_pfs.rb +14 -0
- data/db/migrate/20120621100534_create_customer_pjs.rb +13 -0
- data/db/migrate/20120621100557_create_emails.rb +13 -0
- data/db/migrate/20120621100618_create_tasks.rb +26 -0
- data/db/migrate/20120621100639_create_customer_products.rb +14 -0
- data/db/migrate/20120621100705_create_districts.rb +11 -0
- data/db/migrate/20120621100720_create_cities.rb +11 -0
- data/db/migrate/20120624192444_create_business_segments.rb +10 -0
- data/db/migrate/20120624224245_create_business_activities.rb +13 -0
- data/db/migrate/20120628092744_create_customer_activities.rb +9 -0
- data/db/migrate/20120628092754_create_customer_segments.rb +9 -0
- data/db/migrate/20120703102859_create_states.rb +10 -0
- data/db/migrate/20120705121011_create_contacts.rb +18 -0
- data/db/migrate/20120711233943_add_devise_to_users.rb +56 -0
- data/db/migrate/20120723102847_create_user_abilities.rb +10 -0
- data/db/migrate/20120723104500_create_system_modules.rb +9 -0
- data/db/migrate/20120723104639_create_system_abilities.rb +9 -0
- data/db/migrate/20120728181903_create_user_groups.rb +10 -0
- data/db/migrate/20120729112600_create_users_has_groups.rb +14 -0
- data/db/migrate/20120729121922_add_groups_to_users.rb +6 -0
- data/db/migrate/20120910002835_create_system_task_status.rb +7 -0
- data/db/migrate/20120910010153_create_system_task_resolutions.rb +7 -0
- data/db/migrate/20120911021535_create_task_types.rb +10 -0
- data/db/migrate/20120911070836_create_task_feedbacks.rb +14 -0
- data/db/migrate/20120924022719_create_tests_ajaxes.rb +10 -0
- data/db/migrate/20121007131035_create_business_departments.rb +10 -0
- data/db/migrate/20121013120849_add_notes_and_other_contacts_to_customer.rb +5 -0
- data/db/migrate/20121014201255_create_company_businesses.rb +10 -0
- data/db/migrate/20121014202449_add_company_business_to_task_type.rb +6 -0
- data/db/migrate/20121014212430_add_primary_company_business_to_user.rb +5 -0
- data/db/migrate/20121015101844_add_parent_id_to_system_task_resolution.rb +5 -0
- data/db/migrate/20121026231241_create_customer_has_customers.rb +10 -0
- data/db/migrate/20121026232755_create_customer_pj_has_customers_pjs.rb +10 -0
- data/db/migrate/20121029094047_create_admin_notes.rb +17 -0
- data/db/migrate/20121029094048_move_admin_notes_to_comments.rb +25 -0
- data/db/migrate/20121103183646_add_enabled_to_cities.rb +5 -0
- data/db/migrate/20121104135014_create_customer_financials.rb +17 -0
- data/db/migrate/20121104141751_create_addresses.rb +19 -0
- data/db/migrate/20121205150619_add_type_id_to_users.rb +5 -0
- data/db/schema.rb~ +378 -0
- data/db/seeds.rb +99 -0
- data/gemfiles/Gemfile.rails.3.2.x +82 -0
- data/guara.gemspec +31 -0
- data/lib/active_extend/README.md +19 -0
- data/lib/active_extend/active_disablable.rb +59 -0
- data/lib/active_extend/string_helper.rb +9 -0
- data/lib/active_migration.rb +4 -0
- data/lib/active_migration/converters/rtf_to_html.rb +123 -0
- data/lib/active_migration/dictionary.rb +19 -0
- data/lib/active_migration/migration.rb +211 -0
- data/lib/active_migration/schemas.rb +143 -0
- data/lib/active_migration/spelling_fix.rb +20 -0
- data/lib/active_migration/transformer/grouped_field_fixed_spelling.rb +110 -0
- data/lib/assets/.gitkeep +0 -0
- data/lib/cmgb_rules/app/models/task.rb +19 -0
- data/lib/guara/version.rb +3 -0
- data/lib/spec/asserts/sheet1.xls +0 -0
- data/lib/spec/lib/active_migration_schemas_spec.rb +40 -0
- data/lib/spec/lib/active_migration_spec.rb +78 -0
- data/lib/spec/spec_helper.rb +121 -0
- data/lib/spec/support/active_migration_helper.rb +109 -0
- data/lib/spec/support/utilities.rb +7 -0
- data/lib/tasks/.gitkeep +0 -0
- data/lib/tasks/add_privilegies.rake +6 -0
- data/lib/tasks/external_migration.rake +22 -0
- data/lib/tasks/sample_data.rake +77 -0
- data/lib/tasks/smaple_data_test.rake +13 -0
- data/lib/templates/erb/scaffold/_form.html.erb +11 -0
- data/public/404.html +26 -0
- data/public/422.html +26 -0
- data/public/500.html +25 -0
- data/public/data.txt +1 -0
- data/public/favicon.ico +0 -0
- data/public/javascripts/autocomplete-rails.js +16 -0
- data/public/robots.txt +5 -0
- data/script/create_db +5 -0
- data/script/rails +6 -0
- data/script/recreate_db +5 -0
- data/script/recreate_db.bat +9 -0
- data/script/recreate_db_test +5 -0
- data/script/recreate_development_db +10 -0
- data/spec/controllers/business_activities_controller_spec.disabled +167 -0
- data/spec/controllers/business_departments_controller_spec.disabled +164 -0
- data/spec/controllers/business_segments_controller_spec.disabled +165 -0
- data/spec/controllers/company_businesses_controller_spec.disabled +164 -0
- data/spec/controllers/system_task_status_controller_spec.disabled +164 -0
- data/spec/controllers/system_task_status_spec.disabled +11 -0
- data/spec/controllers/task_types_controller_spec.disabled +164 -0
- data/spec/controllers/tasks_controller_spec.disabled +23 -0
- data/spec/controllers/tests/ajaxes_controller_spec.disabled +164 -0
- data/spec/factories.rb +101 -0
- data/spec/factories/addresses.rb +13 -0
- data/spec/factories/business_departments.rb +8 -0
- data/spec/factories/company_businesses.rb +8 -0
- data/spec/factories/customer_financials.rb +11 -0
- data/spec/factories/customer_has_customers.rb +8 -0
- data/spec/factories/customer_pj_has_customers_pjs.rb +8 -0
- data/spec/factories/system_task_resolutions.rb +7 -0
- data/spec/factories/system_task_status.rb +7 -0
- data/spec/factories/task.rb +17 -0
- data/spec/factories/task_feedbacks.rb +19 -0
- data/spec/factories/task_types.rb +8 -0
- data/spec/factories/tests_ajaxes.rb +8 -0
- data/spec/helpers/business_activities_helper_spec.rb +15 -0
- data/spec/helpers/business_departments_helper_spec.rb +15 -0
- data/spec/helpers/business_segments_helper_spec.rb +15 -0
- data/spec/helpers/company_businesses_helper_spec.rb +15 -0
- data/spec/helpers/customers/contacts_helper_spec.rb +15 -0
- data/spec/helpers/menu_helper_spec.rb +25 -0
- data/spec/helpers/tests/ajaxes_helper_spec.rb +15 -0
- data/spec/helpers/users_helpers_spec.rb +32 -0
- data/spec/models/address_spec.rb +5 -0
- data/spec/models/business_activity_spec.rb +5 -0
- data/spec/models/business_department_spec.rb +5 -0
- data/spec/models/business_segment_spec.rb +5 -0
- data/spec/models/city_spec.rb +5 -0
- data/spec/models/company_business_spec.rb +19 -0
- data/spec/models/contact_spec.rb +60 -0
- data/spec/models/customer_activity_spec.rb +5 -0
- data/spec/models/customer_financial_spec.rb +48 -0
- data/spec/models/customer_has_customers_spec.rb +18 -0
- data/spec/models/customer_pf_spec.rb +24 -0
- data/spec/models/customer_pj_has_customers_pj_spec.rb +34 -0
- data/spec/models/customer_pj_spec.rb +72 -0
- data/spec/models/customer_product_spec.rb +5 -0
- data/spec/models/customer_segment_spec.rb +5 -0
- data/spec/models/customer_spec.rb +135 -0
- data/spec/models/district_spec.rb +5 -0
- data/spec/models/emails_spec.rb +24 -0
- data/spec/models/micropost_spec.rb +49 -0
- data/spec/models/relationship_spec.rb +38 -0
- data/spec/models/state_spec.rb +5 -0
- data/spec/models/system_ability_spec.rb +5 -0
- data/spec/models/system_module_spec.rb +5 -0
- data/spec/models/system_task_resolution_spec.rb +17 -0
- data/spec/models/system_task_status_spec.rb +17 -0
- data/spec/models/task_feedback_spec.rb +46 -0
- data/spec/models/task_spec.rb +176 -0
- data/spec/models/task_type_spec.rb +27 -0
- data/spec/models/tests/ajax_spec.rb +5 -0
- data/spec/models/user_ability_spec.rb +35 -0
- data/spec/models/user_group_spec.rb +26 -0
- data/spec/models/user_spec.rb +274 -0
- data/spec/models/users_has_groups_spec.rb +29 -0
- data/spec/requests/authentication_pages_spec.rb +157 -0
- data/spec/requests/business_activities_spec.rb +7 -0
- data/spec/requests/business_departments_spec.rb +7 -0
- data/spec/requests/business_segments_spec.rb +7 -0
- data/spec/requests/company_businesses_spec.rb +11 -0
- data/spec/requests/customer_contacts_pages_spec.rb +96 -0
- data/spec/requests/customer_pages_spec.rb +60 -0
- data/spec/requests/micropost_pages_spec.rb +58 -0
- data/spec/requests/static_pages_spec.rb +57 -0
- data/spec/requests/task_pages_spec.rb +124 -0
- data/spec/requests/tests/tests_ajaxes_spec.rb +11 -0
- data/spec/requests/user_abilities_pages_spec.rb +73 -0
- data/spec/requests/user_pages_spec.rb +116 -0
- data/spec/routing/business_activities_routing_spec.rb +35 -0
- data/spec/routing/business_departments_routing_spec.rb +35 -0
- data/spec/routing/business_segments_routing_spec.rb +35 -0
- data/spec/routing/company_businesses_routing_spec.rb +35 -0
- data/spec/routing/system_task_status_routing_spec.rb +35 -0
- data/spec/routing/task_types_routing_spec.rb +35 -0
- data/spec/routing/tests/ajaxes_routing_spec.rb +35 -0
- data/spec/spec_helper.rb +123 -0
- data/spec/support/custom_matchers.rb +9 -0
- data/spec/support/utilities.rb +120 -0
- data/spec/views/business_departments/edit.html.erb_spec.rb +20 -0
- data/spec/views/business_departments/index.html.erb_spec.disabled +23 -0
- data/spec/views/business_departments/new.html.erb_spec.rb +20 -0
- data/spec/views/business_departments/show.html.erb_spec.rb +17 -0
- data/spec/views/company_businesses/edit.html.erb_spec.rb +20 -0
- data/spec/views/company_businesses/index.html.erb_spec.rb +23 -0
- data/spec/views/company_businesses/new.html.erb_spec.rb +20 -0
- data/spec/views/company_businesses/show.html.erb_spec.rb +17 -0
- data/spec/views/task_types/edit.html.erb_spec.rb +18 -0
- data/spec/views/task_types/index.html.erb_spec.rb +20 -0
- data/spec/views/task_types/new.html.erb_spec.rb +18 -0
- data/spec/views/task_types/show.html.erb_spec.rb +15 -0
- data/test/fixtures/.gitkeep +0 -0
- data/test/functional/.gitkeep +0 -0
- data/test/integration/.gitkeep +0 -0
- data/test/performance/browsing_test.rb +12 -0
- data/test/test_helper.rb +13 -0
- data/test/unit/.gitkeep +0 -0
- data/vendor/assets/javascripts/.gitkeep +0 -0
- data/vendor/assets/stylesheets/.gitkeep +0 -0
- data/vendor/assets/stylesheets/active_admin/_base.css.scss +45 -0
- data/vendor/assets/stylesheets/active_admin/_forms.css.scss +270 -0
- data/vendor/assets/stylesheets/active_admin/_header.css.scss +137 -0
- data/vendor/assets/stylesheets/active_admin/_mixins.css.scss +1 -0
- data/vendor/assets/stylesheets/active_admin/_typography.css.scss +100 -0
- data/vendor/assets/stylesheets/active_admin/components/_batch_actions.css.scss +11 -0
- data/vendor/assets/stylesheets/active_admin/components/_blank_slates.scss +31 -0
- data/vendor/assets/stylesheets/active_admin/components/_breadcrumbs.scss +20 -0
- data/vendor/assets/stylesheets/active_admin/components/_buttons.scss +11 -0
- data/vendor/assets/stylesheets/active_admin/components/_columns.scss +3 -0
- data/vendor/assets/stylesheets/active_admin/components/_comments.css.scss +40 -0
- data/vendor/assets/stylesheets/active_admin/components/_date_picker.css.scss +123 -0
- data/vendor/assets/stylesheets/active_admin/components/_dropdown_menu.scss +151 -0
- data/vendor/assets/stylesheets/active_admin/components/_flash_messages.css.scss +39 -0
- data/vendor/assets/stylesheets/active_admin/components/_grid.scss +9 -0
- data/vendor/assets/stylesheets/active_admin/components/_links.scss +5 -0
- data/vendor/assets/stylesheets/active_admin/components/_pagination.scss +34 -0
- data/vendor/assets/stylesheets/active_admin/components/_panels.scss +6 -0
- data/vendor/assets/stylesheets/active_admin/components/_popovers.css.scss +123 -0
- data/vendor/assets/stylesheets/active_admin/components/_scopes.scss +10 -0
- data/vendor/assets/stylesheets/active_admin/components/_status_tags.scss +12 -0
- data/vendor/assets/stylesheets/active_admin/components/_table_tools.css.scss +94 -0
- data/vendor/assets/stylesheets/active_admin/components/_tables.css.scss +108 -0
- data/vendor/assets/stylesheets/active_admin/mixins/_all.css.scss +11 -0
- data/vendor/assets/stylesheets/active_admin/mixins/_buttons.css.scss +66 -0
- data/vendor/assets/stylesheets/active_admin/mixins/_gradients.css.scss +37 -0
- data/vendor/assets/stylesheets/active_admin/mixins/_icons.css.scss +24 -0
- data/vendor/assets/stylesheets/active_admin/mixins/_reset.css.scss +165 -0
- data/vendor/assets/stylesheets/active_admin/mixins/_rounded.css.scss +43 -0
- data/vendor/assets/stylesheets/active_admin/mixins/_sections.css.scss +36 -0
- data/vendor/assets/stylesheets/active_admin/mixins/_shadows.css.scss +22 -0
- data/vendor/assets/stylesheets/active_admin/mixins/_typography.scss +3 -0
- data/vendor/assets/stylesheets/active_admin/mixins/_utilities.scss +26 -0
- data/vendor/assets/stylesheets/active_admin/mixins/_variables.css.scss +24 -0
- data/vendor/assets/stylesheets/active_admin/pages/_dashboard.scss +5 -0
- data/vendor/assets/stylesheets/active_admin/pages/_logged_out.scss +44 -0
- data/vendor/assets/stylesheets/active_admin/print.css.scss +290 -0
- data/vendor/assets/stylesheets/active_admin/structure/_footer.scss +14 -0
- data/vendor/assets/stylesheets/active_admin/structure/_main_structure.scss +26 -0
- data/vendor/assets/stylesheets/active_admin/structure/_title_bar.scss +44 -0
- data/vendor/plugins/.gitkeep +0 -0
- metadata +731 -0
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe SystemTaskResolution do
|
4
|
+
|
5
|
+
let(:system_task_status) { SystemTaskResolution.RESOLVED }
|
6
|
+
|
7
|
+
subject { system_task_status }
|
8
|
+
|
9
|
+
it { should respond_to(:name) }
|
10
|
+
|
11
|
+
it { SystemTaskResolution.should respond_to(:RESOLVED) }
|
12
|
+
it { SystemTaskResolution.should respond_to(:CANCELED) }
|
13
|
+
it { SystemTaskResolution.should respond_to(:BLOCKED) }
|
14
|
+
|
15
|
+
it { should be_valid }
|
16
|
+
|
17
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe SystemTaskStatus do
|
4
|
+
|
5
|
+
let(:system_task_status) { SystemTaskStatus.OPENED }
|
6
|
+
|
7
|
+
subject { system_task_status }
|
8
|
+
|
9
|
+
it { should respond_to(:name) }
|
10
|
+
|
11
|
+
it { SystemTaskStatus.should respond_to(:OPENED) }
|
12
|
+
it { SystemTaskStatus.should respond_to(:IN_PROGRESS) }
|
13
|
+
it { SystemTaskStatus.should respond_to(:PAUSED) }
|
14
|
+
it { SystemTaskStatus.should respond_to(:CLOSED) }
|
15
|
+
|
16
|
+
it { should be_valid }
|
17
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe TaskFeedback do
|
4
|
+
|
5
|
+
let(:task) { Factory(:task, status: SystemTaskStatus.CLOSED, resolution: SystemTaskResolution.RESOLVED) }
|
6
|
+
let(:user) { Factory(:user) }
|
7
|
+
|
8
|
+
before do
|
9
|
+
# able(user, :read, :task)
|
10
|
+
# able(user, :update, :task)
|
11
|
+
# able(user, :read, :task_feedback)
|
12
|
+
# able(user, :update, :task_feedback)
|
13
|
+
@task_feedback = TaskFeedback.create(task: task,
|
14
|
+
date: 1.day.ago,
|
15
|
+
notes: Faker::Lorem.sentence(7),
|
16
|
+
user: user,
|
17
|
+
status: task.status,
|
18
|
+
resolution: SystemTaskResolution.RESOLVED);
|
19
|
+
end
|
20
|
+
|
21
|
+
subject { @task_feedback }
|
22
|
+
|
23
|
+
it { should respond_to(:task_id) }
|
24
|
+
it { should respond_to(:date) }
|
25
|
+
it { should respond_to(:notes) }
|
26
|
+
it { should respond_to(:user_id) }
|
27
|
+
it { should respond_to(:status_id) }
|
28
|
+
it { should respond_to(:resolution_id) }
|
29
|
+
|
30
|
+
it { should be_valid }
|
31
|
+
|
32
|
+
it "feedback should included in task" do
|
33
|
+
task.feedbacks.should include(@task_feedback)
|
34
|
+
end
|
35
|
+
|
36
|
+
describe "not filled required fields" do
|
37
|
+
before do
|
38
|
+
@task_feedback.notes = ''
|
39
|
+
@task_feedback.resolution = nil
|
40
|
+
end
|
41
|
+
|
42
|
+
it { should be_invalid }
|
43
|
+
end
|
44
|
+
|
45
|
+
|
46
|
+
end
|
@@ -0,0 +1,176 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Task do
|
4
|
+
|
5
|
+
|
6
|
+
before(:all) { clear_test_dummy }
|
7
|
+
|
8
|
+
let(:customer_pj) { FactoryGirl.create(:customer_pj) }
|
9
|
+
let(:contact) { FactoryGirl.create(:contact, customer: customer_pj.customer) }
|
10
|
+
let(:user) { user = FactoryGirl.create(:user) }
|
11
|
+
|
12
|
+
before do
|
13
|
+
|
14
|
+
@task = Task.create(name: "task "+Faker::Lorem.sentence(4)[0..52],
|
15
|
+
interested: customer_pj,
|
16
|
+
contact: contact,
|
17
|
+
user: user,
|
18
|
+
assigned: user,
|
19
|
+
notes: Faker::Lorem.sentence(60)[0..139],
|
20
|
+
description: Faker::Lorem.sentence(140)[0..999],
|
21
|
+
due_time: Date.today + 10.days,
|
22
|
+
finish_time: nil,
|
23
|
+
status: SystemTaskStatus.OPENED,
|
24
|
+
resolution: nil,
|
25
|
+
type: FactoryGirl.create(:task_type)
|
26
|
+
)
|
27
|
+
|
28
|
+
end
|
29
|
+
|
30
|
+
subject { @task }
|
31
|
+
|
32
|
+
it { should respond_to(:interested) }
|
33
|
+
it { should respond_to(:name) }
|
34
|
+
it { should respond_to(:contact) }
|
35
|
+
it { should respond_to(:user) }
|
36
|
+
it { should respond_to(:assigned) }
|
37
|
+
it { should respond_to(:notes) }
|
38
|
+
it { should respond_to(:description) }
|
39
|
+
it { should respond_to(:due_time) }
|
40
|
+
it { should respond_to(:finish_time) }
|
41
|
+
it { should respond_to(:status) }
|
42
|
+
it { should respond_to(:resolution) }
|
43
|
+
it { should respond_to(:type) }
|
44
|
+
it { should respond_to(:assigned) }
|
45
|
+
it { should respond_to(:feedbacks) }
|
46
|
+
|
47
|
+
it { should respond_to(:done?) }
|
48
|
+
it { should respond_to(:done) }
|
49
|
+
it { should respond_to(:due_critical_level) }
|
50
|
+
|
51
|
+
it { should be_valid }
|
52
|
+
|
53
|
+
describe "specials accessible fields" do
|
54
|
+
it "attr user must be accessible" do
|
55
|
+
expect do
|
56
|
+
@task.user = nil
|
57
|
+
end.to_not raise_error(ActiveModel::MassAssignmentSecurity::Error)
|
58
|
+
end
|
59
|
+
|
60
|
+
it "attr status must be accessible" do
|
61
|
+
expect do
|
62
|
+
@task.status = nil
|
63
|
+
end.to_not raise_error(ActiveModel::MassAssignmentSecurity::Error)
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
describe "required fields must be checked" do
|
68
|
+
before do
|
69
|
+
@task.status = SystemTaskStatus.CLOSED
|
70
|
+
@task.resolution = SystemTaskResolution.RESOLVED
|
71
|
+
end
|
72
|
+
|
73
|
+
describe "and invalid status equals nil" do
|
74
|
+
before { @task.status = nil }
|
75
|
+
it { should be_invalid }
|
76
|
+
end
|
77
|
+
|
78
|
+
describe "and invalid user equals nil" do
|
79
|
+
before { @task.user = nil }
|
80
|
+
it { should be_invalid }
|
81
|
+
end
|
82
|
+
|
83
|
+
describe "invalid status for RESOLVED and OPENED" do
|
84
|
+
before { @task.status = SystemTaskStatus.OPENED }
|
85
|
+
it { should be_invalid }
|
86
|
+
end
|
87
|
+
|
88
|
+
describe "invalid notes is empty" do
|
89
|
+
before { @task.notes = '' }
|
90
|
+
it { should be_invalid }
|
91
|
+
end
|
92
|
+
|
93
|
+
describe "invalid name" do
|
94
|
+
before { @task.name = 'a' }
|
95
|
+
it { should be_invalid }
|
96
|
+
end
|
97
|
+
|
98
|
+
describe "empty name" do
|
99
|
+
before { @task.name = '' }
|
100
|
+
it { should be_invalid }
|
101
|
+
end
|
102
|
+
|
103
|
+
describe "empty status is invalid" do
|
104
|
+
before do
|
105
|
+
@task.status = nil
|
106
|
+
end
|
107
|
+
|
108
|
+
it { should be_invalid }
|
109
|
+
end
|
110
|
+
end
|
111
|
+
|
112
|
+
describe "is done and valid" do
|
113
|
+
before do
|
114
|
+
@task.resolution = SystemTaskResolution.RESOLVED
|
115
|
+
@task.status = SystemTaskStatus.CLOSED
|
116
|
+
end
|
117
|
+
|
118
|
+
it { should be_valid }
|
119
|
+
end
|
120
|
+
|
121
|
+
|
122
|
+
describe "STATUS is OPENED and resolution is not valid" do
|
123
|
+
before { @task.status = SystemTaskStatus.OPENED }
|
124
|
+
|
125
|
+
describe "try RESOLVED resolution" do
|
126
|
+
before { @task.resolution = SystemTaskResolution.RESOLVED }
|
127
|
+
it { should be_invalid }
|
128
|
+
end
|
129
|
+
|
130
|
+
describe "try CANCELED resolution" do
|
131
|
+
before { @task.resolution = SystemTaskResolution.CANCELED }
|
132
|
+
it { should be_invalid }
|
133
|
+
end
|
134
|
+
|
135
|
+
|
136
|
+
describe "try BLOCKED resolution" do
|
137
|
+
before { @task.resolution = SystemTaskResolution.BLOCKED }
|
138
|
+
it { should be_invalid }
|
139
|
+
end
|
140
|
+
end
|
141
|
+
|
142
|
+
describe "associated with a CUSTOMER destroyed, must also be destroyed" do
|
143
|
+
it { expect { customer_pj.customer.destroy_fully }.to change{ Task.count }.by(-1*customer_pj.customer.tasks.count) }
|
144
|
+
end
|
145
|
+
|
146
|
+
it "STATUS is CLOSE" do
|
147
|
+
@task.status = SystemTaskStatus.CLOSED
|
148
|
+
should be_done
|
149
|
+
end
|
150
|
+
|
151
|
+
describe "due time ending" do
|
152
|
+
|
153
|
+
it "overdue" do
|
154
|
+
@task.due_time = 2.days.ago
|
155
|
+
@task.due_critical_level.should be(3)
|
156
|
+
end
|
157
|
+
|
158
|
+
it "4 days remain its critical, level is 2" do
|
159
|
+
@task.due_time = Time.now + 3.days
|
160
|
+
@task.due_critical_level.should be(2)
|
161
|
+
end
|
162
|
+
|
163
|
+
it "Long time remaining, critical level 1" do
|
164
|
+
@task.due_time = Time.now + 200.days
|
165
|
+
@task.due_critical_level.should be(1)
|
166
|
+
end
|
167
|
+
|
168
|
+
|
169
|
+
it "and tasks is done, critical level is 0" do
|
170
|
+
@task.due_time = 2.days.ago
|
171
|
+
@task.done
|
172
|
+
@task.due_critical_level.should be(0)
|
173
|
+
end
|
174
|
+
end
|
175
|
+
|
176
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe TaskType do
|
4
|
+
|
5
|
+
let(:type) { TaskType.new(name: Faker::Name.first_name) }
|
6
|
+
|
7
|
+
subject { type }
|
8
|
+
|
9
|
+
it { should respond_to(:name) }
|
10
|
+
it { should respond_to(:company_business)}
|
11
|
+
it { should be_valid }
|
12
|
+
|
13
|
+
it { TaskType.should respond_to(:for_business)}
|
14
|
+
|
15
|
+
|
16
|
+
describe "Company Business" do
|
17
|
+
before do
|
18
|
+
type.company_business = Factory(:company_business)
|
19
|
+
@another = Factory(:company_business)
|
20
|
+
type.save!
|
21
|
+
end
|
22
|
+
|
23
|
+
it { TaskType.for_business(type.company_business).should include(type) }
|
24
|
+
it { TaskType.for_business(@another).should_not include(type) }
|
25
|
+
end
|
26
|
+
|
27
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe UserAbility do
|
4
|
+
|
5
|
+
let!(:user) { FactoryGirl.create(:user) }
|
6
|
+
|
7
|
+
before do
|
8
|
+
@user_ability = UserAbility.create!(:skilled => user,
|
9
|
+
:ability => SystemAbility.READ,
|
10
|
+
:module => SystemModule.CUSTOMER)
|
11
|
+
|
12
|
+
user.reload
|
13
|
+
end
|
14
|
+
|
15
|
+
subject { @user_ability }
|
16
|
+
|
17
|
+
it { should respond_to :skilled }
|
18
|
+
it { should respond_to :ability }
|
19
|
+
it { should respond_to :module }
|
20
|
+
it { should respond_to :garant }
|
21
|
+
it { UserAbility.should respond_to :for }
|
22
|
+
|
23
|
+
it { should be_valid }
|
24
|
+
|
25
|
+
describe "garant ability to user read cutomers " do
|
26
|
+
it { user.abilities.should include @user_ability }
|
27
|
+
end
|
28
|
+
|
29
|
+
describe "list user abilities for module" do
|
30
|
+
it "customer" do
|
31
|
+
UserAbility.for(user, SystemModule.CUSTOMER).should include SystemAbility.READ
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe UserGroup do
|
4
|
+
|
5
|
+
before do
|
6
|
+
@users_group = UserGroup.new( name: "Operators" )
|
7
|
+
end
|
8
|
+
|
9
|
+
subject { @users_group }
|
10
|
+
|
11
|
+
it { should respond_to :name }
|
12
|
+
it { should respond_to :abilities }
|
13
|
+
it { should be_valid }
|
14
|
+
|
15
|
+
describe "Have abilities" do
|
16
|
+
before do
|
17
|
+
@user_abillity_1 = @users_group.abilities.build(:ability => SystemAbility.READ, :module => SystemModule.CUSTOMER)
|
18
|
+
@user_abillity_2 = @users_group.abilities.build(:ability => SystemAbility.CREATE, :module => SystemModule.CUSTOMER)
|
19
|
+
end
|
20
|
+
it { should be_valid }
|
21
|
+
|
22
|
+
its (:abilities) { should == [@user_abillity_1, @user_abillity_2] }
|
23
|
+
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
@@ -0,0 +1,274 @@
|
|
1
|
+
# == Schema Information
|
2
|
+
#
|
3
|
+
# Table name: users
|
4
|
+
#
|
5
|
+
# id :integer not null, primary key
|
6
|
+
# name :string(25)
|
7
|
+
# email :string(100)
|
8
|
+
# created_at :datetime not null
|
9
|
+
# updated_at :datetime not null
|
10
|
+
#
|
11
|
+
|
12
|
+
require 'spec_helper'
|
13
|
+
|
14
|
+
include UsersHelper
|
15
|
+
|
16
|
+
describe User do
|
17
|
+
|
18
|
+
before(:all) { clear_test_dummy }
|
19
|
+
|
20
|
+
before do
|
21
|
+
@user = User.new(name: "Example User", email: "user@example.com",
|
22
|
+
password: "foobar", password_confirmation: "foobar")
|
23
|
+
end
|
24
|
+
|
25
|
+
subject { @user }
|
26
|
+
|
27
|
+
let(:found_user) { User.find_by_email(@user.email)?:found_user:@user }
|
28
|
+
|
29
|
+
it { should respond_to(:name) }
|
30
|
+
it { should respond_to(:email) }
|
31
|
+
it { should respond_to(:password_digest) }
|
32
|
+
it { should respond_to(:password) }
|
33
|
+
it { should respond_to(:password_confirmation) }
|
34
|
+
it { should respond_to(:remember_token) }
|
35
|
+
|
36
|
+
it { should respond_to(:microposts) }
|
37
|
+
it { should respond_to(:feed) }
|
38
|
+
|
39
|
+
#colaboration
|
40
|
+
it { should respond_to(:relationships) }
|
41
|
+
it { should respond_to(:followed_users) }
|
42
|
+
it { should respond_to(:following?) }
|
43
|
+
it { should respond_to(:follow!) }
|
44
|
+
it { should respond_to(:followers) }
|
45
|
+
|
46
|
+
#groups
|
47
|
+
it { should respond_to :groups }
|
48
|
+
it { should respond_to :primary_group }
|
49
|
+
it { should respond_to :secundary_groups }
|
50
|
+
|
51
|
+
it { should respond_to(:admin) }
|
52
|
+
|
53
|
+
it { should respond_to(:primary_company_business) }
|
54
|
+
|
55
|
+
it { should be_valid }
|
56
|
+
it { should_not be_admin }
|
57
|
+
|
58
|
+
it { respond_to :able? }
|
59
|
+
|
60
|
+
describe "when name is not present" do
|
61
|
+
before { @user.name = " " }
|
62
|
+
it { should_not be_valid }
|
63
|
+
end
|
64
|
+
|
65
|
+
describe "when email format is invalid" do
|
66
|
+
it "should be invalid" do
|
67
|
+
addresses = %w[user@foo,com user_at_foo.org example.user@foo.
|
68
|
+
foo@bar_baz.com foo@bar+baz.com]
|
69
|
+
addresses.each do |invalid_address|
|
70
|
+
@user.email = invalid_address
|
71
|
+
@user.should_not be_valid
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
describe "when email format is valid" do
|
77
|
+
it "should be valid" do
|
78
|
+
addresses = %w[user@foo.COM A_US-ER@f.b.org frst.lst@foo.jp a+b@baz.cn]
|
79
|
+
addresses.each do |valid_address|
|
80
|
+
@user.email = valid_address
|
81
|
+
@user.should be_valid
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
describe "when email address is already taken" do
|
87
|
+
before do
|
88
|
+
user_with_same_email = @user.dup
|
89
|
+
user_with_same_email.email = @user.email.upcase
|
90
|
+
user_with_same_email.save
|
91
|
+
end
|
92
|
+
|
93
|
+
it { should_not be_valid }
|
94
|
+
end
|
95
|
+
|
96
|
+
#PASSWORDS TESTS <================================================
|
97
|
+
|
98
|
+
describe "when password is not present" do
|
99
|
+
before { @user.password = @user.password_confirmation = " " }
|
100
|
+
it { should_not be_valid }
|
101
|
+
end
|
102
|
+
|
103
|
+
describe "when password doesn't match confirmation" do
|
104
|
+
before { @user.password_confirmation = "mismatch" }
|
105
|
+
it { should_not be_valid }
|
106
|
+
end
|
107
|
+
|
108
|
+
describe "when password confirmation is nil" do
|
109
|
+
before { @user.password_confirmation = nil }
|
110
|
+
it { should_not be_valid }
|
111
|
+
end
|
112
|
+
|
113
|
+
describe "with a password that's too short" do
|
114
|
+
before { @user.password = @user.password_confirmation = "a" * 5 }
|
115
|
+
it { should be_invalid }
|
116
|
+
end
|
117
|
+
|
118
|
+
describe "email address with mixed case" do
|
119
|
+
let(:mixed_case_email) { "Foo@ExAMPle.CoM" }
|
120
|
+
|
121
|
+
it "should be saved as all lower-case" do
|
122
|
+
@user.email = mixed_case_email
|
123
|
+
@user.save
|
124
|
+
@user.reload.email.should == mixed_case_email.downcase
|
125
|
+
end
|
126
|
+
end
|
127
|
+
|
128
|
+
#AUTHENTICATION <================================================
|
129
|
+
=begin
|
130
|
+
describe "return value of authenticate method" do
|
131
|
+
before { @user.save }
|
132
|
+
let(:found_user) { User.find_by_email(@user.email) }
|
133
|
+
|
134
|
+
describe "with valid password" do
|
135
|
+
it { should == found_user.authenticate(@user.password) }
|
136
|
+
end
|
137
|
+
|
138
|
+
describe "with invalid password" do
|
139
|
+
let(:user_for_invalid_password) { found_user.authenticate("invalid") }
|
140
|
+
|
141
|
+
it { should_not == user_for_invalid_password }
|
142
|
+
specify { user_for_invalid_password.should be_false }
|
143
|
+
end
|
144
|
+
end
|
145
|
+
=end
|
146
|
+
|
147
|
+
#REMEMBER <================================================
|
148
|
+
|
149
|
+
describe "remember token" do
|
150
|
+
before { @user.save }
|
151
|
+
its(:remember_token) { should_not be_blank }
|
152
|
+
end
|
153
|
+
|
154
|
+
|
155
|
+
#ADMIN <================================================
|
156
|
+
|
157
|
+
describe "with admin attribute set to 'true'" do
|
158
|
+
before { @user.toggle!(:admin) }
|
159
|
+
it { should be_admin }
|
160
|
+
|
161
|
+
it "attr admin must be accessible" do
|
162
|
+
expect do
|
163
|
+
@user.toggle!(:admin)
|
164
|
+
end.to_not raise_error(ActiveModel::MassAssignmentSecurity::Error)
|
165
|
+
end
|
166
|
+
|
167
|
+
end
|
168
|
+
|
169
|
+
#MICROPOSTS <==============================================
|
170
|
+
|
171
|
+
describe "micropost associations" do
|
172
|
+
|
173
|
+
before { @user.save }
|
174
|
+
let!(:older_micropost) do
|
175
|
+
FactoryGirl.create(:micropost, user: @user, created_at: 1.day.ago)
|
176
|
+
end
|
177
|
+
let!(:newer_micropost) do
|
178
|
+
FactoryGirl.create(:micropost, user: @user, created_at: 1.hour.ago)
|
179
|
+
end
|
180
|
+
|
181
|
+
it "should have the right microposts in the right order" do
|
182
|
+
@user.microposts.should == [newer_micropost, older_micropost]
|
183
|
+
end
|
184
|
+
|
185
|
+
it "should destroy associated microposts" do
|
186
|
+
microposts = @user.microposts
|
187
|
+
@user.destroy_fully
|
188
|
+
microposts.each do |micropost|
|
189
|
+
Micropost.find_by_id(micropost.id).should be_nil
|
190
|
+
end
|
191
|
+
end
|
192
|
+
|
193
|
+
describe "status" do
|
194
|
+
let(:unfollowed_post) do
|
195
|
+
FactoryGirl.create(:micropost, user: FactoryGirl.create(:user))
|
196
|
+
end
|
197
|
+
|
198
|
+
its(:feed) { should include(newer_micropost) }
|
199
|
+
its(:feed) { should include(older_micropost) }
|
200
|
+
its(:feed) { should_not include(unfollowed_post) }
|
201
|
+
end
|
202
|
+
end
|
203
|
+
|
204
|
+
#FOLLOWING<===================================================
|
205
|
+
|
206
|
+
describe "following" do
|
207
|
+
let(:other_user) { FactoryGirl.create(:user) }
|
208
|
+
before do
|
209
|
+
@user.save
|
210
|
+
@user.follow!(other_user)
|
211
|
+
end
|
212
|
+
|
213
|
+
it { should be_following(other_user) }
|
214
|
+
its(:followed_users) { should include(other_user) }
|
215
|
+
|
216
|
+
describe "and unfollowing" do
|
217
|
+
before { @user.unfollow!(other_user) }
|
218
|
+
|
219
|
+
it { should_not be_following(other_user) }
|
220
|
+
its(:followed_users) { should_not include(other_user) }
|
221
|
+
end
|
222
|
+
|
223
|
+
it { should be_following(other_user) }
|
224
|
+
its(:followed_users) { should include(other_user) }
|
225
|
+
|
226
|
+
describe "followed user" do
|
227
|
+
subject { other_user }
|
228
|
+
its(:followers) { should include(@user) }
|
229
|
+
end
|
230
|
+
|
231
|
+
end
|
232
|
+
|
233
|
+
|
234
|
+
#User and Groups<=============================================
|
235
|
+
|
236
|
+
describe "have a primary group or not " do
|
237
|
+
it(:primary_group) { @user.primary_group = UserGroup.first }
|
238
|
+
it { should be_valid }
|
239
|
+
end
|
240
|
+
|
241
|
+
describe "have many groups" do
|
242
|
+
let(:group_primary) { UserGroup.first }
|
243
|
+
let(:group_secs) { [FactoryGirl.create(:user_group), FactoryGirl.create(:user_group)] }
|
244
|
+
before do
|
245
|
+
@user.primary_group = group_primary
|
246
|
+
@user.secundary_groups = group_secs
|
247
|
+
@user.save!
|
248
|
+
end
|
249
|
+
|
250
|
+
its (:groups) { should include(group_secs[0]) }
|
251
|
+
its (:groups) { should include(group_secs[1]) }
|
252
|
+
|
253
|
+
end
|
254
|
+
|
255
|
+
|
256
|
+
|
257
|
+
describe "user able?" do
|
258
|
+
before do
|
259
|
+
able(@user, :create, :customer)
|
260
|
+
able(@user, :read, :user)
|
261
|
+
end
|
262
|
+
|
263
|
+
it { @user.able?(SystemModule.CUSTOMER, SystemAbility.CREATE).should be_true }
|
264
|
+
it { @user.able?(SystemModule.USER, SystemAbility.READ).should be_true }
|
265
|
+
it { @user.able?(SystemModule.USER, SystemAbility.CREATE).should_not be_true }
|
266
|
+
end
|
267
|
+
|
268
|
+
|
269
|
+
describe "tasks" do
|
270
|
+
let(:task) { FactoryGirl.create(:task, user: @user) }
|
271
|
+
it { @user.tasks.should include(task) }
|
272
|
+
end
|
273
|
+
|
274
|
+
end
|