fat_free_crm 0.17.2 → 0.19.0
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of fat_free_crm might be problematic. Click here for more details.
- checksums.yaml +5 -5
- data/.rubocop.yml +1 -1
- data/.rubocop_todo.yml +71 -148
- data/.travis.yml +35 -14
- data/CHANGELOG.md +88 -5
- data/CONTRIBUTORS.md +96 -53
- data/Dockerfile +45 -14
- data/Gemfile +23 -13
- data/Gemfile.lock +249 -241
- data/Procfile +1 -1
- data/README.md +9 -6
- data/Rakefile +1 -1
- data/app/assets/javascripts/crm.js.coffee +3 -3
- data/app/assets/javascripts/crm_select2.js.coffee +15 -14
- data/app/assets/stylesheets/common.scss +1 -1
- data/app/controllers/admin/application_controller.rb +1 -1
- data/app/controllers/admin/field_groups_controller.rb +9 -4
- data/app/controllers/admin/fields_controller.rb +4 -4
- data/app/controllers/admin/groups_controller.rb +1 -1
- data/app/controllers/admin/tags_controller.rb +2 -4
- data/app/controllers/admin/users_controller.rb +5 -8
- data/app/controllers/application_controller.rb +22 -45
- data/app/controllers/comments_controller.rb +16 -11
- data/{config/initializers/authlogic.rb → app/controllers/confirmations_controller.rb} +4 -2
- data/app/controllers/emails_controller.rb +0 -2
- data/app/controllers/entities/accounts_controller.rb +1 -3
- data/app/controllers/entities/campaigns_controller.rb +8 -5
- data/app/controllers/entities/contacts_controller.rb +4 -24
- data/app/controllers/entities/leads_controller.rb +16 -12
- data/app/controllers/entities/opportunities_controller.rb +17 -16
- data/app/controllers/entities_controller.rb +31 -12
- data/app/controllers/home_controller.rb +2 -4
- data/app/controllers/lists_controller.rb +5 -1
- data/app/controllers/passwords_controller.rb +3 -59
- data/{spec/features/support/maintain_sessions.rb → app/controllers/registrations_controller.rb} +12 -5
- data/{lib/development_tasks/gem.rake → app/controllers/sessions_controller.rb} +6 -6
- data/app/controllers/tasks_controller.rb +22 -17
- data/app/controllers/users_controller.rb +8 -29
- data/app/helpers/accounts_helper.rb +1 -1
- data/app/helpers/admin/users_helper.rb +1 -1
- data/app/helpers/application_helper.rb +28 -33
- data/app/helpers/campaigns_helper.rb +1 -1
- data/app/helpers/contacts_helper.rb +1 -3
- data/app/helpers/leads_helper.rb +1 -1
- data/app/helpers/opportunities_helper.rb +48 -3
- data/app/helpers/tags_helper.rb +1 -1
- data/app/helpers/tasks_helper.rb +1 -1
- data/app/helpers/users_helper.rb +1 -3
- data/{config/initializers/paper_trail.rb → app/mailers/devise_mailer.rb} +5 -1
- data/app/mailers/user_mailer.rb +0 -9
- data/app/models/entities/account.rb +10 -10
- data/app/models/entities/campaign.rb +4 -6
- data/app/models/entities/contact.rb +24 -12
- data/app/models/entities/lead.rb +7 -14
- data/app/models/entities/opportunity.rb +10 -11
- data/app/models/fields/custom_field.rb +1 -0
- data/app/models/fields/custom_field_date_pair.rb +2 -0
- data/app/models/fields/field.rb +1 -3
- data/app/models/list.rb +1 -1
- data/app/models/observers/entity_observer.rb +3 -7
- data/app/models/observers/lead_observer.rb +2 -4
- data/app/models/observers/opportunity_observer.rb +5 -7
- data/app/models/observers/task_observer.rb +1 -1
- data/app/models/polymorphic/email.rb +2 -2
- data/app/models/polymorphic/task.rb +13 -9
- data/app/models/polymorphic/version.rb +3 -2
- data/app/models/setting.rb +2 -0
- data/app/models/users/ability.rb +3 -4
- data/app/models/users/permission.rb +3 -3
- data/app/models/users/preference.rb +2 -1
- data/app/models/users/user.rb +67 -42
- data/app/views/accounts/_top_section.html.haml +1 -1
- data/app/views/accounts/edit.js.haml +1 -1
- data/app/views/accounts/update.js.haml +2 -2
- data/app/views/admin/users/_user.html.haml +4 -4
- data/app/views/campaigns/_metrics.html.haml +3 -3
- data/app/views/contacts/_index_brief.html.haml +1 -1
- data/app/views/contacts/_index_full.html.haml +1 -1
- data/app/views/contacts/_index_long.html.haml +1 -1
- data/app/views/devise/confirmations/new.html.haml +9 -0
- data/app/views/devise/mailer/confirmation_instructions.html.haml +4 -0
- data/app/views/devise/mailer/password_change.html.haml +3 -0
- data/app/views/devise/mailer/reset_password_instructions.html.haml +6 -0
- data/app/views/devise/passwords/edit.html.haml +18 -0
- data/app/views/devise/passwords/new.html.haml +10 -0
- data/app/views/devise/registrations/new.html.haml +21 -0
- data/app/views/devise/sessions/new.html.haml +32 -0
- data/app/views/home/_opportunity.html.haml +4 -19
- data/app/views/layouts/_about.html.haml +5 -5
- data/app/views/layouts/_header.html.haml +3 -3
- data/app/views/layouts/admin/_header.html.haml +1 -1
- data/app/views/opportunities/_index_long.html.haml +1 -24
- data/app/views/opportunities/_sidebar_show.html.haml +3 -3
- data/app/views/opportunities/_top_section.html.haml +1 -1
- data/app/views/shared/_address.html.haml +5 -5
- data/app/views/shared/_paginate_with_per_page.html.haml +1 -0
- data/app/views/users/_avatar.html.haml +1 -1
- data/bin/bundle +1 -1
- data/bin/rails +1 -1
- data/bin/setup +38 -0
- data/bin/update +33 -0
- data/bin/yarn +13 -0
- data/config/application.rb +8 -6
- data/config/boot.rb +1 -1
- data/config/brakeman.ignore +2 -2
- data/config/database.postgres.docker.yml +5 -5
- data/config/environment.rb +1 -1
- data/config/environments/development.rb +1 -0
- data/config/environments/test.rb +7 -0
- data/config/initializers/action_mailer.rb +1 -3
- data/config/initializers/application_controller_renderer.rb +9 -0
- data/config/initializers/assets.rb +6 -11
- data/config/initializers/backtrace_silencers.rb +0 -6
- data/config/initializers/content_security_policy.rb +26 -0
- data/config/initializers/cookies_serializer.rb +3 -6
- data/config/initializers/devise.rb +289 -0
- data/config/initializers/filter_parameter_logging.rb +0 -5
- data/config/initializers/gravatar.rb +0 -1
- data/config/initializers/inflections.rb +0 -6
- data/config/initializers/mime_types.rb +1 -9
- data/config/initializers/new_framework_defaults_5_2.rb +40 -0
- data/config/initializers/relative_url_root.rb +1 -3
- data/config/initializers/session_store.rb +1 -3
- data/config/initializers/wrap_parameters.rb +4 -9
- data/config/locales/fat_free_crm.en-GB.yml +5 -5
- data/config/locales/fat_free_crm.en-US.yml +5 -5
- data/config/locales/fat_free_crm.fr.yml +1 -1
- data/config/locales/fat_free_crm.ru.yml +1 -0
- data/config/routes.rb +20 -9
- data/db/demo/users.yml +62 -81
- data/db/migrate/20100928030620_remove_uuid.rb +1 -2
- data/db/migrate/20120316045804_activities_to_versions.rb +1 -0
- data/db/migrate/20120510025219_add_not_null_constraints_for_timestamp_columns.rb +1 -0
- data/db/migrate/20180107082701_authlogic_to_devise.rb +58 -0
- data/db/schema.rb +48 -46
- data/docker-compose.yml +10 -0
- data/fat_free_crm.gemspec +12 -14
- data/lib/development_tasks/license.rake +2 -2
- data/lib/fat_free_crm/callback.rb +2 -2
- data/lib/fat_free_crm/comment_extensions.rb +2 -4
- data/lib/fat_free_crm/core_ext/string.rb +1 -1
- data/lib/fat_free_crm/engine.rb +2 -2
- data/lib/fat_free_crm/errors.rb +1 -1
- data/lib/fat_free_crm/export_csv.rb +1 -0
- data/lib/fat_free_crm/exportable.rb +1 -1
- data/lib/fat_free_crm/fields.rb +2 -2
- data/lib/fat_free_crm/gem_dependencies.rb +1 -1
- data/lib/fat_free_crm/gem_ext/simple_form/action_view_extensions/form_helper.rb +1 -3
- data/lib/fat_free_crm/i18n.rb +2 -2
- data/lib/fat_free_crm/mail_processor/base.rb +4 -10
- data/lib/fat_free_crm/mail_processor/dropbox.rb +5 -15
- data/lib/fat_free_crm/permissions.rb +7 -18
- data/lib/fat_free_crm/sortable.rb +1 -1
- data/lib/fat_free_crm/tabs.rb +2 -2
- data/lib/fat_free_crm/version.rb +2 -2
- data/lib/gravatar_image_tag.rb +7 -8
- data/lib/missing_translation_detector.rb +1 -0
- data/lib/tasks/ffcrm/missing_translations.rake +1 -0
- data/lib/tasks/ffcrm/setup.rake +13 -4
- data/lib/tasks/ffcrm/update_data.rake +2 -2
- data/script/rails +2 -2
- data/spec/controllers/admin/users_controller_spec.rb +25 -81
- data/spec/controllers/comments_controller_spec.rb +19 -19
- data/spec/controllers/emails_controller_spec.rb +2 -2
- data/spec/controllers/entities/accounts_controller_spec.rb +56 -56
- data/spec/controllers/entities/campaigns_controller_spec.rb +66 -66
- data/spec/controllers/entities/contacts_controller_spec.rb +69 -68
- data/spec/controllers/entities/leads_controller_spec.rb +126 -126
- data/spec/controllers/entities/opportunities_controller_spec.rb +101 -101
- data/spec/controllers/entities_controller_spec.rb +5 -0
- data/spec/controllers/home_controller_spec.rb +30 -30
- data/spec/controllers/tasks_controller_spec.rb +42 -40
- data/spec/controllers/users_controller_spec.rb +43 -113
- data/spec/factories/account_factories.rb +13 -13
- data/spec/factories/campaign_factories.rb +8 -8
- data/spec/factories/contact_factories.rb +18 -18
- data/spec/factories/field_factories.rb +11 -10
- data/spec/factories/lead_factories.rb +13 -13
- data/spec/factories/list_factories.rb +3 -3
- data/spec/factories/opportunity_factories.rb +9 -9
- data/spec/factories/sequences.rb +1 -1
- data/spec/factories/setting_factories.rb +5 -5
- data/spec/factories/shared_factories.rb +25 -23
- data/spec/factories/subscription_factories.rb +1 -1
- data/spec/factories/tag_factories.rb +1 -1
- data/spec/factories/task_factories.rb +11 -11
- data/spec/factories/user_factories.rb +27 -30
- data/spec/features/accounts_spec.rb +17 -4
- data/spec/features/admin/groups_spec.rb +2 -2
- data/spec/features/admin/users_spec.rb +4 -2
- data/spec/features/campaigns_spec.rb +5 -5
- data/spec/features/contacts_spec.rb +11 -5
- data/spec/features/dashboard_spec.rb +8 -8
- data/spec/features/devise/sign_in_spec.rb +58 -0
- data/spec/features/devise/sign_up_spec.rb +36 -0
- data/spec/features/leads_spec.rb +5 -5
- data/spec/features/opportunities_overview_spec.rb +16 -16
- data/spec/features/opportunities_spec.rb +35 -9
- data/spec/features/support/autocomlete_helper.rb +17 -0
- data/spec/features/support/browser.rb +5 -9
- data/spec/features/tasks_spec.rb +5 -5
- data/spec/helpers/admin/field_groups_helper_spec.rb +1 -1
- data/spec/helpers/application_helper_spec.rb +1 -1
- data/spec/helpers/tasks_helper_spec.rb +1 -1
- data/spec/helpers/users_helper_spec.rb +7 -7
- data/spec/lib/comment_extensions_spec.rb +11 -5
- data/spec/lib/errors_spec.rb +2 -2
- data/spec/lib/mail_processor/base_spec.rb +3 -3
- data/spec/lib/mail_processor/comment_replies_spec.rb +3 -3
- data/spec/lib/mail_processor/dropbox_spec.rb +17 -17
- data/spec/lib/mail_processor/sample_emails/dropbox.rb +8 -8
- data/spec/lib/permissions_spec.rb +15 -28
- data/spec/mailers/devise_mailer_spec.rb +35 -0
- data/spec/mailers/user_mailer_spec.rb +6 -32
- data/spec/models/entities/account_spec.rb +58 -32
- data/spec/models/entities/campaign_spec.rb +18 -25
- data/spec/models/entities/contact_spec.rb +113 -21
- data/spec/models/entities/lead_spec.rb +9 -11
- data/spec/models/entities/opportunity_spec.rb +45 -45
- data/spec/models/fields/custom_field_date_pair_spec.rb +4 -2
- data/spec/models/fields/custom_field_spec.rb +21 -19
- data/spec/models/list_spec.rb +2 -2
- data/spec/models/observers/entity_observer_spec.rb +7 -7
- data/spec/models/polymorphic/address_spec.rb +1 -1
- data/spec/models/polymorphic/avatar_spec.rb +5 -5
- data/spec/models/polymorphic/comment_spec.rb +5 -5
- data/spec/models/polymorphic/task_spec.rb +65 -58
- data/spec/models/polymorphic/version_spec.rb +31 -31
- data/spec/models/setting_spec.rb +2 -2
- data/spec/models/users/preference_spec.rb +6 -6
- data/spec/models/users/user_spec.rb +46 -50
- data/spec/routing/users_routing_spec.rb +30 -8
- data/spec/shared/controllers.rb +3 -9
- data/spec/shared/models.rb +22 -22
- data/spec/spec_helper.rb +12 -4
- data/spec/support/assert_select.rb +1 -0
- data/spec/support/devise_helpers.rb +28 -0
- data/spec/{features/support/helpers.rb → support/feature_helpers.rb} +11 -11
- data/spec/support/macros.rb +7 -4
- data/spec/views/accounts/_edit.haml_spec.rb +1 -1
- data/spec/views/accounts/create.js.haml_spec.rb +2 -2
- data/spec/views/accounts/destroy.js.haml_spec.rb +1 -1
- data/spec/views/accounts/edit.js.haml_spec.rb +2 -2
- data/spec/views/accounts/index.haml_spec.rb +2 -2
- data/spec/views/accounts/index.js.haml_spec.rb +1 -1
- data/spec/views/accounts/show.haml_spec.rb +4 -4
- data/spec/views/accounts/update.js.haml_spec.rb +1 -1
- data/spec/views/admin/field_groups/create.js.haml_spec.rb +1 -1
- data/spec/views/admin/field_groups/destroy.js.haml_spec.rb +1 -1
- data/spec/views/admin/field_groups/edit.js.haml_spec.rb +1 -1
- data/spec/views/admin/field_groups/new.js.haml_spec.rb +1 -1
- data/spec/views/admin/field_groups/update.js.haml_spec.rb +1 -1
- data/spec/views/admin/users/create.js.haml_spec.rb +2 -2
- data/spec/views/admin/users/destroy.js.haml_spec.rb +2 -2
- data/spec/views/admin/users/edit.js.haml_spec.rb +2 -2
- data/spec/views/admin/users/index.haml_spec.rb +1 -1
- data/spec/views/admin/users/index.js.haml_spec.rb +2 -2
- data/spec/views/admin/users/reactivate.js.haml_spec.rb +1 -1
- data/spec/views/admin/users/suspend.js.haml_spec.rb +1 -1
- data/spec/views/admin/users/update.js.haml_spec.rb +1 -1
- data/spec/views/application/auto_complete.haml_spec.rb +3 -3
- data/spec/views/campaigns/_edit.haml_spec.rb +1 -1
- data/spec/views/campaigns/create.js.haml_spec.rb +3 -3
- data/spec/views/campaigns/destroy.js.haml_spec.rb +1 -1
- data/spec/views/campaigns/edit.js.haml_spec.rb +2 -2
- data/spec/views/campaigns/index.haml_spec.rb +1 -1
- data/spec/views/campaigns/index.js.haml_spec.rb +1 -1
- data/spec/views/campaigns/show.haml_spec.rb +4 -4
- data/spec/views/campaigns/update.js.haml_spec.rb +1 -1
- data/spec/views/contacts/_edit.haml_spec.rb +7 -7
- data/spec/views/contacts/_new.haml_spec.rb +1 -1
- data/spec/views/contacts/create.js.haml_spec.rb +4 -4
- data/spec/views/contacts/destroy.js.haml_spec.rb +1 -1
- data/spec/views/contacts/edit.js.haml_spec.rb +3 -3
- data/spec/views/contacts/index.haml_spec.rb +1 -1
- data/spec/views/contacts/index.js.html_spec.rb +1 -1
- data/spec/views/contacts/new.js.haml_spec.rb +1 -1
- data/spec/views/contacts/show.haml_spec.rb +3 -3
- data/spec/views/contacts/update.js.haml_spec.rb +3 -3
- data/spec/views/home/index.haml_spec.rb +1 -1
- data/spec/views/home/index.js.haml_spec.rb +1 -1
- data/spec/views/home/options.js.haml_spec.rb +2 -2
- data/spec/views/leads/_convert.haml_spec.rb +3 -3
- data/spec/views/leads/_edit.haml_spec.rb +2 -2
- data/spec/views/leads/_new.haml_spec.rb +2 -2
- data/spec/views/leads/_sidebar_show.haml_spec.rb +5 -5
- data/spec/views/leads/convert.js.haml_spec.rb +4 -4
- data/spec/views/leads/create.js.haml_spec.rb +5 -5
- data/spec/views/leads/destroy.js.haml_spec.rb +2 -2
- data/spec/views/leads/edit.js.haml_spec.rb +4 -4
- data/spec/views/leads/index.haml_spec.rb +1 -1
- data/spec/views/leads/index.js.haml_spec.rb +1 -1
- data/spec/views/leads/new.js.haml_spec.rb +1 -1
- data/spec/views/leads/promote.js.haml_spec.rb +7 -7
- data/spec/views/leads/reject.js.haml_spec.rb +2 -2
- data/spec/views/leads/show.haml_spec.rb +2 -2
- data/spec/views/leads/update.js.haml_spec.rb +4 -4
- data/spec/views/opportunities/_edit.haml_spec.rb +7 -7
- data/spec/views/opportunities/_new.haml_spec.rb +2 -2
- data/spec/views/opportunities/create.js.haml_spec.rb +6 -6
- data/spec/views/opportunities/destroy.js.haml_spec.rb +3 -3
- data/spec/views/opportunities/edit.js.haml_spec.rb +3 -3
- data/spec/views/opportunities/index.haml_spec.rb +1 -1
- data/spec/views/opportunities/index.js.haml_spec.rb +1 -1
- data/spec/views/opportunities/new.js.haml_spec.rb +1 -1
- data/spec/views/opportunities/show.haml_spec.rb +3 -3
- data/spec/views/opportunities/update.js.haml_spec.rb +5 -5
- data/spec/views/tasks/_edit.haml_spec.rb +1 -1
- data/spec/views/tasks/complete.js.haml_spec.rb +4 -4
- data/spec/views/tasks/create.js.haml_spec.rb +6 -6
- data/spec/views/tasks/destroy.js.haml_spec.rb +2 -2
- data/spec/views/tasks/index.haml_spec.rb +4 -4
- data/spec/views/tasks/new.js.haml_spec.rb +1 -1
- data/spec/views/tasks/uncomplete.js.haml_spec.rb +2 -2
- data/spec/views/tasks/update.js.haml_spec.rb +18 -18
- data/spec/views/users/upload_avatar.js.haml_spec.rb +2 -2
- data/vendor/gems/ransack_ui-1.3.4/.gitignore +17 -0
- data/vendor/gems/ransack_ui-1.3.4/Gemfile +7 -0
- data/vendor/gems/ransack_ui-1.3.4/LICENSE.txt +22 -0
- data/vendor/gems/ransack_ui-1.3.4/README.md +57 -0
- data/vendor/gems/ransack_ui-1.3.4/Rakefile +1 -0
- data/vendor/gems/ransack_ui-1.3.4/app/assets/images/ransack_ui/calendar.png +0 -0
- data/vendor/gems/ransack_ui-1.3.4/app/assets/images/ransack_ui/delete.png +0 -0
- data/vendor/gems/ransack_ui-1.3.4/app/assets/javascripts/ransack/predicates.js.coffee +41 -0
- data/vendor/gems/ransack_ui-1.3.4/app/assets/javascripts/ransack_ui_bootstrap/button_group_select.js.coffee +26 -0
- data/vendor/gems/ransack_ui-1.3.4/app/assets/javascripts/ransack_ui_bootstrap/index.js.coffee +2 -0
- data/vendor/gems/ransack_ui-1.3.4/app/assets/javascripts/ransack_ui_jquery/index.js +2 -0
- data/vendor/gems/ransack_ui-1.3.4/app/assets/javascripts/ransack_ui_jquery/search_form.js.coffee.erb +499 -0
- data/vendor/gems/ransack_ui-1.3.4/app/assets/stylesheets/ransack_ui_bootstrap/index.css +3 -0
- data/vendor/gems/ransack_ui-1.3.4/app/assets/stylesheets/ransack_ui_bootstrap/search.css.scss +41 -0
- data/vendor/gems/ransack_ui-1.3.4/app/views/ransack_ui/_condition_fields.html.erb +15 -0
- data/vendor/gems/ransack_ui-1.3.4/app/views/ransack_ui/_grouping_fields.html.erb +16 -0
- data/vendor/gems/ransack_ui-1.3.4/app/views/ransack_ui/_search.html.erb +29 -0
- data/vendor/gems/ransack_ui-1.3.4/app/views/ransack_ui/_sort_fields.html.erb +4 -0
- data/vendor/gems/ransack_ui-1.3.4/config/locales/en.yml +24 -0
- data/vendor/gems/ransack_ui-1.3.4/lib/ransack_ui.rb +9 -0
- data/vendor/gems/ransack_ui-1.3.4/lib/ransack_ui/adapters/active_record.rb +6 -0
- data/vendor/gems/ransack_ui-1.3.4/lib/ransack_ui/adapters/active_record/base.rb +46 -0
- data/vendor/gems/ransack_ui-1.3.4/lib/ransack_ui/controller_helpers.rb +18 -0
- data/vendor/gems/ransack_ui-1.3.4/lib/ransack_ui/rails/engine.rb +21 -0
- data/vendor/gems/ransack_ui-1.3.4/lib/ransack_ui/ransack_overrides/adapters/active_record/base.rb +47 -0
- data/vendor/gems/ransack_ui-1.3.4/lib/ransack_ui/ransack_overrides/configuration.rb +15 -0
- data/vendor/gems/ransack_ui-1.3.4/lib/ransack_ui/ransack_overrides/context.rb +9 -0
- data/vendor/gems/ransack_ui-1.3.4/lib/ransack_ui/ransack_overrides/helpers/form_builder.rb +262 -0
- data/vendor/gems/ransack_ui-1.3.4/lib/ransack_ui/ransack_overrides/nodes/attribute.rb +13 -0
- data/vendor/gems/ransack_ui-1.3.4/lib/ransack_ui/ransack_overrides/nodes/condition.rb +13 -0
- data/vendor/gems/ransack_ui-1.3.4/lib/ransack_ui/ransack_overrides/nodes/grouping.rb +20 -0
- data/vendor/gems/ransack_ui-1.3.4/lib/ransack_ui/version.rb +3 -0
- data/vendor/gems/ransack_ui-1.3.4/lib/ransack_ui/view_helpers.rb +30 -0
- data/vendor/gems/ransack_ui-1.3.4/ransack_ui.gemspec +23 -0
- metadata +83 -70
- data/app/controllers/authentications_controller.rb +0 -53
- data/app/models/users/authentication.rb +0 -56
- data/app/views/authentications/new.html.haml +0 -19
- data/app/views/passwords/edit.html.haml +0 -15
- data/app/views/passwords/new.html.haml +0 -10
- data/app/views/user_mailer/password_reset_instructions.html.haml +0 -6
- data/app/views/users/new.html.haml +0 -19
- data/spec/controllers/authentications_controller_spec.rb +0 -150
- data/spec/controllers/passwords_controller_spec.rb +0 -32
- data/spec/models/users/authentication_spec.rb +0 -19
- data/spec/support/auth_macros.rb +0 -49
- data/spec/views/authentications/new.haml_spec.rb +0 -31
@@ -18,7 +18,7 @@ describe Admin::UsersController do
|
|
18
18
|
#----------------------------------------------------------------------------
|
19
19
|
describe "GET index" do
|
20
20
|
it "assigns all users as @users and renders [index] template" do
|
21
|
-
@users = [current_user,
|
21
|
+
@users = [current_user, create(:user)]
|
22
22
|
|
23
23
|
get :index
|
24
24
|
expect(assigns[:users].first).to eq(@users.last) # get_users() sorts by id DESC
|
@@ -27,8 +27,8 @@ describe Admin::UsersController do
|
|
27
27
|
end
|
28
28
|
|
29
29
|
it "performs lookup using query string" do
|
30
|
-
@amy =
|
31
|
-
@bob =
|
30
|
+
@amy = create(:user, username: "amy_anderson")
|
31
|
+
@bob = create(:user, username: "bob_builder")
|
32
32
|
|
33
33
|
get :index, params: { query: "amy_anderson" }
|
34
34
|
expect(assigns[:users]).to eq([@amy])
|
@@ -42,7 +42,7 @@ describe Admin::UsersController do
|
|
42
42
|
#----------------------------------------------------------------------------
|
43
43
|
describe "GET show" do
|
44
44
|
it "assigns the requested user as @user and renders [show] template" do
|
45
|
-
@user =
|
45
|
+
@user = create(:user)
|
46
46
|
|
47
47
|
get :show, params: { id: @user.id }
|
48
48
|
expect(assigns[:user]).to eq(@user)
|
@@ -50,22 +50,11 @@ describe Admin::UsersController do
|
|
50
50
|
end
|
51
51
|
end
|
52
52
|
|
53
|
-
# GET /admin/users/new
|
54
|
-
# GET /admin/users/new.xml AJAX
|
55
|
-
#----------------------------------------------------------------------------
|
56
|
-
describe "GET new" do
|
57
|
-
it "assigns a new user as @user and renders [new] template" do
|
58
|
-
get :new, xhr: true
|
59
|
-
expect(assigns[:user]).to be_new_record
|
60
|
-
expect(response).to render_template("admin/users/new")
|
61
|
-
end
|
62
|
-
end
|
63
|
-
|
64
53
|
# GET /admin/users/1/edit AJAX
|
65
54
|
#----------------------------------------------------------------------------
|
66
55
|
describe "GET edit" do
|
67
56
|
it "assigns the requested user as @user and renders [edit] template" do
|
68
|
-
@user =
|
57
|
+
@user = create(:user)
|
69
58
|
|
70
59
|
get :edit, params: { id: @user.id }, xhr: true
|
71
60
|
expect(assigns[:user]).to eq(@user)
|
@@ -74,15 +63,15 @@ describe Admin::UsersController do
|
|
74
63
|
end
|
75
64
|
|
76
65
|
it "assigns the previous user as @previous when necessary" do
|
77
|
-
@user =
|
78
|
-
@previous =
|
66
|
+
@user = create(:user)
|
67
|
+
@previous = create(:user)
|
79
68
|
|
80
69
|
get :edit, params: { id: @user.id, previous: @previous.id }, xhr: true
|
81
70
|
expect(assigns[:previous]).to eq(@previous)
|
82
71
|
end
|
83
72
|
|
84
73
|
it "reloads current page with the flash message if user got deleted" do
|
85
|
-
@user =
|
74
|
+
@user = create(:user)
|
86
75
|
@user.destroy
|
87
76
|
|
88
77
|
get :edit, params: { id: @user.id }, xhr: true
|
@@ -91,8 +80,8 @@ describe Admin::UsersController do
|
|
91
80
|
end
|
92
81
|
|
93
82
|
it "notifies the view if previous user got deleted" do
|
94
|
-
@user =
|
95
|
-
@previous =
|
83
|
+
@user = create(:user)
|
84
|
+
@previous = create(:user)
|
96
85
|
@previous.destroy
|
97
86
|
|
98
87
|
get :edit, params: { id: @user.id, previous: @previous.id }, xhr: true
|
@@ -102,58 +91,13 @@ describe Admin::UsersController do
|
|
102
91
|
end
|
103
92
|
end
|
104
93
|
|
105
|
-
# POST /admin/users
|
106
|
-
# POST /admin/users.xml AJAX
|
107
|
-
#----------------------------------------------------------------------------
|
108
|
-
describe "POST create" do
|
109
|
-
describe "with valid params" do
|
110
|
-
before(:each) do
|
111
|
-
@username = "none"
|
112
|
-
@email = @username + "@example.com"
|
113
|
-
@password = "secret"
|
114
|
-
end
|
115
|
-
|
116
|
-
it "assigns a newly created user as @user and renders [create] template" do
|
117
|
-
@user = FactoryGirl.build(:user, username: @username, email: @email)
|
118
|
-
allow(User).to receive(:new).and_return(@user)
|
119
|
-
|
120
|
-
post :create, params: { user: { username: @username, email: @email, password: @password, password_confirmation: @password } }, xhr: true
|
121
|
-
expect(assigns[:user]).to eq(@user)
|
122
|
-
expect(response).to render_template("admin/users/create")
|
123
|
-
end
|
124
|
-
|
125
|
-
it "creates admin user when requested so" do
|
126
|
-
post :create, params: { user: { username: @username, email: @email, admin: "1", password: @password, password_confirmation: @password } }, xhr: true
|
127
|
-
expect(assigns[:user].admin).to eq(true)
|
128
|
-
expect(response).to render_template("admin/users/create")
|
129
|
-
end
|
130
|
-
|
131
|
-
it "doesn't create admin user unless requested so" do
|
132
|
-
post :create, params: { user: { username: @username, email: @email, admin: "0", password: @password, password_confirmation: @password } }, xhr: true
|
133
|
-
expect(assigns[:user].admin).to eq(false)
|
134
|
-
expect(response).to render_template("admin/users/create")
|
135
|
-
end
|
136
|
-
end
|
137
|
-
|
138
|
-
describe "with invalid params" do
|
139
|
-
it "assigns a newly created but unsaved user as @user and re-renders [create] template" do
|
140
|
-
@user = FactoryGirl.build(:user, username: "", email: "")
|
141
|
-
allow(User).to receive(:new).and_return(@user)
|
142
|
-
|
143
|
-
post :create, params: { user: {} }, xhr: true
|
144
|
-
expect(assigns[:user]).to eq(@user)
|
145
|
-
expect(response).to render_template("admin/users/create")
|
146
|
-
end
|
147
|
-
end
|
148
|
-
end
|
149
|
-
|
150
94
|
# PUT /admin/users/1
|
151
95
|
# PUT /admin/users/1.xml AJAX
|
152
96
|
#----------------------------------------------------------------------------
|
153
97
|
describe "PUT update" do
|
154
98
|
describe "with valid params" do
|
155
99
|
it "updates the requested user, assigns it to @user, and renders [update] template" do
|
156
|
-
@user =
|
100
|
+
@user = create(:user, username: "flip", email: "flip@example.com")
|
157
101
|
|
158
102
|
put :update, params: { id: @user.id, user: { username: "flop", email: "flop@example.com" } }, xhr: true
|
159
103
|
expect(assigns[:user]).to eq(@user.reload)
|
@@ -162,7 +106,7 @@ describe Admin::UsersController do
|
|
162
106
|
end
|
163
107
|
|
164
108
|
it "reloads current page is the user got deleted" do
|
165
|
-
@user =
|
109
|
+
@user = create(:user)
|
166
110
|
@user.destroy
|
167
111
|
|
168
112
|
put :update, params: { id: @user.id, user: { username: "flop", email: "flop@example.com" } }, xhr: true
|
@@ -171,7 +115,7 @@ describe Admin::UsersController do
|
|
171
115
|
end
|
172
116
|
|
173
117
|
it "assigns admin rights when requested so" do
|
174
|
-
@user =
|
118
|
+
@user = create(:user, admin: false)
|
175
119
|
put :update, params: { id: @user.id, user: { admin: "1", username: @user.username, email: @user.email } }, xhr: true
|
176
120
|
expect(assigns[:user]).to eq(@user.reload)
|
177
121
|
expect(assigns[:user].admin).to eq(true)
|
@@ -179,7 +123,7 @@ describe Admin::UsersController do
|
|
179
123
|
end
|
180
124
|
|
181
125
|
it "revokes admin rights when requested so" do
|
182
|
-
@user =
|
126
|
+
@user = create(:user, admin: true)
|
183
127
|
put :update, params: { id: @user.id, user: { admin: "0", username: @user.username, email: @user.email } }, xhr: true
|
184
128
|
expect(assigns[:user]).to eq(@user.reload)
|
185
129
|
expect(assigns[:user].admin).to eq(false)
|
@@ -189,7 +133,7 @@ describe Admin::UsersController do
|
|
189
133
|
|
190
134
|
describe "with invalid params" do
|
191
135
|
it "doesn't update the requested user, but assigns it to @user and renders [update] template" do
|
192
|
-
@user =
|
136
|
+
@user = create(:user, username: "flip", email: "flip@example.com")
|
193
137
|
|
194
138
|
put :update, params: { id: @user.id, user: {} }, xhr: true
|
195
139
|
expect(assigns[:user]).to eq(@user.reload)
|
@@ -203,7 +147,7 @@ describe Admin::UsersController do
|
|
203
147
|
#----------------------------------------------------------------------------
|
204
148
|
describe "GET confirm" do
|
205
149
|
it "assigns the requested user as @user and renders [confirm] template" do
|
206
|
-
@user =
|
150
|
+
@user = create(:user)
|
207
151
|
|
208
152
|
get :confirm, params: { id: @user.id }, xhr: true
|
209
153
|
expect(assigns[:user]).to eq(@user)
|
@@ -211,7 +155,7 @@ describe Admin::UsersController do
|
|
211
155
|
end
|
212
156
|
|
213
157
|
it "reloads current page is the user got deleted" do
|
214
|
-
@user =
|
158
|
+
@user = create(:user)
|
215
159
|
@user.destroy
|
216
160
|
|
217
161
|
get :confirm, params: { id: @user.id }, xhr: true
|
@@ -225,7 +169,7 @@ describe Admin::UsersController do
|
|
225
169
|
#----------------------------------------------------------------------------
|
226
170
|
describe "DELETE destroy" do
|
227
171
|
it "destroys the requested user and renders [destroy] template" do
|
228
|
-
@user =
|
172
|
+
@user = create(:user)
|
229
173
|
|
230
174
|
delete :destroy, params: { id: @user.id }, xhr: true
|
231
175
|
expect { User.find(@user.id) }.to raise_error(ActiveRecord::RecordNotFound)
|
@@ -233,8 +177,8 @@ describe Admin::UsersController do
|
|
233
177
|
end
|
234
178
|
|
235
179
|
it "handles the case when the requested user can't be deleted" do
|
236
|
-
@user =
|
237
|
-
@account =
|
180
|
+
@user = create(:user)
|
181
|
+
@account = create(:account, user: @user) # Plant artifact to prevent the user from being deleted.
|
238
182
|
|
239
183
|
delete :destroy, params: { id: @user.id }, xhr: true
|
240
184
|
expect(flash[:warning]).not_to eq(nil)
|
@@ -247,7 +191,7 @@ describe Admin::UsersController do
|
|
247
191
|
#----------------------------------------------------------------------------
|
248
192
|
describe "POST auto_complete" do
|
249
193
|
before(:each) do
|
250
|
-
@auto_complete_matches = [
|
194
|
+
@auto_complete_matches = [create(:user, first_name: "Hello")]
|
251
195
|
end
|
252
196
|
|
253
197
|
it_should_behave_like("auto complete")
|
@@ -258,7 +202,7 @@ describe Admin::UsersController do
|
|
258
202
|
#----------------------------------------------------------------------------
|
259
203
|
describe "PUT suspend" do
|
260
204
|
it "suspends the requested user" do
|
261
|
-
@user =
|
205
|
+
@user = create(:user)
|
262
206
|
|
263
207
|
put :suspend, params: { id: @user.id }, xhr: true
|
264
208
|
expect(assigns[:user].suspended?).to eq(true)
|
@@ -274,7 +218,7 @@ describe Admin::UsersController do
|
|
274
218
|
end
|
275
219
|
|
276
220
|
it "reloads current page is the user got deleted" do
|
277
|
-
@user =
|
221
|
+
@user = create(:user)
|
278
222
|
@user.destroy
|
279
223
|
|
280
224
|
put :suspend, params: { id: @user.id }, xhr: true
|
@@ -288,7 +232,7 @@ describe Admin::UsersController do
|
|
288
232
|
#----------------------------------------------------------------------------
|
289
233
|
describe "PUT reactivate" do
|
290
234
|
it "re-activates the requested user" do
|
291
|
-
@user =
|
235
|
+
@user = create(:user, suspended_at: Time.now.yesterday)
|
292
236
|
|
293
237
|
put :reactivate, params: { id: @user.id }, xhr: true
|
294
238
|
expect(assigns[:user].suspended?).to eq(false)
|
@@ -296,7 +240,7 @@ describe Admin::UsersController do
|
|
296
240
|
end
|
297
241
|
|
298
242
|
it "reloads current page is the user got deleted" do
|
299
|
-
@user =
|
243
|
+
@user = create(:user)
|
300
244
|
@user.destroy
|
301
245
|
|
302
246
|
put :reactivate, params: { id: @user.id }, xhr: true
|
@@ -21,16 +21,16 @@ describe CommentsController do
|
|
21
21
|
COMMENTABLE.each do |asset|
|
22
22
|
describe "(HTML)" do
|
23
23
|
before(:each) do
|
24
|
-
@asset =
|
24
|
+
@asset = create(asset)
|
25
25
|
end
|
26
26
|
|
27
27
|
it "should redirect to the asset landing page if the asset is found" do
|
28
|
-
get :index, params: {
|
28
|
+
get :index, params: { "#{asset}_id": @asset.id }
|
29
29
|
expect(response).to redirect_to(controller: asset.to_s.pluralize, action: :show, id: @asset.id)
|
30
30
|
end
|
31
31
|
|
32
32
|
it "should redirect to root url with warning if the asset is not found" do
|
33
|
-
get :index, params: {
|
33
|
+
get :index, params: { "#{asset}_id": @asset.id + 42 }
|
34
34
|
expect(flash[:warning]).not_to eq(nil)
|
35
35
|
expect(response).to redirect_to(root_path)
|
36
36
|
end
|
@@ -38,18 +38,18 @@ describe CommentsController do
|
|
38
38
|
|
39
39
|
describe "(JSON)" do
|
40
40
|
before(:each) do
|
41
|
-
@asset =
|
42
|
-
@asset.comments = [
|
41
|
+
@asset = create(asset)
|
42
|
+
@asset.comments = [create(:comment, commentable: @asset)]
|
43
43
|
request.env["HTTP_ACCEPT"] = "application/json"
|
44
44
|
end
|
45
45
|
|
46
46
|
it "should render all comments as JSON if the asset is found found" do
|
47
|
-
get :index, params: {
|
47
|
+
get :index, params: { "#{asset}_id": @asset.id }
|
48
48
|
expect(response.body).to eq(assigns[:comments].to_json)
|
49
49
|
end
|
50
50
|
|
51
51
|
it "JSON: should return 404 (Not Found) JSON error if the asset is not found" do
|
52
|
-
get :index, params: {
|
52
|
+
get :index, params: { "#{asset}_id": @asset.id + 42 }
|
53
53
|
expect(flash[:warning]).not_to eq(nil)
|
54
54
|
expect(response.code).to eq("404")
|
55
55
|
end
|
@@ -57,18 +57,18 @@ describe CommentsController do
|
|
57
57
|
|
58
58
|
describe "(XML)" do
|
59
59
|
before(:each) do
|
60
|
-
@asset =
|
61
|
-
@asset.comments = [
|
60
|
+
@asset = create(asset)
|
61
|
+
@asset.comments = [create(:comment, commentable: @asset)]
|
62
62
|
request.env["HTTP_ACCEPT"] = "application/xml"
|
63
63
|
end
|
64
64
|
|
65
65
|
it "should render all comments as XML if the asset is found found" do
|
66
|
-
get :index, params: {
|
66
|
+
get :index, params: { "#{asset}_id": @asset.id }
|
67
67
|
expect(response.body).to eq(assigns[:comments].to_xml)
|
68
68
|
end
|
69
69
|
|
70
70
|
it "XML: should return 404 (Not Found) XML error if the asset is not found" do
|
71
|
-
get :index, params: {
|
71
|
+
get :index, params: { "#{asset}_id": @asset.id + 42 }
|
72
72
|
expect(flash[:warning]).not_to eq(nil)
|
73
73
|
expect(response.code).to eq("404")
|
74
74
|
end
|
@@ -81,8 +81,8 @@ describe CommentsController do
|
|
81
81
|
describe "responding to GET edit" do
|
82
82
|
COMMENTABLE.each do |asset|
|
83
83
|
it "should expose the requested comment as @commment and render [edit] template" do
|
84
|
-
@asset =
|
85
|
-
@comment =
|
84
|
+
@asset = create(asset)
|
85
|
+
@comment = create(:comment, id: 42, commentable: @asset, user: current_user)
|
86
86
|
allow(Comment).to receive(:new).and_return(@comment)
|
87
87
|
|
88
88
|
get :edit, params: { id: 42 }, xhr: true
|
@@ -99,8 +99,8 @@ describe CommentsController do
|
|
99
99
|
describe "with valid params" do
|
100
100
|
COMMENTABLE.each do |asset|
|
101
101
|
it "should expose a newly created comment as @comment for the #{asset}" do
|
102
|
-
@asset =
|
103
|
-
@comment =
|
102
|
+
@asset = create(asset)
|
103
|
+
@comment = build(:comment, commentable: @asset, user: current_user)
|
104
104
|
allow(Comment).to receive(:new).and_return(@comment)
|
105
105
|
|
106
106
|
post :create, params: { comment: { commentable_type: asset.to_s.classify, commentable_id: @asset.id, user_id: current_user.id, comment: "Hello" } }, xhr: true
|
@@ -113,8 +113,8 @@ describe CommentsController do
|
|
113
113
|
describe "with invalid params" do
|
114
114
|
COMMENTABLE.each do |asset|
|
115
115
|
it "should expose a newly created but unsaved comment as @comment for #{asset}" do
|
116
|
-
@asset =
|
117
|
-
@comment =
|
116
|
+
@asset = create(asset)
|
117
|
+
@comment = build(:comment, commentable: @asset, user: current_user)
|
118
118
|
allow(Comment).to receive(:new).and_return(@comment)
|
119
119
|
|
120
120
|
post :create, params: { comment: {} }, xhr: true
|
@@ -180,8 +180,8 @@ describe CommentsController do
|
|
180
180
|
describe "with valid params" do
|
181
181
|
COMMENTABLE.each do |asset|
|
182
182
|
it "should destroy the requested comment and render [destroy] template" do
|
183
|
-
@asset =
|
184
|
-
@comment =
|
183
|
+
@asset = create(asset)
|
184
|
+
@comment = create(:comment, commentable: @asset, user: current_user)
|
185
185
|
allow(Comment).to receive(:new).and_return(@comment)
|
186
186
|
|
187
187
|
delete :destroy, params: { id: @comment.id }, xhr: true
|
@@ -22,8 +22,8 @@ describe EmailsController, "handling GET /emails" do
|
|
22
22
|
describe "with valid params" do
|
23
23
|
MEDIATOR.each do |asset|
|
24
24
|
it "should destroy the requested email and render [destroy] template" do
|
25
|
-
@asset =
|
26
|
-
@email =
|
25
|
+
@asset = create(asset)
|
26
|
+
@email = create(:email, mediator: @asset, user: current_user)
|
27
27
|
allow(Email).to receive(:new).and_return(@email)
|
28
28
|
|
29
29
|
delete :destroy, params: { id: @email.id }, xhr: true
|
@@ -26,14 +26,14 @@ describe AccountsController do
|
|
26
26
|
end
|
27
27
|
|
28
28
|
it "should expose all accounts as @accounts and render [index] template" do
|
29
|
-
@accounts = [
|
29
|
+
@accounts = [create(:account, user: current_user)]
|
30
30
|
get :index
|
31
31
|
expect(assigns[:accounts]).to eq(@accounts)
|
32
32
|
expect(response).to render_template("accounts/index")
|
33
33
|
end
|
34
34
|
|
35
35
|
it "should collect the data for the accounts sidebar" do
|
36
|
-
@accounts = [
|
36
|
+
@accounts = [create(:account, user: current_user)]
|
37
37
|
|
38
38
|
get :index
|
39
39
|
expect(assigns[:account_category_total].keys.map(&:to_sym) - (@category << :all << :other)).to eq([])
|
@@ -43,19 +43,19 @@ describe AccountsController do
|
|
43
43
|
categories = %w[customer vendor]
|
44
44
|
controller.session[:accounts_filter] = categories.join(',')
|
45
45
|
@accounts = [
|
46
|
-
|
47
|
-
|
46
|
+
create(:account, user: current_user, category: categories.first),
|
47
|
+
create(:account, user: current_user, category: categories.last)
|
48
48
|
]
|
49
49
|
# This one should be filtered out.
|
50
|
-
|
50
|
+
create(:account, user: current_user, category: "competitor")
|
51
51
|
|
52
52
|
get :index
|
53
53
|
expect(assigns[:accounts]).to eq(@accounts)
|
54
54
|
end
|
55
55
|
|
56
56
|
it "should perform lookup using query string" do
|
57
|
-
@first =
|
58
|
-
@second =
|
57
|
+
@first = create(:account, user: current_user, name: "The first one")
|
58
|
+
@second = create(:account, user: current_user, name: "The second one")
|
59
59
|
|
60
60
|
get :index, params: { query: "second" }
|
61
61
|
expect(assigns[:accounts]).to eq([@second])
|
@@ -65,7 +65,7 @@ describe AccountsController do
|
|
65
65
|
|
66
66
|
describe "AJAX pagination" do
|
67
67
|
it "should pick up page number from params" do
|
68
|
-
@accounts = [
|
68
|
+
@accounts = [create(:account, user: current_user)]
|
69
69
|
get :index, params: { page: 42 }, xhr: true
|
70
70
|
|
71
71
|
expect(assigns[:current_page].to_i).to eq(42)
|
@@ -76,7 +76,7 @@ describe AccountsController do
|
|
76
76
|
|
77
77
|
it "should pick up saved page number from session" do
|
78
78
|
session[:accounts_current_page] = 42
|
79
|
-
@accounts = [
|
79
|
+
@accounts = [create(:account, user: current_user)]
|
80
80
|
get :index, xhr: true
|
81
81
|
|
82
82
|
expect(assigns[:current_page]).to eq(42)
|
@@ -87,7 +87,7 @@ describe AccountsController do
|
|
87
87
|
it "should reset current_page when query is altered" do
|
88
88
|
session[:accounts_current_page] = 42
|
89
89
|
session[:accounts_current_query] = "bill"
|
90
|
-
@accounts = [
|
90
|
+
@accounts = [create(:account, user: current_user)]
|
91
91
|
get :index, xhr: true
|
92
92
|
|
93
93
|
expect(assigns[:current_page]).to eq(1)
|
@@ -125,7 +125,7 @@ describe AccountsController do
|
|
125
125
|
describe "responding to GET show" do
|
126
126
|
describe "with mime type of HTML" do
|
127
127
|
before do
|
128
|
-
@account =
|
128
|
+
@account = create(:account, user: current_user)
|
129
129
|
@stage = Setting.unroll(:opportunity_stage)
|
130
130
|
@comment = Comment.new
|
131
131
|
end
|
@@ -146,7 +146,7 @@ describe AccountsController do
|
|
146
146
|
|
147
147
|
describe "with mime type of JSON" do
|
148
148
|
it "should render the requested account as json" do
|
149
|
-
@account =
|
149
|
+
@account = create(:account, user: current_user)
|
150
150
|
expect(Account).to receive(:find).and_return(@account)
|
151
151
|
expect(@account).to receive(:to_json).and_return("generated JSON")
|
152
152
|
|
@@ -158,7 +158,7 @@ describe AccountsController do
|
|
158
158
|
|
159
159
|
describe "with mime type of XML" do
|
160
160
|
it "should render the requested account as xml" do
|
161
|
-
@account =
|
161
|
+
@account = create(:account, user: current_user)
|
162
162
|
expect(Account).to receive(:find).and_return(@account)
|
163
163
|
expect(@account).to receive(:to_xml).and_return("generated XML")
|
164
164
|
|
@@ -170,7 +170,7 @@ describe AccountsController do
|
|
170
170
|
|
171
171
|
describe "account got deleted or otherwise unavailable" do
|
172
172
|
it "should redirect to account index if the account got deleted" do
|
173
|
-
@account =
|
173
|
+
@account = create(:account, user: current_user)
|
174
174
|
@account.destroy
|
175
175
|
|
176
176
|
get :show, params: { id: @account.id }
|
@@ -179,7 +179,7 @@ describe AccountsController do
|
|
179
179
|
end
|
180
180
|
|
181
181
|
it "should redirect to account index if the account is protected" do
|
182
|
-
@private =
|
182
|
+
@private = create(:account, user: create(:user), access: "Private")
|
183
183
|
|
184
184
|
get :show, params: { id: @private.id }
|
185
185
|
expect(flash[:warning]).not_to eq(nil)
|
@@ -187,7 +187,7 @@ describe AccountsController do
|
|
187
187
|
end
|
188
188
|
|
189
189
|
it "should return 404 (Not Found) JSON error" do
|
190
|
-
@account =
|
190
|
+
@account = create(:account, user: current_user)
|
191
191
|
@account.destroy
|
192
192
|
request.env["HTTP_ACCEPT"] = "application/json"
|
193
193
|
|
@@ -196,7 +196,7 @@ describe AccountsController do
|
|
196
196
|
end
|
197
197
|
|
198
198
|
it "should return 404 (Not Found) XML error" do
|
199
|
-
@account =
|
199
|
+
@account = create(:account, user: current_user)
|
200
200
|
@account.destroy
|
201
201
|
request.env["HTTP_ACCEPT"] = "application/xml"
|
202
202
|
|
@@ -220,7 +220,7 @@ describe AccountsController do
|
|
220
220
|
end
|
221
221
|
|
222
222
|
it "should created an instance of related object when necessary" do
|
223
|
-
@contact =
|
223
|
+
@contact = create(:contact, id: 42)
|
224
224
|
|
225
225
|
get :new, params: { related: "contact_42" }, xhr: true
|
226
226
|
expect(assigns[:contact]).to eq(@contact)
|
@@ -231,7 +231,7 @@ describe AccountsController do
|
|
231
231
|
#----------------------------------------------------------------------------
|
232
232
|
describe "responding to GET edit" do
|
233
233
|
it "should expose the requested account as @account and render [edit] template" do
|
234
|
-
@account =
|
234
|
+
@account = create(:account, id: 42, user: current_user)
|
235
235
|
|
236
236
|
get :edit, params: { id: 42 }, xhr: true
|
237
237
|
expect(assigns[:account]).to eq(@account)
|
@@ -240,8 +240,8 @@ describe AccountsController do
|
|
240
240
|
end
|
241
241
|
|
242
242
|
it "should expose previous account as @previous when necessary" do
|
243
|
-
@account =
|
244
|
-
@previous =
|
243
|
+
@account = create(:account, id: 42)
|
244
|
+
@previous = create(:account, id: 41)
|
245
245
|
|
246
246
|
get :edit, params: { id: 42, previous: 41 }, xhr: true
|
247
247
|
expect(assigns[:previous]).to eq(@previous)
|
@@ -249,7 +249,7 @@ describe AccountsController do
|
|
249
249
|
|
250
250
|
describe "(account got deleted or is otherwise unavailable)" do
|
251
251
|
it "should reload current page with the flash message if the account got deleted" do
|
252
|
-
@account =
|
252
|
+
@account = create(:account, user: current_user)
|
253
253
|
@account.destroy
|
254
254
|
|
255
255
|
get :edit, params: { id: @account.id }, xhr: true
|
@@ -258,7 +258,7 @@ describe AccountsController do
|
|
258
258
|
end
|
259
259
|
|
260
260
|
it "should reload current page with the flash message if the account is protected" do
|
261
|
-
@private =
|
261
|
+
@private = create(:account, user: create(:user), access: "Private")
|
262
262
|
|
263
263
|
get :edit, params: { id: @private.id }, xhr: true
|
264
264
|
expect(flash[:warning]).not_to eq(nil)
|
@@ -268,8 +268,8 @@ describe AccountsController do
|
|
268
268
|
|
269
269
|
describe "(previous account got deleted or is otherwise unavailable)" do
|
270
270
|
before do
|
271
|
-
@account =
|
272
|
-
@previous =
|
271
|
+
@account = create(:account, user: current_user)
|
272
|
+
@previous = create(:account, user: create(:user))
|
273
273
|
end
|
274
274
|
|
275
275
|
it "should notify the view if previous account got deleted" do
|
@@ -298,7 +298,7 @@ describe AccountsController do
|
|
298
298
|
describe "responding to POST create" do
|
299
299
|
describe "with valid params" do
|
300
300
|
it "should expose a newly created account as @account and render [create] template" do
|
301
|
-
@account =
|
301
|
+
@account = build(:account, name: "Hello world", user: current_user)
|
302
302
|
allow(Account).to receive(:new).and_return(@account)
|
303
303
|
|
304
304
|
post :create, params: { account: { name: "Hello world" } }, xhr: true
|
@@ -308,7 +308,7 @@ describe AccountsController do
|
|
308
308
|
|
309
309
|
# Note: [Create Account] is shown only on Accounts index page.
|
310
310
|
it "should reload accounts to update pagination" do
|
311
|
-
@account =
|
311
|
+
@account = build(:account, user: current_user)
|
312
312
|
allow(Account).to receive(:new).and_return(@account)
|
313
313
|
|
314
314
|
post :create, params: { account: { name: "Hello" } }, xhr: true
|
@@ -316,7 +316,7 @@ describe AccountsController do
|
|
316
316
|
end
|
317
317
|
|
318
318
|
it "should get data to update account sidebar" do
|
319
|
-
@account =
|
319
|
+
@account = build(:account, name: "Hello", user: current_user)
|
320
320
|
allow(Campaign).to receive(:new).and_return(@account)
|
321
321
|
|
322
322
|
post :create, params: { account: { name: "Hello" } }, xhr: true
|
@@ -324,7 +324,7 @@ describe AccountsController do
|
|
324
324
|
end
|
325
325
|
|
326
326
|
it "should add a new comment to the newly created account when specified" do
|
327
|
-
@account =
|
327
|
+
@account = build(:account, name: "Hello world", user: current_user)
|
328
328
|
allow(Account).to receive(:new).and_return(@account)
|
329
329
|
|
330
330
|
post :create, params: { account: { name: "Hello world" }, comment_body: "Awesome comment is awesome" }, xhr: true
|
@@ -334,7 +334,7 @@ describe AccountsController do
|
|
334
334
|
|
335
335
|
describe "with invalid params" do
|
336
336
|
it "should expose a newly created but unsaved account as @account and still render [create] template" do
|
337
|
-
@account =
|
337
|
+
@account = build(:account, name: nil, user: nil)
|
338
338
|
allow(Account).to receive(:new).and_return(@account)
|
339
339
|
|
340
340
|
post :create, params: { account: {} }, xhr: true
|
@@ -350,7 +350,7 @@ describe AccountsController do
|
|
350
350
|
describe "responding to PUT update" do
|
351
351
|
describe "with valid params" do
|
352
352
|
it "should update the requested account, expose the requested account as @account, and render [update] template" do
|
353
|
-
@account =
|
353
|
+
@account = create(:account, id: 42, name: "Hello people")
|
354
354
|
|
355
355
|
put :update, params: { id: 42, account: { name: "Hello world" } }, xhr: true
|
356
356
|
expect(@account.reload.name).to eq("Hello world")
|
@@ -359,7 +359,7 @@ describe AccountsController do
|
|
359
359
|
end
|
360
360
|
|
361
361
|
it "should get data for accounts sidebar when called from Campaigns index" do
|
362
|
-
@account =
|
362
|
+
@account = create(:account, id: 42)
|
363
363
|
request.env["HTTP_REFERER"] = "http://localhost/accounts"
|
364
364
|
|
365
365
|
put :update, params: { id: 42, account: { name: "Hello" } }, xhr: true
|
@@ -368,7 +368,7 @@ describe AccountsController do
|
|
368
368
|
end
|
369
369
|
|
370
370
|
it "should update account permissions when sharing with specific users" do
|
371
|
-
@account =
|
371
|
+
@account = create(:account, id: 42, access: "Public")
|
372
372
|
|
373
373
|
put :update, params: { id: 42, account: { name: "Hello", access: "Shared", user_ids: [7, 8] } }, xhr: true
|
374
374
|
expect(assigns[:account].access).to eq("Shared")
|
@@ -377,7 +377,7 @@ describe AccountsController do
|
|
377
377
|
|
378
378
|
describe "account got deleted or otherwise unavailable" do
|
379
379
|
it "should reload current page is the account got deleted" do
|
380
|
-
@account =
|
380
|
+
@account = create(:account, user: current_user)
|
381
381
|
@account.destroy
|
382
382
|
|
383
383
|
put :update, params: { id: @account.id }, xhr: true
|
@@ -386,7 +386,7 @@ describe AccountsController do
|
|
386
386
|
end
|
387
387
|
|
388
388
|
it "should reload current page with the flash message if the account is protected" do
|
389
|
-
@private =
|
389
|
+
@private = create(:account, user: create(:user), access: "Private")
|
390
390
|
|
391
391
|
put :update, params: { id: @private.id }, xhr: true
|
392
392
|
expect(flash[:warning]).not_to eq(nil)
|
@@ -397,7 +397,7 @@ describe AccountsController do
|
|
397
397
|
|
398
398
|
describe "with invalid params" do
|
399
399
|
it "should not update the requested account but still expose the requested account as @account, and render [update] template" do
|
400
|
-
@account =
|
400
|
+
@account = create(:account, id: 42, name: "Hello people")
|
401
401
|
|
402
402
|
put :update, params: { id: 42, account: { name: nil } }, xhr: true
|
403
403
|
expect(assigns(:account).reload.name).to eq("Hello people")
|
@@ -412,12 +412,12 @@ describe AccountsController do
|
|
412
412
|
#----------------------------------------------------------------------------
|
413
413
|
describe "responding to DELETE destroy" do
|
414
414
|
before do
|
415
|
-
@account =
|
415
|
+
@account = create(:account, user: current_user)
|
416
416
|
end
|
417
417
|
|
418
418
|
describe "AJAX request" do
|
419
419
|
it "should destroy the requested account and render [destroy] template" do
|
420
|
-
@another_account =
|
420
|
+
@another_account = create(:account, user: current_user)
|
421
421
|
delete :destroy, params: { id: @account.id }, xhr: true
|
422
422
|
|
423
423
|
expect { Account.find(@account.id) }.to raise_error(ActiveRecord::RecordNotFound)
|
@@ -449,7 +449,7 @@ describe AccountsController do
|
|
449
449
|
|
450
450
|
describe "account got deleted or otherwise unavailable" do
|
451
451
|
it "should reload current page is the account got deleted" do
|
452
|
-
@account =
|
452
|
+
@account = create(:account, user: current_user)
|
453
453
|
@account.destroy
|
454
454
|
|
455
455
|
delete :destroy, params: { id: @account.id }, xhr: true
|
@@ -458,7 +458,7 @@ describe AccountsController do
|
|
458
458
|
end
|
459
459
|
|
460
460
|
it "should reload current page with the flash message if the account is protected" do
|
461
|
-
@private =
|
461
|
+
@private = create(:account, user: create(:user), access: "Private")
|
462
462
|
|
463
463
|
delete :destroy, params: { id: @private.id }, xhr: true
|
464
464
|
expect(flash[:warning]).not_to eq(nil)
|
@@ -476,7 +476,7 @@ describe AccountsController do
|
|
476
476
|
end
|
477
477
|
|
478
478
|
it "should redirect to account index with the flash message is the account got deleted" do
|
479
|
-
@account =
|
479
|
+
@account = create(:account, user: current_user)
|
480
480
|
@account.destroy
|
481
481
|
|
482
482
|
delete :destroy, params: { id: @account.id }
|
@@ -485,7 +485,7 @@ describe AccountsController do
|
|
485
485
|
end
|
486
486
|
|
487
487
|
it "should redirect to account index with the flash message if the account is protected" do
|
488
|
-
@private =
|
488
|
+
@private = create(:account, user: create(:user), access: "Private")
|
489
489
|
|
490
490
|
delete :destroy, params: { id: @private.id }
|
491
491
|
expect(flash[:warning]).not_to eq(nil)
|
@@ -500,16 +500,16 @@ describe AccountsController do
|
|
500
500
|
describe "responding to PUT attach" do
|
501
501
|
describe "tasks" do
|
502
502
|
before do
|
503
|
-
@model =
|
504
|
-
@attachment =
|
503
|
+
@model = create(:account)
|
504
|
+
@attachment = create(:task, asset: nil)
|
505
505
|
end
|
506
506
|
it_should_behave_like("attach")
|
507
507
|
end
|
508
508
|
|
509
509
|
describe "contacts" do
|
510
510
|
before do
|
511
|
-
@model =
|
512
|
-
@attachment =
|
511
|
+
@model = create(:account)
|
512
|
+
@attachment = create(:contact, account: nil)
|
513
513
|
end
|
514
514
|
it_should_behave_like("attach")
|
515
515
|
end
|
@@ -521,16 +521,16 @@ describe AccountsController do
|
|
521
521
|
describe "responding to POST discard" do
|
522
522
|
describe "tasks" do
|
523
523
|
before do
|
524
|
-
@model =
|
525
|
-
@attachment =
|
524
|
+
@model = create(:account)
|
525
|
+
@attachment = create(:task, asset: @model)
|
526
526
|
end
|
527
527
|
it_should_behave_like("discard")
|
528
528
|
end
|
529
529
|
|
530
530
|
describe "contacts" do
|
531
531
|
before do
|
532
|
-
@attachment =
|
533
|
-
@model =
|
532
|
+
@attachment = create(:contact)
|
533
|
+
@model = create(:account)
|
534
534
|
@model.contacts << @attachment
|
535
535
|
end
|
536
536
|
it_should_behave_like("discard")
|
@@ -538,8 +538,8 @@ describe AccountsController do
|
|
538
538
|
|
539
539
|
describe "opportunities" do
|
540
540
|
before do
|
541
|
-
@attachment =
|
542
|
-
@model =
|
541
|
+
@attachment = create(:opportunity)
|
542
|
+
@model = create(:account)
|
543
543
|
@model.opportunities << @attachment
|
544
544
|
end
|
545
545
|
# 'super from singleton method that is defined to multiple classes is not supported;'
|
@@ -552,7 +552,7 @@ describe AccountsController do
|
|
552
552
|
#----------------------------------------------------------------------------
|
553
553
|
describe "responding to POST auto_complete" do
|
554
554
|
before do
|
555
|
-
@auto_complete_matches = [
|
555
|
+
@auto_complete_matches = [create(:account, name: "Hello World", user: current_user)]
|
556
556
|
end
|
557
557
|
|
558
558
|
it_should_behave_like("auto complete")
|
@@ -575,8 +575,8 @@ describe AccountsController do
|
|
575
575
|
|
576
576
|
it "should select @accounts and render [index] template" do
|
577
577
|
@accounts = [
|
578
|
-
|
579
|
-
|
578
|
+
create(:account, name: "A", user: current_user),
|
579
|
+
create(:account, name: "B", user: current_user)
|
580
580
|
]
|
581
581
|
|
582
582
|
get :redraw, params: { per_page: 1, sort_by: "name" }, xhr: true
|
@@ -590,7 +590,7 @@ describe AccountsController do
|
|
590
590
|
describe "responding to POST filter" do
|
591
591
|
it "should expose filtered accounts as @accounts and render [index] template" do
|
592
592
|
session[:accounts_filter] = "customer,vendor"
|
593
|
-
@accounts = [
|
593
|
+
@accounts = [create(:account, category: "partner", user: current_user)]
|
594
594
|
|
595
595
|
post :filter, params: { category: "partner" }, xhr: true
|
596
596
|
expect(assigns(:accounts)).to eq(@accounts)
|