fat_free_crm 0.11.3 → 0.11.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of fat_free_crm might be problematic. Click here for more details.
- data/.gitignore +1 -0
- data/.travis.yml +2 -2
- data/CHANGELOG +6 -1
- data/CONTRIBUTORS +40 -1
- data/Capfile +5 -0
- data/Gemfile +25 -6
- data/Gemfile.lock +128 -86
- data/README.md +23 -16
- data/{vendor → app}/assets/images/delete.png +0 -0
- data/app/assets/javascripts/admin/fields.js.coffee +62 -0
- data/app/assets/javascripts/application.js.erb +8 -1
- data/app/assets/javascripts/crm.js +44 -46
- data/app/assets/javascripts/crm_chosen.js.coffee +10 -7
- data/app/assets/javascripts/datepicker.js.coffee +15 -0
- data/app/assets/javascripts/format_buttons.js.coffee +48 -0
- data/app/assets/javascripts/{admin/field_groups.js.coffee → groups.js.coffee} +0 -0
- data/app/assets/javascripts/lists.js.coffee +1 -1
- data/app/assets/javascripts/search.js.coffee +56 -38
- data/app/assets/stylesheets/admin/{field_groups.css.scss → fields.css.scss} +4 -0
- data/app/assets/stylesheets/advanced_search.css.scss +79 -0
- data/app/assets/stylesheets/application.css.erb +4 -0
- data/app/assets/stylesheets/base.scss +3 -3
- data/app/assets/stylesheets/common.scss +72 -25
- data/app/assets/stylesheets/fields.scss +14 -0
- data/app/assets/stylesheets/format_buttons.css.scss +30 -0
- data/app/assets/stylesheets/groups.css.scss +3 -0
- data/app/assets/stylesheets/header.scss +7 -6
- data/{vendor/plugins/.gitkeep → app/assets/stylesheets/index_headers.css.scss} +0 -0
- data/app/assets/stylesheets/print.css.scss +12 -3
- data/app/assets/stylesheets/rails.scss +12 -3
- data/app/controllers/admin/application_controller.rb +1 -1
- data/app/controllers/admin/field_groups_controller.rb +2 -0
- data/app/controllers/admin/fields_controller.rb +41 -17
- data/app/controllers/admin/groups_controller.rb +70 -0
- data/app/controllers/admin/tags_controller.rb +1 -0
- data/app/controllers/admin/users_controller.rb +8 -7
- data/app/controllers/application_controller.rb +34 -5
- data/app/controllers/comments_controller.rb +2 -3
- data/app/controllers/entities/accounts_controller.rb +30 -37
- data/app/controllers/entities/campaigns_controller.rb +56 -29
- data/app/controllers/entities/contacts_controller.rb +24 -26
- data/app/controllers/entities/leads_controller.rb +38 -37
- data/app/controllers/entities/opportunities_controller.rb +28 -34
- data/app/controllers/entities_controller.rb +71 -43
- data/app/controllers/home_controller.rb +29 -27
- data/app/controllers/tasks_controller.rb +18 -17
- data/app/controllers/users_controller.rb +12 -8
- data/app/helpers/accounts_helper.rb +58 -16
- data/app/helpers/addresses_helper.rb +4 -1
- data/app/helpers/admin/fields_helper.rb +3 -4
- data/app/helpers/application_helper.rb +147 -100
- data/app/helpers/campaigns_helper.rb +2 -9
- data/app/helpers/fields_helper.rb +0 -1
- data/app/helpers/groups_helper.rb +2 -0
- data/app/helpers/home_helper.rb +11 -0
- data/app/helpers/leads_helper.rb +2 -9
- data/app/helpers/opportunities_helper.rb +2 -9
- data/app/helpers/{crm_tags_helper.rb → tags_helper.rb} +9 -8
- data/app/helpers/tasks_helper.rb +5 -21
- data/app/helpers/users_helper.rb +14 -7
- data/app/helpers/versions_helper.rb +46 -0
- data/app/inputs/date_time_input.rb +8 -25
- data/app/inputs/datepair_input.rb +77 -0
- data/app/inputs/datetimepair_input.rb +37 -0
- data/app/mailers/user_mailer.rb +10 -0
- data/app/models/entities/account.rb +18 -11
- data/app/models/entities/account_contact.rb +4 -3
- data/app/models/entities/account_opportunity.rb +0 -1
- data/app/models/entities/campaign.rb +6 -7
- data/app/models/entities/contact.rb +53 -25
- data/app/models/entities/contact_opportunity.rb +0 -1
- data/app/models/entities/lead.rb +24 -13
- data/app/models/entities/opportunity.rb +34 -16
- data/app/models/fields/custom_field.rb +29 -13
- data/app/models/fields/custom_field_date_pair.rb +58 -0
- data/app/models/fields/custom_field_datetime_pair.rb +28 -0
- data/app/models/fields/custom_field_pair.rb +54 -0
- data/app/models/fields/field.rb +60 -43
- data/app/models/fields/field_group.rb +0 -9
- data/app/models/observers/entity_observer.rb +29 -0
- data/app/models/observers/opportunity_observer.rb +3 -0
- data/app/models/polymorphic/address.rb +14 -0
- data/app/models/polymorphic/avatar.rb +13 -1
- data/app/models/polymorphic/email.rb +1 -1
- data/app/models/polymorphic/task.rb +14 -13
- data/app/models/setting.rb +14 -21
- data/app/models/users/ability.rb +25 -4
- data/app/models/users/group.rb +13 -0
- data/app/models/users/permission.rb +3 -1
- data/app/models/users/preference.rb +1 -2
- data/app/models/users/user.rb +25 -3
- data/app/views/accounts/_account.html.haml +5 -39
- data/app/views/accounts/_edit.html.haml +3 -2
- data/app/views/accounts/_index_brief.html.haml +32 -0
- data/app/views/accounts/_index_long.html.haml +42 -0
- data/app/views/accounts/_new.html.haml +3 -2
- data/app/views/accounts/_sidebar_index.html.haml +3 -4
- data/app/views/accounts/_sidebar_show.html.haml +2 -2
- data/app/views/accounts/_title_bar.html.haml +11 -0
- data/app/views/accounts/_top_section.html.haml +1 -1
- data/app/views/accounts/create.js.rjs +1 -2
- data/app/views/accounts/destroy.js.rjs +1 -1
- data/app/views/accounts/edit.js.rjs +0 -2
- data/app/views/accounts/index.html.haml +6 -13
- data/app/views/accounts/index.js.rjs +3 -1
- data/app/views/accounts/index.xls.builder +82 -0
- data/app/views/accounts/new.js.rjs +0 -2
- data/app/views/accounts/show.html.haml +17 -15
- data/app/views/accounts/show.js.erb +2 -0
- data/app/views/admin/custom_fields/_base_field.html.haml +21 -0
- data/app/views/admin/custom_fields/_check_boxes_field.html.haml +6 -0
- data/app/views/admin/custom_fields/_date_field.html.haml +14 -0
- data/app/views/admin/custom_fields/_date_pair_field.html.haml +21 -0
- data/app/views/admin/custom_fields/_datetime_field.html.haml +14 -0
- data/app/views/admin/custom_fields/_datetime_pair_field.html.haml +21 -0
- data/app/views/admin/custom_fields/_radio_field.html.haml +6 -0
- data/app/views/admin/custom_fields/_select_field.html.haml +25 -0
- data/app/views/admin/custom_fields/_string_field.html.haml +2 -0
- data/app/views/admin/field_groups/_field_group.html.haml +7 -5
- data/app/views/admin/field_groups/_top_section.html.haml +4 -3
- data/app/views/admin/field_groups/create.js.rjs +1 -2
- data/app/views/admin/fields/_field.html.haml +5 -3
- data/app/views/admin/fields/_form.html.haml +35 -0
- data/app/views/admin/fields/_subform.html.haml +6 -0
- data/app/views/admin/fields/create.js.erb +19 -0
- data/app/views/admin/fields/destroy.js.erb +9 -0
- data/app/views/admin/fields/edit.js.erb +1 -0
- data/app/views/admin/fields/index.html.haml +11 -8
- data/app/views/admin/fields/update.js.erb +13 -0
- data/app/views/admin/groups/_edit.html.haml +12 -0
- data/app/views/admin/groups/_form.html.haml +13 -0
- data/app/views/admin/groups/_group.html.haml +15 -0
- data/app/views/admin/groups/_new.html.haml +12 -0
- data/app/views/admin/groups/create.js.rjs +11 -0
- data/app/views/admin/{fields → groups}/destroy.js.rjs +3 -3
- data/app/views/admin/groups/edit.js.rjs +21 -0
- data/app/views/admin/groups/index.html.haml +18 -0
- data/app/views/admin/groups/index.js.rjs +2 -0
- data/app/views/admin/groups/new.js.rjs +9 -0
- data/app/views/admin/groups/show.html.haml +11 -0
- data/app/views/admin/groups/update.js.rjs +10 -0
- data/app/views/admin/users/_profile.html.haml +13 -1
- data/app/views/admin/users/_user.html.haml +7 -2
- data/app/views/admin/users/index.js.rjs +1 -0
- data/app/views/application/index.atom.builder +1 -1
- data/app/views/application/index.rss.builder +1 -1
- data/app/views/application/show.atom.builder +32 -0
- data/app/views/application/show.rss.builder +29 -0
- data/app/views/campaigns/_campaign.html.haml +5 -21
- data/app/views/campaigns/_edit.html.haml +3 -2
- data/app/views/campaigns/_index_brief.html.haml +15 -0
- data/app/views/campaigns/_index_long.html.haml +20 -0
- data/app/views/campaigns/_new.html.haml +4 -2
- data/app/views/campaigns/_sidebar_index.html.haml +3 -3
- data/app/views/campaigns/_title_bar.html.haml +11 -0
- data/app/views/campaigns/_top_section.html.haml +2 -2
- data/app/views/campaigns/create.js.rjs +1 -4
- data/app/views/campaigns/destroy.js.rjs +1 -1
- data/app/views/campaigns/edit.js.rjs +0 -4
- data/app/views/campaigns/index.html.haml +6 -13
- data/app/views/campaigns/index.js.rjs +3 -1
- data/app/views/campaigns/index.xls.builder +75 -0
- data/app/views/campaigns/new.js.rjs +0 -4
- data/app/views/campaigns/show.html.haml +17 -15
- data/app/views/campaigns/show.js.erb +2 -0
- data/app/views/campaigns/update.js.rjs +0 -2
- data/app/views/comments/_comment.html.haml +6 -5
- data/app/views/comments/_edit.html.haml +5 -5
- data/app/views/comments/_new.html.haml +6 -5
- data/app/views/comments/create.js.rjs +1 -1
- data/app/views/contacts/_contact.html.haml +5 -52
- data/app/views/contacts/_contacts.html.haml +1 -0
- data/app/views/contacts/_edit.html.haml +3 -2
- data/app/views/contacts/_index_brief.html.haml +25 -0
- data/app/views/contacts/_index_full.html.haml +57 -0
- data/app/views/contacts/_index_long.html.haml +43 -0
- data/app/views/contacts/_new.html.haml +4 -2
- data/app/views/contacts/_section_extra.html.haml +26 -0
- data/app/views/contacts/_section_general.html.haml +22 -0
- data/app/views/contacts/_sidebar_index.html.haml +0 -3
- data/app/views/contacts/_sidebar_show.html.haml +2 -10
- data/app/views/contacts/_title_bar.html.haml +11 -0
- data/app/views/contacts/_top_section.html.haml +1 -1
- data/app/views/contacts/create.js.rjs +1 -2
- data/app/views/contacts/destroy.js.rjs +1 -1
- data/app/views/contacts/edit.js.rjs +0 -2
- data/app/views/contacts/index.html.haml +6 -14
- data/app/views/contacts/index.js.rjs +3 -1
- data/app/views/contacts/index.xls.builder +102 -0
- data/app/views/contacts/new.js.rjs +0 -2
- data/app/views/contacts/show.html.haml +15 -15
- data/app/views/contacts/show.js.erb +2 -0
- data/app/views/entities/_basic_search.html.haml +22 -0
- data/app/views/entities/_permissions.html.haml +41 -0
- data/app/views/entities/_search.html.haml +15 -0
- data/app/views/entities/_section_custom_fields.html.haml +11 -0
- data/app/views/entities/_title_bar.html.haml +12 -0
- data/app/views/entities/attach.js.rjs +1 -1
- data/app/views/entities/opportunities.js.rjs +1 -1
- data/app/views/entities/versions.js.erb +3 -0
- data/app/views/fields/_edit_custom_field_group.html.haml +8 -0
- data/app/views/fields/_group.html.haml +11 -20
- data/app/views/fields/_group_table.html.haml +13 -0
- data/app/views/fields/_group_view.html.haml +7 -0
- data/app/views/fields/_groups.html.haml +1 -4
- data/app/views/fields/_sidebar_show.html.haml +5 -4
- data/app/views/home/_account.html.haml +29 -0
- data/app/views/home/_activity.html.haml +16 -6
- data/app/views/home/_opportunity.html.haml +41 -0
- data/app/views/home/_options.html.haml +1 -1
- data/app/views/home/_task.html.haml +46 -0
- data/app/views/home/index.html.haml +32 -1
- data/app/views/home/index.js.rjs +1 -0
- data/app/views/layouts/_header.html.haml +3 -3
- data/app/views/layouts/_sidebar.html.haml +1 -3
- data/app/views/layouts/_tabbed.html.haml +2 -3
- data/app/views/layouts/_tabless.html.haml +1 -1
- data/app/views/layouts/admin/_header.html.haml +1 -1
- data/app/views/layouts/application.html.haml +7 -8
- data/app/views/layouts/header.xls.builder +8 -0
- data/app/views/leads/_contact.html.haml +1 -2
- data/app/views/leads/_convert.html.haml +1 -2
- data/app/views/leads/_convert_permissions.html.haml +21 -11
- data/app/views/leads/_edit.html.haml +3 -2
- data/app/views/leads/_index_brief.html.haml +41 -0
- data/app/views/leads/_index_long.html.haml +62 -0
- data/app/views/leads/_lead.html.haml +5 -62
- data/app/views/leads/_new.html.haml +4 -2
- data/app/views/leads/_opportunity.html.haml +1 -1
- data/app/views/leads/_sidebar_index.html.haml +3 -3
- data/app/views/leads/_sidebar_show.html.haml +3 -3
- data/app/views/leads/_status.html.haml +1 -1
- data/app/views/leads/_title_bar.html.haml +16 -0
- data/app/views/leads/convert.js.rjs +0 -1
- data/app/views/leads/create.js.rjs +1 -2
- data/app/views/leads/destroy.js.rjs +1 -1
- data/app/views/leads/edit.js.rjs +0 -2
- data/app/views/leads/index.html.haml +6 -13
- data/app/views/leads/index.js.rjs +3 -1
- data/app/views/leads/index.xls.builder +100 -0
- data/app/views/leads/new.js.rjs +0 -2
- data/app/views/leads/promote.js.rjs +0 -1
- data/app/views/leads/show.html.haml +13 -18
- data/app/views/leads/show.js.erb +2 -0
- data/app/views/{shared/_lists.html.haml → lists/_sidebar.html.haml} +0 -0
- data/app/views/lists/create.js.rjs +1 -1
- data/app/views/opportunities/_edit.html.haml +3 -2
- data/app/views/opportunities/_index_brief.html.haml +29 -0
- data/app/views/opportunities/_index_long.html.haml +59 -0
- data/app/views/opportunities/_new.html.haml +4 -2
- data/app/views/opportunities/_opportunity.html.haml +5 -57
- data/app/views/opportunities/_sidebar_index.html.haml +3 -3
- data/app/views/opportunities/_sidebar_show.html.haml +2 -2
- data/app/views/opportunities/_title_bar.html.haml +11 -0
- data/app/views/opportunities/_top_section.html.haml +2 -2
- data/app/views/opportunities/create.js.rjs +4 -6
- data/app/views/opportunities/destroy.js.rjs +1 -1
- data/app/views/opportunities/edit.js.rjs +0 -3
- data/app/views/opportunities/index.html.haml +6 -14
- data/app/views/opportunities/index.js.rjs +3 -1
- data/app/views/opportunities/index.xls.builder +69 -0
- data/app/views/opportunities/new.js.rjs +1 -5
- data/app/views/opportunities/show.html.haml +14 -14
- data/app/views/opportunities/show.js.erb +2 -0
- data/app/views/opportunities/update.js.rjs +0 -1
- data/app/views/passwords/new.html.haml +1 -1
- data/app/views/shared/_add_comment.html.haml +8 -0
- data/app/views/shared/_address.html.haml +1 -1
- data/app/views/shared/_address_show.html.haml +1 -1
- data/app/views/shared/_edit_comment.html.haml +2 -2
- data/app/views/shared/_export.html.haml +2 -1
- data/app/views/shared/_paginate_with_per_page.html.haml +14 -0
- data/app/views/shared/_recently.html.haml +1 -1
- data/app/views/shared/_search.html.haml +1 -1
- data/app/views/shared/_tags.html.haml +1 -2
- data/app/views/shared/_tasks.html.haml +2 -2
- data/app/views/tasks/_completed.html.haml +3 -3
- data/app/views/tasks/_new.html.haml +1 -1
- data/app/views/tasks/_pending.html.haml +2 -3
- data/app/views/tasks/_sidebar_index.html.haml +2 -2
- data/app/views/tasks/_top_section.html.haml +5 -3
- data/app/views/tasks/create.js.rjs +3 -4
- data/app/views/tasks/edit.js.rjs +2 -4
- data/app/views/tasks/index.html.haml +1 -1
- data/app/views/tasks/index.xls.builder +47 -0
- data/app/views/tasks/new.js.rjs +0 -2
- data/app/views/tasks/update.js.rjs +0 -1
- data/app/views/user_mailer/assigned_entity_notification.html.haml +3 -0
- data/app/views/users/_user.html.haml +2 -2
- data/app/views/users/_user_report.html.haml +6 -0
- data/app/views/users/opportunities_overview.html.haml +16 -0
- data/app/views/users/show.html.haml +2 -3
- data/app/views/users/update.js.rjs +1 -1
- data/app/views/versions/_version.html.haml +4 -19
- data/app/views/versions/_version_item.html.haml +8 -0
- data/app/views/versions/_versions.html.haml +9 -9
- data/config/application.rb +10 -2
- data/config/deploy.example.rb +47 -0
- data/config/environments/development.rb +1 -0
- data/config/environments/production.rb +1 -3
- data/config/environments/staging.rb +1 -1
- data/config/initializers/action_mailer.rb +10 -8
- data/config/initializers/custom_fields.rb +21 -0
- data/config/initializers/gravatar.rb +7 -0
- data/config/initializers/paper_trail.rb +1 -0
- data/config/initializers/ransack.rb +15 -0
- data/config/initializers/simple_form.rb +1 -2
- data/config/initializers/views.rb +42 -0
- data/config/locales/cz_fat_free_crm.yml +0 -10
- data/config/locales/de_fat_free_crm.yml +23 -21
- data/config/locales/en-GB_fat_free_crm.yml +241 -25
- data/config/locales/en-US_fat_free_crm.yml +139 -57
- data/config/locales/en-US_ransack.yml +92 -0
- data/config/locales/es_fat_free_crm.yml +0 -6
- data/config/locales/fr-CA_fat_free_crm.yml +0 -6
- data/config/locales/fr_fat_free_crm.yml +3 -14
- data/config/locales/it_fat_free_crm.yml +0 -11
- data/config/locales/ja_fat_free_crm.yml +0 -10
- data/config/locales/pl_fat_free_crm.yml +0 -6
- data/config/locales/pt-BR_fat_free_crm.yml +0 -6
- data/config/locales/ru_fat_free_crm.yml +0 -9
- data/config/locales/sv-SE_fat_free_crm.yml +0 -10
- data/config/locales/th_fat_free_crm.yml +0 -6
- data/config/locales/zh-CN.yml +4 -0
- data/config/locales/zh-CN_fat_free_crm.yml +78 -47
- data/config/routes.rb +13 -0
- data/config/settings.default.yml +20 -20
- data/db/demo/addresses.yml +2 -2
- data/db/migrate/20100928030598_create_sessions.rb +5 -0
- data/db/migrate/20100928030627_acts_as_taggable_on_migration.rb +6 -6
- data/db/migrate/20111201030535_add_field_groups_klass_name.rb +2 -1
- data/db/migrate/20120406082136_create_groups.rb +19 -0
- data/db/migrate/20120510025219_add_not_null_constraints_for_timestamp_columns.rb +21 -0
- data/db/migrate/20120528102124_increase_length_of_version_events.rb +9 -0
- data/db/migrate/20120801032706_add_pair_id_to_fields.rb +5 -0
- data/db/migrate/20121003063155_add_settings_to_custom_fields.rb +5 -0
- data/db/migrate/20121221033947_fix_country_mapping.rb +32 -0
- data/db/schema.rb +25 -6
- data/fat_free_crm.gemspec +16 -13
- data/lib/fat_free_crm.rb +2 -0
- data/lib/fat_free_crm/comment_extensions.rb +23 -0
- data/lib/fat_free_crm/core_ext/array.rb +8 -2
- data/lib/fat_free_crm/fields.rb +24 -2
- data/lib/fat_free_crm/gem_dependencies.rb +7 -1
- data/lib/fat_free_crm/permissions.rb +47 -26
- data/lib/fat_free_crm/version.rb +1 -1
- data/lib/fat_free_crm/view_factory.rb +95 -0
- data/lib/plugins/country_select/lib/country_select.rb +393 -374
- data/lib/tasks/{plugins.rake → db/migrate.rake} +1 -1
- data/lib/tasks/{schema_upgrade.rake → db/schema.rake} +2 -1
- data/lib/tasks/{mail_processing.rake → ffcrm/comment_replies.rake} +2 -21
- data/lib/tasks/ffcrm/config.rake +33 -0
- data/lib/tasks/{demo.rake → ffcrm/demo.rake} +3 -2
- data/lib/tasks/ffcrm/dropbox.rake +42 -0
- data/lib/tasks/ffcrm/settings.rake +46 -0
- data/lib/tasks/{fat_free_crm.rake → ffcrm/setup.rake} +1 -39
- data/lib/tasks/ffcrm/update_data.rake +256 -0
- data/{acceptance → spec/acceptance}/acceptance_helper.rb +5 -4
- data/{acceptance → spec/acceptance}/accounts_spec.rb +36 -10
- data/spec/acceptance/admin/groups_spec.rb +26 -0
- data/spec/acceptance/admin/users_spec.rb +34 -0
- data/spec/acceptance/campaigns_spec.rb +101 -0
- data/spec/acceptance/contacts_spec.rb +101 -0
- data/spec/acceptance/dashboard_spec.rb +62 -0
- data/spec/acceptance/leads_spec.rb +109 -0
- data/spec/acceptance/opportunities_overview_spec.rb +82 -0
- data/spec/acceptance/opportunities_spec.rb +103 -0
- data/{acceptance → spec/acceptance}/support/browser.rb +0 -0
- data/{acceptance → spec/acceptance}/support/headless.rb +0 -0
- data/{acceptance → spec/acceptance}/support/helpers.rb +8 -1
- data/{acceptance → spec/acceptance}/support/maintain_sessions.rb +0 -0
- data/spec/acceptance/support/paths.rb +42 -0
- data/spec/acceptance/support/selector_helpers.rb +31 -0
- data/spec/acceptance/tasks_spec.rb +85 -0
- data/spec/controllers/admin/groups_controller_spec.rb +5 -0
- data/spec/controllers/admin/users_controller_spec.rb +2 -3
- data/spec/controllers/applications_controller_spec.rb +40 -0
- data/spec/controllers/comments_controller_spec.rb +5 -6
- data/spec/controllers/emails_controller_spec.rb +1 -2
- data/spec/controllers/entities/accounts_controller_spec.rb +65 -81
- data/spec/controllers/entities/campaigns_controller_spec.rb +69 -85
- data/spec/controllers/entities/contacts_controller_spec.rb +78 -95
- data/spec/controllers/entities/leads_controller_spec.rb +105 -127
- data/spec/controllers/entities/opportunities_controller_spec.rb +88 -103
- data/spec/controllers/entities_controller_spec.rb +39 -0
- data/spec/controllers/home_controller_spec.rb +101 -11
- data/spec/controllers/tasks_controller_spec.rb +27 -32
- data/spec/controllers/users_controller_spec.rb +95 -28
- data/spec/factories/account_factories.rb +2 -2
- data/spec/factories/opportunity_factories.rb +12 -4
- data/spec/factories/task_factories.rb +4 -0
- data/spec/factories/user_factories.rb +9 -2
- data/spec/helpers/application_helper_spec.rb +15 -1
- data/spec/helpers/groups_helper_spec.rb +15 -0
- data/spec/helpers/users_helper_spec.rb +26 -4
- data/spec/lib/comment_extensions_spec.rb +29 -0
- data/spec/lib/core_ext/{string.rb → string_spec.rb} +0 -1
- data/spec/lib/fields_spec.rb +104 -0
- data/spec/lib/permissions_spec.rb +144 -0
- data/spec/lib/view_factory_spec.rb +68 -0
- data/spec/mailers/subscription_mailer_spec.rb +18 -4
- data/spec/mailers/user_mailer_spec.rb +134 -0
- data/spec/models/entities/account_spec.rb +44 -4
- data/spec/models/entities/campaign_spec.rb +3 -4
- data/spec/models/entities/contact_spec.rb +45 -5
- data/spec/models/entities/lead_spec.rb +3 -4
- data/spec/models/entities/opportunity_spec.rb +105 -9
- data/spec/models/fields/custom_field_date_pair_spec.rb +106 -0
- data/spec/models/fields/custom_field_pair_spec.rb +94 -0
- data/spec/models/fields/custom_field_spec.rb +43 -23
- data/spec/models/fields/field_spec.rb +3 -5
- data/spec/models/observers/entity_observer_spec.rb +65 -0
- data/spec/models/polymorphic/task_spec.rb +74 -118
- data/spec/models/polymorphic/version_spec.rb +18 -18
- data/spec/models/users/group_spec.rb +5 -0
- data/spec/models/users/permission_spec.rb +18 -1
- data/spec/models/users/preference_spec.rb +5 -1
- data/spec/models/users/user_spec.rb +55 -8
- data/spec/shared/models.rb +54 -0
- data/spec/spec_helper.rb +82 -87
- data/spec/support/auth_macros.rb +2 -3
- data/spec/views/accounts/_edit.haml_spec.rb +1 -2
- data/spec/views/accounts/_new.haml_spec.rb +1 -2
- data/spec/views/accounts/create.rjs_spec.rb +1 -3
- data/spec/views/accounts/edit.rjs_spec.rb +3 -4
- data/spec/views/accounts/index.haml_spec.rb +9 -6
- data/spec/views/accounts/new.rjs_spec.rb +2 -9
- data/spec/views/accounts/show.haml_spec.rb +1 -2
- data/spec/views/accounts/update.rjs_spec.rb +2 -3
- data/spec/views/admin/users/_create.haml_spec.rb +1 -2
- data/spec/views/admin/users/create.rjs_spec.rb +1 -2
- data/spec/views/campaigns/_edit.haml_spec.rb +2 -3
- data/spec/views/campaigns/_new.haml_spec.rb +2 -3
- data/spec/views/campaigns/create.rjs_spec.rb +0 -3
- data/spec/views/campaigns/destroy.rjs_spec.rb +1 -2
- data/spec/views/campaigns/edit.rjs_spec.rb +3 -6
- data/spec/views/campaigns/index.haml_spec.rb +6 -3
- data/spec/views/campaigns/new.rjs_spec.rb +2 -13
- data/spec/views/campaigns/show.haml_spec.rb +4 -6
- data/spec/views/campaigns/update.rjs_spec.rb +2 -7
- data/spec/views/contacts/_edit.haml_spec.rb +6 -7
- data/spec/views/contacts/_new.haml_spec.rb +2 -3
- data/spec/views/contacts/create.rjs_spec.rb +1 -3
- data/spec/views/contacts/edit.rjs_spec.rb +3 -4
- data/spec/views/contacts/index.haml_spec.rb +6 -3
- data/spec/views/contacts/new.rjs_spec.rb +2 -11
- data/spec/views/contacts/show.haml_spec.rb +1 -2
- data/spec/views/contacts/update.rjs_spec.rb +2 -3
- data/spec/views/home/index.haml_spec.rb +6 -2
- data/spec/views/home/index.rjs_spec.rb +1 -2
- data/spec/views/home/options.rjs_spec.rb +1 -2
- data/spec/views/leads/_convert.haml_spec.rb +1 -2
- data/spec/views/leads/_edit.haml_spec.rb +2 -3
- data/spec/views/leads/_new.haml_spec.rb +2 -3
- data/spec/views/leads/_sidebar_show.haml_spec.rb +1 -2
- data/spec/views/leads/convert.rjs_spec.rb +3 -5
- data/spec/views/leads/edit.rjs_spec.rb +4 -5
- data/spec/views/leads/index.haml_spec.rb +6 -3
- data/spec/views/leads/new.rjs_spec.rb +2 -11
- data/spec/views/leads/promote.rjs_spec.rb +3 -5
- data/spec/views/leads/show.haml_spec.rb +1 -2
- data/spec/views/leads/update.rjs_spec.rb +2 -3
- data/spec/views/opportunities/_edit.haml_spec.rb +5 -6
- data/spec/views/opportunities/_new.haml_spec.rb +2 -4
- data/spec/views/opportunities/create.rjs_spec.rb +0 -2
- data/spec/views/opportunities/edit.rjs_spec.rb +3 -4
- data/spec/views/opportunities/index.haml_spec.rb +7 -4
- data/spec/views/opportunities/new.rjs_spec.rb +2 -12
- data/spec/views/opportunities/show.haml_spec.rb +1 -2
- data/spec/views/opportunities/update.rjs_spec.rb +2 -3
- data/spec/views/tasks/_edit.haml_spec.rb +1 -3
- data/spec/views/tasks/complete.rjs_spec.rb +2 -3
- data/spec/views/tasks/create.rjs_spec.rb +2 -2
- data/spec/views/tasks/edit.rjs_spec.rb +1 -2
- data/spec/views/tasks/new.rjs_spec.rb +1 -18
- data/spec/views/users/avatar.rjs_spec.rb +1 -2
- data/spec/views/users/change_password.rjs_spec.rb +1 -2
- data/spec/views/users/edit.rjs_spec.rb +1 -2
- data/spec/views/users/password.rjs_spec.rb +1 -1
- data/spec/views/users/update.rjs_spec.rb +1 -2
- data/spec/views/users/upload_avatar.rjs_spec.rb +6 -7
- data/vendor/assets/images/brief.png +0 -0
- data/vendor/assets/images/chosen-sprite.png +0 -0
- data/vendor/assets/images/full.png +0 -0
- data/vendor/assets/images/jquery-ui/ui-bg_flat_0_aaaaaa_40x100.png +0 -0
- data/vendor/assets/images/jquery-ui/ui-bg_flat_0_eeeeee_40x100.png +0 -0
- data/vendor/assets/images/jquery-ui/ui-bg_flat_100_ffffff_40x100.png +0 -0
- data/vendor/assets/images/jquery-ui/ui-bg_flat_25_3875d7_40x100.png +0 -0
- data/vendor/assets/images/jquery-ui/ui-bg_flat_55_ffffff_40x100.png +0 -0
- data/vendor/assets/images/jquery-ui/ui-bg_flat_65_3875d7_40x100.png +0 -0
- data/vendor/assets/images/jquery-ui/ui-bg_flat_75_ffffff_40x100.png +0 -0
- data/vendor/assets/images/jquery-ui/ui-bg_highlight-soft_50_dddddd_1x100.png +0 -0
- data/vendor/assets/images/jquery-ui/{ui-icons_ef8c08_256x240.png → ui-icons_0073ea_256x240.png} +0 -0
- data/vendor/assets/images/jquery-ui/ui-icons_466bb1_256x240.png +0 -0
- data/vendor/assets/images/jquery-ui/{ui-icons_ffd27a_256x240.png → ui-icons_ff0084_256x240.png} +0 -0
- data/vendor/assets/images/long.png +0 -0
- data/vendor/assets/javascripts/chosen-jquery.js +3 -0
- data/vendor/assets/javascripts/chosen-prototype.js +3 -0
- data/vendor/assets/javascripts/chosen.jquery.coffee +574 -0
- data/vendor/assets/javascripts/chosen.proto.coffee +580 -0
- data/vendor/assets/javascripts/jquery.disable.js +23 -0
- data/vendor/assets/javascripts/jquery_ui_datepicker/jquery-ui-timepicker-addon.js +1882 -0
- data/vendor/assets/javascripts/jquery_ui_datepicker/jquery-ui-timepicker-af.js +20 -0
- data/vendor/assets/javascripts/jquery_ui_datepicker/jquery-ui-timepicker-ca.js +20 -0
- data/vendor/assets/javascripts/jquery_ui_datepicker/jquery-ui-timepicker-cz.js +20 -0
- data/vendor/assets/javascripts/jquery_ui_datepicker/jquery-ui-timepicker-de.js +20 -0
- data/vendor/assets/javascripts/jquery_ui_datepicker/jquery-ui-timepicker-el.js +20 -0
- data/vendor/assets/javascripts/jquery_ui_datepicker/jquery-ui-timepicker-es.js +20 -0
- data/vendor/assets/javascripts/jquery_ui_datepicker/jquery-ui-timepicker-et.js +20 -0
- data/vendor/assets/javascripts/jquery_ui_datepicker/jquery-ui-timepicker-fi.js +20 -0
- data/vendor/assets/javascripts/jquery_ui_datepicker/jquery-ui-timepicker-fr-CA.js +20 -0
- data/vendor/assets/javascripts/jquery_ui_datepicker/jquery-ui-timepicker-fr.js +20 -0
- data/vendor/assets/javascripts/jquery_ui_datepicker/jquery-ui-timepicker-gl.js +20 -0
- data/vendor/assets/javascripts/jquery_ui_datepicker/jquery-ui-timepicker-he.js +20 -0
- data/vendor/assets/javascripts/jquery_ui_datepicker/jquery-ui-timepicker-hu.js +20 -0
- data/vendor/assets/javascripts/jquery_ui_datepicker/jquery-ui-timepicker-id.js +20 -0
- data/vendor/assets/javascripts/jquery_ui_datepicker/jquery-ui-timepicker-it.js +20 -0
- data/vendor/assets/javascripts/jquery_ui_datepicker/jquery-ui-timepicker-ja.js +20 -0
- data/vendor/assets/javascripts/jquery_ui_datepicker/jquery-ui-timepicker-ko.js +20 -0
- data/vendor/assets/javascripts/jquery_ui_datepicker/jquery-ui-timepicker-lt.js +20 -0
- data/vendor/assets/javascripts/jquery_ui_datepicker/jquery-ui-timepicker-nl.js +20 -0
- data/vendor/assets/javascripts/jquery_ui_datepicker/jquery-ui-timepicker-no.js +20 -0
- data/vendor/assets/javascripts/jquery_ui_datepicker/jquery-ui-timepicker-pl.js +20 -0
- data/vendor/assets/javascripts/jquery_ui_datepicker/jquery-ui-timepicker-pt.js +20 -0
- data/vendor/assets/javascripts/jquery_ui_datepicker/jquery-ui-timepicker-ro.js +20 -0
- data/vendor/assets/javascripts/jquery_ui_datepicker/jquery-ui-timepicker-ru.js +20 -0
- data/vendor/assets/javascripts/jquery_ui_datepicker/jquery-ui-timepicker-sk.js +20 -0
- data/vendor/assets/javascripts/jquery_ui_datepicker/jquery-ui-timepicker-sv.js +20 -0
- data/vendor/assets/javascripts/jquery_ui_datepicker/jquery-ui-timepicker-tr.js +20 -0
- data/vendor/assets/javascripts/jquery_ui_datepicker/jquery-ui-timepicker-vi.js +20 -0
- data/vendor/assets/javascripts/jquery_ui_datepicker/jquery-ui-timepicker-zh-CN.js +20 -0
- data/vendor/assets/javascripts/jquery_ui_datepicker/jquery-ui-timepicker-zh-TW.js +20 -0
- data/vendor/assets/javascripts/jquery_ui_datepicker/jquery.ui.datepicker-cz.js +23 -0
- data/vendor/assets/javascripts/jquery_ui_datepicker/jquery.ui.datepicker-de.js +23 -0
- data/vendor/assets/javascripts/jquery_ui_datepicker/jquery.ui.datepicker-en-GB.js +23 -0
- data/vendor/assets/javascripts/jquery_ui_datepicker/jquery.ui.datepicker-es.js +23 -0
- data/vendor/assets/javascripts/jquery_ui_datepicker/jquery.ui.datepicker-fr.js +23 -0
- data/vendor/assets/javascripts/jquery_ui_datepicker/jquery.ui.datepicker-it.js +23 -0
- data/vendor/assets/javascripts/jquery_ui_datepicker/jquery.ui.datepicker-ja.js +23 -0
- data/vendor/assets/javascripts/jquery_ui_datepicker/jquery.ui.datepicker-pl.js +23 -0
- data/vendor/assets/javascripts/jquery_ui_datepicker/jquery.ui.datepicker-pt-BR.js +23 -0
- data/vendor/assets/javascripts/jquery_ui_datepicker/jquery.ui.datepicker-ru.js +23 -0
- data/vendor/assets/javascripts/jquery_ui_datepicker/jquery.ui.datepicker-sv-SE.js +23 -0
- data/vendor/assets/javascripts/jquery_ui_datepicker/jquery.ui.datepicker-th.js +23 -0
- data/vendor/assets/javascripts/jquery_ui_datepicker/jquery.ui.datepicker-zh-CN.js +23 -0
- data/vendor/assets/javascripts/lib/abstract-chosen.coffee +110 -0
- data/vendor/assets/javascripts/lib/select-parser.coffee +51 -0
- data/vendor/assets/stylesheets/chosen.css.sass +361 -0
- data/vendor/assets/stylesheets/{jquery-ui.custom.css.erb → jquery-ui.custom.css} +70 -70
- data/zeus.json +21 -0
- metadata +304 -140
- data/acceptance/support/database_cleaner.rb +0 -16
- data/acceptance/support/paths.rb +0 -9
- data/app/views/accounts/_options.html.haml +0 -20
- data/app/views/accounts/_permissions.html.haml +0 -24
- data/app/views/accounts/options.js.rjs +0 -10
- data/app/views/admin/fields/_edit.html.haml +0 -9
- data/app/views/admin/fields/_new.html.haml +0 -10
- data/app/views/admin/fields/_options.html.haml +0 -12
- data/app/views/admin/fields/_top_section.html.haml +0 -54
- data/app/views/admin/fields/create.js.rjs +0 -16
- data/app/views/admin/fields/edit.js.rjs +0 -35
- data/app/views/admin/fields/index.js.rjs +0 -6
- data/app/views/admin/fields/new.js.rjs +0 -8
- data/app/views/admin/fields/options.js.rjs +0 -10
- data/app/views/admin/fields/update.js.rjs +0 -17
- data/app/views/campaigns/_options.html.haml +0 -20
- data/app/views/campaigns/_permissions.html.haml +0 -24
- data/app/views/campaigns/options.js.rjs +0 -10
- data/app/views/contacts/_options.html.haml +0 -21
- data/app/views/contacts/_permissions.html.haml +0 -24
- data/app/views/contacts/options.js.rjs +0 -10
- data/app/views/entities/_advanced_search.html.haml +0 -12
- data/app/views/entities/_condition_fields.html.haml +0 -14
- data/app/views/entities/_grouping_fields.html.haml +0 -12
- data/app/views/entities/advanced_search.js.rjs +0 -9
- data/app/views/entities/versions.js.rjs +0 -3
- data/app/views/leads/_options.html.haml +0 -21
- data/app/views/leads/_permissions.html.haml +0 -28
- data/app/views/leads/options.js.rjs +0 -10
- data/app/views/opportunities/_options.html.haml +0 -20
- data/app/views/opportunities/_permissions.html.haml +0 -24
- data/app/views/opportunities/options.js.rjs +0 -10
- data/app/views/shared/_outline.html.haml +0 -9
- data/app/views/shared/_per_page.html.haml +0 -10
- data/app/views/shared/_sort_by.html.haml +0 -10
- data/config/initializers/cancan.rb +0 -151
- data/config/initializers/squeel.rb +0 -5
- data/public/blank_iframe.html +0 -2
- data/spec/views/accounts/options.rjs_spec.rb +0 -59
- data/spec/views/campaigns/options.rjs_spec.rb +0 -60
- data/spec/views/contacts/options.rjs_spec.rb +0 -61
- data/spec/views/leads/options.rjs_spec.rb +0 -61
- data/spec/views/opportunities/options.rjs_spec.rb +0 -60
- data/vendor/assets/images/jquery-ui/ui-bg_diagonals-thick_18_b81900_40x40.png +0 -0
- data/vendor/assets/images/jquery-ui/ui-bg_diagonals-thick_20_666666_40x40.png +0 -0
- data/vendor/assets/images/jquery-ui/ui-bg_flat_10_000000_40x100.png +0 -0
- data/vendor/assets/images/jquery-ui/ui-bg_glass_100_f6f6f6_1x400.png +0 -0
- data/vendor/assets/images/jquery-ui/ui-bg_glass_100_fdf5ce_1x400.png +0 -0
- data/vendor/assets/images/jquery-ui/ui-bg_glass_65_ffffff_1x400.png +0 -0
- data/vendor/assets/images/jquery-ui/ui-bg_gloss-wave_35_f6a828_500x100.png +0 -0
- data/vendor/assets/images/jquery-ui/ui-bg_highlight-soft_100_eeeeee_1x100.png +0 -0
- data/vendor/assets/images/jquery-ui/ui-bg_highlight-soft_75_ffe45c_1x100.png +0 -0
- data/vendor/assets/images/jquery-ui/ui-icons_222222_256x240.png +0 -0
- data/vendor/assets/images/jquery-ui/ui-icons_228ef1_256x240.png +0 -0
- data/vendor/assets/javascripts/calendar_date_select/calendar_date_select.js +0 -446
- data/vendor/assets/javascripts/calendar_date_select/format_american.js +0 -35
- data/vendor/assets/javascripts/calendar_date_select/format_danish.js +0 -31
- data/vendor/assets/javascripts/calendar_date_select/format_db.js +0 -27
- data/vendor/assets/javascripts/calendar_date_select/format_euro_24hr.js +0 -7
- data/vendor/assets/javascripts/calendar_date_select/format_euro_24hr_ymd.js +0 -7
- data/vendor/assets/javascripts/calendar_date_select/format_finnish.js +0 -32
- data/vendor/assets/javascripts/calendar_date_select/format_french.js +0 -24
- data/vendor/assets/javascripts/calendar_date_select/format_hyphen_ampm.js +0 -37
- data/vendor/assets/javascripts/calendar_date_select/format_iso_date.js +0 -29
- data/vendor/assets/javascripts/calendar_date_select/format_italian.js +0 -24
- data/vendor/assets/javascripts/calendar_date_select/locale/ar.js +0 -10
- data/vendor/assets/javascripts/calendar_date_select/locale/da.js +0 -11
- data/vendor/assets/javascripts/calendar_date_select/locale/de.js +0 -11
- data/vendor/assets/javascripts/calendar_date_select/locale/es.js +0 -11
- data/vendor/assets/javascripts/calendar_date_select/locale/fi.js +0 -10
- data/vendor/assets/javascripts/calendar_date_select/locale/fr.js +0 -11
- data/vendor/assets/javascripts/calendar_date_select/locale/it.js +0 -9
- data/vendor/assets/javascripts/calendar_date_select/locale/ja.js +0 -11
- data/vendor/assets/javascripts/calendar_date_select/locale/nl.js +0 -11
- data/vendor/assets/javascripts/calendar_date_select/locale/pl.js +0 -11
- data/vendor/assets/javascripts/calendar_date_select/locale/pt.js +0 -11
- data/vendor/assets/javascripts/calendar_date_select/locale/ru.js +0 -10
- data/vendor/assets/javascripts/calendar_date_select/locale/sl.js +0 -11
- data/vendor/assets/javascripts/calendar_date_select/locale/sv.js +0 -9
- data/vendor/assets/stylesheets/calendar_date_select/blue.css +0 -130
- data/vendor/assets/stylesheets/calendar_date_select/default.css +0 -135
- data/vendor/assets/stylesheets/calendar_date_select/green.css +0 -142
- data/vendor/assets/stylesheets/calendar_date_select/plain.css +0 -128
- data/vendor/assets/stylesheets/calendar_date_select/red.css +0 -135
- data/vendor/assets/stylesheets/calendar_date_select/silver.css +0 -133
- data/vendor/plugins/.gitkeep~master +0 -0
@@ -13,15 +13,16 @@ describe ContactsController do
|
|
13
13
|
describe "responding to GET index" do
|
14
14
|
|
15
15
|
it "should expose all contacts as @contacts and render [index] template" do
|
16
|
-
@contacts = [ FactoryGirl.create(:contact, :user =>
|
16
|
+
@contacts = [ FactoryGirl.create(:contact, :user => current_user) ]
|
17
17
|
get :index
|
18
|
+
assigns[:contacts].count.should == @contacts.count
|
18
19
|
assigns[:contacts].should == @contacts
|
19
20
|
response.should render_template("contacts/index")
|
20
21
|
end
|
21
22
|
|
22
23
|
it "should perform lookup using query string" do
|
23
|
-
@billy_bones = FactoryGirl.create(:contact, :user =>
|
24
|
-
@captain_flint = FactoryGirl.create(:contact, :user =>
|
24
|
+
@billy_bones = FactoryGirl.create(:contact, :user => current_user, :first_name => "Billy", :last_name => "Bones")
|
25
|
+
@captain_flint = FactoryGirl.create(:contact, :user => current_user, :first_name => "Captain", :last_name => "Flint")
|
25
26
|
|
26
27
|
get :index, :query => "bill"
|
27
28
|
assigns[:contacts].should == [ @billy_bones ]
|
@@ -31,7 +32,7 @@ describe ContactsController do
|
|
31
32
|
|
32
33
|
describe "AJAX pagination" do
|
33
34
|
it "should pick up page number from params" do
|
34
|
-
@contacts = [ FactoryGirl.create(:contact, :user =>
|
35
|
+
@contacts = [ FactoryGirl.create(:contact, :user => current_user) ]
|
35
36
|
xhr :get, :index, :page => 42
|
36
37
|
|
37
38
|
assigns[:current_page].to_i.should == 42
|
@@ -42,13 +43,24 @@ describe ContactsController do
|
|
42
43
|
|
43
44
|
it "should pick up saved page number from session" do
|
44
45
|
session[:contacts_current_page] = 42
|
45
|
-
@contacts = [ FactoryGirl.create(:contact, :user =>
|
46
|
+
@contacts = [ FactoryGirl.create(:contact, :user => current_user) ]
|
46
47
|
xhr :get, :index
|
47
48
|
|
48
49
|
assigns[:current_page].should == 42
|
49
50
|
assigns[:contacts].should == []
|
50
51
|
response.should render_template("contacts/index")
|
51
52
|
end
|
53
|
+
|
54
|
+
it "should reset current_page when query is altered" do
|
55
|
+
session[:contacts_current_page] = 42
|
56
|
+
session[:contacts_current_query] = "bill"
|
57
|
+
@contacts = [ FactoryGirl.create(:contact, :user => current_user) ]
|
58
|
+
xhr :get, :index
|
59
|
+
|
60
|
+
assigns[:current_page].should == 1
|
61
|
+
assigns[:contacts].should == @contacts
|
62
|
+
response.should render_template("contacts/index")
|
63
|
+
end
|
52
64
|
end
|
53
65
|
|
54
66
|
describe "with mime type of JSON" do
|
@@ -126,7 +138,7 @@ describe ContactsController do
|
|
126
138
|
|
127
139
|
describe "contact got deleted or otherwise unavailable" do
|
128
140
|
it "should redirect to contact index if the contact got deleted" do
|
129
|
-
@contact = FactoryGirl.create(:contact, :user =>
|
141
|
+
@contact = FactoryGirl.create(:contact, :user => current_user)
|
130
142
|
@contact.destroy
|
131
143
|
|
132
144
|
get :show, :id => @contact.id
|
@@ -143,7 +155,7 @@ describe ContactsController do
|
|
143
155
|
end
|
144
156
|
|
145
157
|
it "should return 404 (Not Found) XML error" do
|
146
|
-
@contact = FactoryGirl.create(:contact, :user =>
|
158
|
+
@contact = FactoryGirl.create(:contact, :user => current_user)
|
147
159
|
@contact.destroy
|
148
160
|
request.env["HTTP_ACCEPT"] = "application/xml"
|
149
161
|
|
@@ -159,15 +171,14 @@ describe ContactsController do
|
|
159
171
|
describe "responding to GET new" do
|
160
172
|
|
161
173
|
it "should expose a new contact as @contact and render [new] template" do
|
162
|
-
@contact = Contact.new(:user =>
|
163
|
-
|
164
|
-
@
|
165
|
-
@accounts = [ FactoryGirl.create(:account, :user =>
|
174
|
+
@contact = Contact.new(:user => current_user,
|
175
|
+
:access => Setting.default_access)
|
176
|
+
@account = Account.new(:user => current_user)
|
177
|
+
@accounts = [ FactoryGirl.create(:account, :user => current_user) ]
|
166
178
|
|
167
179
|
xhr :get, :new
|
168
180
|
assigns[:contact].attributes.should == @contact.attributes
|
169
181
|
assigns[:account].attributes.should == @account.attributes
|
170
|
-
assigns[:users].should == @users
|
171
182
|
assigns[:accounts].should == @accounts
|
172
183
|
assigns[:opportunity].should == nil
|
173
184
|
response.should render_template("contacts/new")
|
@@ -205,13 +216,11 @@ describe ContactsController do
|
|
205
216
|
describe "responding to GET edit" do
|
206
217
|
|
207
218
|
it "should expose the requested contact as @contact and render [edit] template" do
|
208
|
-
@contact = FactoryGirl.create(:contact, :id => 42, :user =>
|
209
|
-
@
|
210
|
-
@account = Account.new(:user => @current_user)
|
219
|
+
@contact = FactoryGirl.create(:contact, :id => 42, :user => current_user, :lead => nil)
|
220
|
+
@account = Account.new(:user => current_user)
|
211
221
|
|
212
222
|
xhr :get, :edit, :id => 42
|
213
223
|
assigns[:contact].should == @contact
|
214
|
-
assigns[:users].should == @users
|
215
224
|
assigns[:account].attributes.should == @account.attributes
|
216
225
|
assigns[:previous].should == nil
|
217
226
|
response.should render_template("contacts/edit")
|
@@ -219,7 +228,7 @@ describe ContactsController do
|
|
219
228
|
|
220
229
|
it "should expose the requested contact as @contact and linked account as @account" do
|
221
230
|
@account = FactoryGirl.create(:account, :id => 99)
|
222
|
-
@contact = FactoryGirl.create(:contact, :id => 42, :user =>
|
231
|
+
@contact = FactoryGirl.create(:contact, :id => 42, :user => current_user, :lead => nil)
|
223
232
|
FactoryGirl.create(:account_contact, :account => @account, :contact => @contact)
|
224
233
|
|
225
234
|
xhr :get, :edit, :id => 42
|
@@ -237,7 +246,7 @@ describe ContactsController do
|
|
237
246
|
|
238
247
|
describe "(contact got deleted or is otherwise unavailable)" do
|
239
248
|
it "should reload current page with the flash message if the contact got deleted" do
|
240
|
-
@contact = FactoryGirl.create(:contact, :user =>
|
249
|
+
@contact = FactoryGirl.create(:contact, :user => current_user)
|
241
250
|
@contact.destroy
|
242
251
|
|
243
252
|
xhr :get, :edit, :id => @contact.id
|
@@ -256,7 +265,7 @@ describe ContactsController do
|
|
256
265
|
|
257
266
|
describe "(previous contact got deleted or is otherwise unavailable)" do
|
258
267
|
before(:each) do
|
259
|
-
@contact = FactoryGirl.create(:contact, :user =>
|
268
|
+
@contact = FactoryGirl.create(:contact, :user => current_user)
|
260
269
|
@previous = FactoryGirl.create(:contact, :user => FactoryGirl.create(:user))
|
261
270
|
end
|
262
271
|
|
@@ -291,9 +300,9 @@ describe ContactsController do
|
|
291
300
|
@contact = FactoryGirl.build(:contact, :first_name => "Billy", :last_name => "Bones")
|
292
301
|
Contact.stub!(:new).and_return(@contact)
|
293
302
|
|
294
|
-
xhr :post, :create, :contact => { :first_name => "Billy", :last_name => "Bones" }, :account => { :name => "Hello world" }
|
303
|
+
xhr :post, :create, :contact => { :first_name => "Billy", :last_name => "Bones" }, :account => { :name => "Hello world" }
|
295
304
|
assigns(:contact).should == @contact
|
296
|
-
assigns(:contact).account.name.should == "Hello world"
|
305
|
+
assigns(:contact).reload.account.name.should == "Hello world"
|
297
306
|
response.should render_template("contacts/create")
|
298
307
|
end
|
299
308
|
|
@@ -308,31 +317,37 @@ describe ContactsController do
|
|
308
317
|
end
|
309
318
|
|
310
319
|
it "should reload contacts to update pagination if called from contacts index" do
|
311
|
-
@contact = FactoryGirl.build(:contact, :user =>
|
320
|
+
@contact = FactoryGirl.build(:contact, :user => current_user)
|
312
321
|
Contact.stub!(:new).and_return(@contact)
|
313
322
|
|
314
323
|
request.env["HTTP_REFERER"] = "http://localhost/contacts"
|
315
|
-
xhr :post, :create, :contact => { :first_name => "Billy", :last_name => "Bones" }, :account => {}
|
324
|
+
xhr :post, :create, :contact => { :first_name => "Billy", :last_name => "Bones" }, :account => {}
|
316
325
|
assigns[:contacts].should == [ @contact ]
|
317
326
|
end
|
327
|
+
|
328
|
+
it "should add a new comment to the newly created contact when specified" do
|
329
|
+
@contact = FactoryGirl.build(:contact, :user => current_user)
|
330
|
+
Contact.stub!(:new).and_return(@contact)
|
331
|
+
|
332
|
+
xhr :post, :create, :contact => { :first_name => "Testy", :last_name => "McTest" }, :account => { :name => "Hello world" }, :comment_body => "Awesome comment is awesome"
|
333
|
+
assigns[:contact].comments.map(&:comment).should include("Awesome comment is awesome")
|
334
|
+
end
|
318
335
|
end
|
319
336
|
|
320
337
|
describe "with invalid params" do
|
321
338
|
|
322
339
|
before(:each) do
|
323
|
-
@contact = FactoryGirl.build(:contact, :first_name => nil, :user =>
|
340
|
+
@contact = FactoryGirl.build(:contact, :first_name => nil, :user => current_user, :lead => nil)
|
324
341
|
Contact.stub!(:new).and_return(@contact)
|
325
|
-
@users = [ FactoryGirl.create(:user) ]
|
326
342
|
end
|
327
343
|
|
328
344
|
# Redraw [create] form with selected account.
|
329
345
|
it "should redraw [Create Contact] form with selected account" do
|
330
|
-
@account = FactoryGirl.create(:account, :id => 42, :user =>
|
346
|
+
@account = FactoryGirl.create(:account, :id => 42, :user => current_user)
|
331
347
|
|
332
348
|
# This redraws [create] form with blank account.
|
333
|
-
xhr :post, :create, :contact => {}, :account => { :id => 42, :user_id =>
|
349
|
+
xhr :post, :create, :contact => {}, :account => { :id => 42, :user_id => current_user.id }
|
334
350
|
assigns(:contact).should == @contact
|
335
|
-
assigns(:users).should == @users
|
336
351
|
assigns(:account).should == @account
|
337
352
|
assigns(:accounts).should == [ @account ]
|
338
353
|
response.should render_template("contacts/create")
|
@@ -340,24 +355,22 @@ describe ContactsController do
|
|
340
355
|
|
341
356
|
# Redraw [create] form with related account.
|
342
357
|
it "should redraw [Create Contact] form with related account" do
|
343
|
-
@account = FactoryGirl.create(:account, :id => 123, :user =>
|
358
|
+
@account = FactoryGirl.create(:account, :id => 123, :user => current_user)
|
344
359
|
|
345
360
|
request.env["HTTP_REFERER"] = "http://localhost/accounts/123"
|
346
|
-
xhr :post, :create, :contact => { :first_name => nil }, :account => { :name => nil, :user_id =>
|
361
|
+
xhr :post, :create, :contact => { :first_name => nil }, :account => { :name => nil, :user_id => current_user.id }
|
347
362
|
assigns(:contact).should == @contact
|
348
|
-
assigns(:users).should == @users
|
349
363
|
assigns(:account).should == @account
|
350
364
|
assigns(:accounts).should == [ @account ]
|
351
365
|
response.should render_template("contacts/create")
|
352
366
|
end
|
353
367
|
|
354
368
|
it "should redraw [Create Contact] form with blank account" do
|
355
|
-
@accounts = [ FactoryGirl.create(:account, :user =>
|
356
|
-
@account = Account.new(:user =>
|
369
|
+
@accounts = [ FactoryGirl.create(:account, :user => current_user) ]
|
370
|
+
@account = Account.new(:user => current_user)
|
357
371
|
|
358
|
-
xhr :post, :create, :contact => { :first_name => nil }, :account => { :name => nil, :user_id =>
|
372
|
+
xhr :post, :create, :contact => { :first_name => nil }, :account => { :name => nil, :user_id => current_user.id }
|
359
373
|
assigns(:contact).should == @contact
|
360
|
-
assigns(:users).should == @users
|
361
374
|
assigns(:account).attributes.should == @account.attributes
|
362
375
|
assigns(:accounts).should == @accounts
|
363
376
|
response.should render_template("contacts/create")
|
@@ -384,8 +397,8 @@ describe ContactsController do
|
|
384
397
|
@contact = FactoryGirl.create(:contact, :id => 42, :first_name => "Billy")
|
385
398
|
|
386
399
|
xhr :put, :update, :id => 42, :contact => { :first_name => "Bones" }, :account => {}
|
387
|
-
|
388
|
-
assigns
|
400
|
+
assigns[:contact].first_name.should == "Bones"
|
401
|
+
assigns[:contact].should == @contact
|
389
402
|
response.should render_template("contacts/update")
|
390
403
|
end
|
391
404
|
|
@@ -393,8 +406,8 @@ describe ContactsController do
|
|
393
406
|
@contact = FactoryGirl.create(:contact, :id => 42, :first_name => "Billy")
|
394
407
|
|
395
408
|
xhr :put, :update, :id => 42, :contact => { :first_name => "Bones" }, :account => { :name => "new account" }
|
396
|
-
|
397
|
-
|
409
|
+
assigns[:contact].first_name.should == "Bones"
|
410
|
+
assigns[:contact].account.name.should == "new account"
|
398
411
|
end
|
399
412
|
|
400
413
|
it "should be able to link existing account with the contact" do
|
@@ -402,24 +415,22 @@ describe ContactsController do
|
|
402
415
|
@contact = FactoryGirl.create(:contact, :id => 42, :first_name => "Billy")
|
403
416
|
|
404
417
|
xhr :put, :update, :id => 42, :contact => { :first_name => "Bones" }, :account => { :id => 99 }
|
405
|
-
|
406
|
-
|
418
|
+
assigns[:contact].first_name.should == "Bones"
|
419
|
+
assigns[:contact].account.id.should == 99
|
407
420
|
end
|
408
421
|
|
409
422
|
it "should update contact permissions when sharing with specific users" do
|
410
423
|
@contact = FactoryGirl.create(:contact, :id => 42, :access => "Public")
|
411
|
-
he = FactoryGirl.create(:user, :id => 7)
|
412
|
-
she = FactoryGirl.create(:user, :id => 8)
|
413
424
|
|
414
|
-
xhr :put, :update, :id => 42, :contact => { :first_name => "Hello", :access => "Shared"
|
415
|
-
|
416
|
-
|
425
|
+
xhr :put, :update, :id => 42, :contact => { :first_name => "Hello", :access => "Shared", :user_ids => [7, 8] }, :account => {}
|
426
|
+
assigns[:contact].access.should == "Shared"
|
427
|
+
assigns[:contact].user_ids.sort.should == [ 7, 8 ]
|
417
428
|
assigns[:contact].should == @contact
|
418
429
|
end
|
419
430
|
|
420
431
|
describe "contact got deleted or otherwise unavailable" do
|
421
432
|
it "should reload current page is the contact got deleted" do
|
422
|
-
@contact = FactoryGirl.create(:contact, :user =>
|
433
|
+
@contact = FactoryGirl.create(:contact, :user => current_user)
|
423
434
|
@contact.destroy
|
424
435
|
|
425
436
|
xhr :put, :update, :id => @contact.id
|
@@ -441,15 +452,13 @@ describe ContactsController do
|
|
441
452
|
describe "with invalid params" do
|
442
453
|
|
443
454
|
it "should not update the contact, but still expose it as @contact and render [update] template" do
|
444
|
-
@contact = FactoryGirl.create(:contact, :id => 42, :user =>
|
445
|
-
@account = Account.new(:user =>
|
446
|
-
@users = [ FactoryGirl.create(:user) ]
|
455
|
+
@contact = FactoryGirl.create(:contact, :id => 42, :user => current_user, :first_name => "Billy", :lead => nil)
|
456
|
+
@account = Account.new(:user => current_user)
|
447
457
|
|
448
458
|
xhr :put, :update, :id => 42, :contact => { :first_name => nil }, :account => {}
|
449
|
-
|
450
|
-
assigns
|
451
|
-
assigns
|
452
|
-
assigns(:users).should == @users
|
459
|
+
assigns[:contact].reload.first_name.should == "Billy"
|
460
|
+
assigns[:contact].should == @contact
|
461
|
+
assigns[:account].attributes.should == @account.attributes
|
453
462
|
response.should render_template("contacts/update")
|
454
463
|
end
|
455
464
|
|
@@ -458,7 +467,7 @@ describe ContactsController do
|
|
458
467
|
@contact = FactoryGirl.create(:contact, :id => 42, :account => @account)
|
459
468
|
|
460
469
|
xhr :put, :update, :id => 42, :contact => { :first_name => nil }, :account => { :id => 99 }
|
461
|
-
assigns
|
470
|
+
assigns[:account].should == @account
|
462
471
|
end
|
463
472
|
|
464
473
|
end
|
@@ -470,7 +479,7 @@ describe ContactsController do
|
|
470
479
|
#----------------------------------------------------------------------------
|
471
480
|
describe "responding to DELETE destroy" do
|
472
481
|
before(:each) do
|
473
|
-
@contact = FactoryGirl.create(:contact, :user =>
|
482
|
+
@contact = FactoryGirl.create(:contact, :user => current_user)
|
474
483
|
end
|
475
484
|
|
476
485
|
describe "AJAX request" do
|
@@ -515,7 +524,7 @@ describe ContactsController do
|
|
515
524
|
|
516
525
|
describe "contact got deleted or otherwise unavailable" do
|
517
526
|
it "should reload current page is the contact got deleted" do
|
518
|
-
@contact = FactoryGirl.create(:contact, :user =>
|
527
|
+
@contact = FactoryGirl.create(:contact, :user => current_user)
|
519
528
|
@contact.destroy
|
520
529
|
|
521
530
|
xhr :delete, :destroy, :id => @contact.id
|
@@ -542,7 +551,7 @@ describe ContactsController do
|
|
542
551
|
end
|
543
552
|
|
544
553
|
it "should redirect to contact index with the flash message is the contact got deleted" do
|
545
|
-
@contact = FactoryGirl.create(:contact, :user =>
|
554
|
+
@contact = FactoryGirl.create(:contact, :user => current_user)
|
546
555
|
@contact.destroy
|
547
556
|
|
548
557
|
delete :destroy, :id => @contact.id
|
@@ -628,63 +637,38 @@ describe ContactsController do
|
|
628
637
|
#----------------------------------------------------------------------------
|
629
638
|
describe "responding to POST auto_complete" do
|
630
639
|
before(:each) do
|
631
|
-
@auto_complete_matches = [ FactoryGirl.create(:contact, :first_name => "Hello", :last_name => "World", :user =>
|
640
|
+
@auto_complete_matches = [ FactoryGirl.create(:contact, :first_name => "Hello", :last_name => "World", :user => current_user) ]
|
632
641
|
end
|
633
642
|
|
634
643
|
it_should_behave_like("auto complete")
|
635
644
|
end
|
636
645
|
|
637
|
-
# GET /contacts/options AJAX
|
638
|
-
#----------------------------------------------------------------------------
|
639
|
-
describe "responding to GET options" do
|
640
|
-
it "should set current user preferences when showing options" do
|
641
|
-
@per_page = FactoryGirl.create(:preference, :user => @current_user, :name => "contacts_per_page", :value => Base64.encode64(Marshal.dump(42)))
|
642
|
-
@outline = FactoryGirl.create(:preference, :user => @current_user, :name => "contacts_outline", :value => Base64.encode64(Marshal.dump("option_long")))
|
643
|
-
@sort_by = FactoryGirl.create(:preference, :user => @current_user, :name => "contacts_sort_by", :value => Base64.encode64(Marshal.dump("contacts.first_name ASC")))
|
644
|
-
@naming = FactoryGirl.create(:preference, :user => @current_user, :name => "contacts_naming", :value => Base64.encode64(Marshal.dump("option_after")))
|
645
|
-
|
646
|
-
xhr :get, :options
|
647
|
-
assigns[:per_page].should == 42
|
648
|
-
assigns[:outline].should == "option_long"
|
649
|
-
assigns[:sort_by].should == "contacts.first_name ASC"
|
650
|
-
assigns[:naming].should == "option_after"
|
651
|
-
end
|
652
|
-
|
653
|
-
it "should not assign instance variables when hiding options" do
|
654
|
-
xhr :get, :options, :cancel => "true"
|
655
|
-
assigns[:per_page].should == nil
|
656
|
-
assigns[:outline].should == nil
|
657
|
-
assigns[:sort_by].should == nil
|
658
|
-
assigns[:naming].should == nil
|
659
|
-
end
|
660
|
-
end
|
661
|
-
|
662
646
|
# POST /contacts/redraw AJAX
|
663
647
|
#----------------------------------------------------------------------------
|
664
648
|
describe "responding to POST redraw" do
|
665
649
|
it "should save user selected contact preference" do
|
666
|
-
xhr :post, :redraw, :per_page => 42, :
|
667
|
-
|
668
|
-
|
669
|
-
|
670
|
-
|
650
|
+
xhr :post, :redraw, :per_page => 42, :view => "long", :sort_by => "first_name", :naming => "after"
|
651
|
+
current_user.preference[:contacts_per_page].to_i.should == 42
|
652
|
+
current_user.preference[:contacts_index_view].should == "long"
|
653
|
+
current_user.preference[:contacts_sort_by].should == "contacts.first_name ASC"
|
654
|
+
current_user.preference[:contacts_naming].should == "after"
|
671
655
|
end
|
672
656
|
|
673
657
|
it "should set similar options for Leads" do
|
674
658
|
xhr :post, :redraw, :sort_by => "first_name", :naming => "after"
|
675
|
-
|
676
|
-
|
659
|
+
current_user.pref[:leads_sort_by].should == "leads.first_name ASC"
|
660
|
+
current_user.pref[:leads_naming].should == "after"
|
677
661
|
end
|
678
662
|
|
679
663
|
it "should reset current page to 1" do
|
680
|
-
xhr :post, :redraw, :per_page => 42, :
|
664
|
+
xhr :post, :redraw, :per_page => 42, :view => "long", :sort_by => "first_name", :naming => "after"
|
681
665
|
session[:contacts_current_page].should == 1
|
682
666
|
end
|
683
667
|
|
684
668
|
it "should select @contacts and render [index] template" do
|
685
669
|
@contacts = [
|
686
|
-
FactoryGirl.create(:contact, :first_name => "Alice", :user =>
|
687
|
-
FactoryGirl.create(:contact, :first_name => "Bobby", :user =>
|
670
|
+
FactoryGirl.create(:contact, :first_name => "Alice", :user => current_user),
|
671
|
+
FactoryGirl.create(:contact, :first_name => "Bobby", :user => current_user)
|
688
672
|
]
|
689
673
|
|
690
674
|
xhr :post, :redraw, :per_page => 1, :sort_by => "first_name"
|
@@ -694,4 +678,3 @@ describe ContactsController do
|
|
694
678
|
end
|
695
679
|
|
696
680
|
end
|
697
|
-
|
@@ -13,7 +13,7 @@ describe LeadsController do
|
|
13
13
|
describe "responding to GET index" do
|
14
14
|
|
15
15
|
it "should expose all leads as @leads and render [index] template" do
|
16
|
-
@leads = [ FactoryGirl.create(:lead, :user =>
|
16
|
+
@leads = [ FactoryGirl.create(:lead, :user => current_user) ]
|
17
17
|
|
18
18
|
get :index
|
19
19
|
assigns[:leads].should == @leads
|
@@ -21,7 +21,7 @@ describe LeadsController do
|
|
21
21
|
end
|
22
22
|
|
23
23
|
it "should collect the data for the leads sidebar" do
|
24
|
-
@leads = [ FactoryGirl.create(:lead, :user =>
|
24
|
+
@leads = [ FactoryGirl.create(:lead, :user => current_user) ]
|
25
25
|
@status = Setting.lead_status.dup
|
26
26
|
|
27
27
|
get :index
|
@@ -31,12 +31,12 @@ describe LeadsController do
|
|
31
31
|
it "should filter out leads by status" do
|
32
32
|
controller.session[:leads_filter] = "new,contacted"
|
33
33
|
@leads = [
|
34
|
-
FactoryGirl.create(:lead, :status => "new", :user =>
|
35
|
-
FactoryGirl.create(:lead, :status => "contacted", :user =>
|
34
|
+
FactoryGirl.create(:lead, :status => "new", :user => current_user),
|
35
|
+
FactoryGirl.create(:lead, :status => "contacted", :user => current_user)
|
36
36
|
]
|
37
37
|
|
38
38
|
# This one should be filtered out.
|
39
|
-
FactoryGirl.create(:lead, :status => "rejected", :user =>
|
39
|
+
FactoryGirl.create(:lead, :status => "rejected", :user => current_user)
|
40
40
|
|
41
41
|
get :index
|
42
42
|
# Note: can't compare campaigns directly because of BigDecimals.
|
@@ -45,8 +45,8 @@ describe LeadsController do
|
|
45
45
|
end
|
46
46
|
|
47
47
|
it "should perform lookup using query string" do
|
48
|
-
@billy_bones = FactoryGirl.create(:lead, :user =>
|
49
|
-
@captain_flint = FactoryGirl.create(:lead, :user =>
|
48
|
+
@billy_bones = FactoryGirl.create(:lead, :user => current_user, :first_name => "Billy", :last_name => "Bones")
|
49
|
+
@captain_flint = FactoryGirl.create(:lead, :user => current_user, :first_name => "Captain", :last_name => "Flint")
|
50
50
|
|
51
51
|
get :index, :query => "bill"
|
52
52
|
assigns[:leads].should == [ @billy_bones ]
|
@@ -56,7 +56,7 @@ describe LeadsController do
|
|
56
56
|
|
57
57
|
describe "AJAX pagination" do
|
58
58
|
it "should pick up page number from params" do
|
59
|
-
@leads = [ FactoryGirl.create(:lead, :user =>
|
59
|
+
@leads = [ FactoryGirl.create(:lead, :user => current_user) ]
|
60
60
|
xhr :get, :index, :page => 42
|
61
61
|
|
62
62
|
assigns[:current_page].to_i.should == 42
|
@@ -67,13 +67,25 @@ describe LeadsController do
|
|
67
67
|
|
68
68
|
it "should pick up saved page number from session" do
|
69
69
|
session[:leads_current_page] = 42
|
70
|
-
|
71
|
-
|
70
|
+
session[:leads_current_query] = "bill"
|
71
|
+
@leads = [ FactoryGirl.create(:lead, :user => current_user) ]
|
72
|
+
xhr :get, :index, :query => "bill"
|
72
73
|
|
73
74
|
assigns[:current_page].should == 42
|
74
75
|
assigns[:leads].should == []
|
75
76
|
response.should render_template("leads/index")
|
76
77
|
end
|
78
|
+
|
79
|
+
it "should reset current_page when query is altered" do
|
80
|
+
session[:leads_current_page] = 42
|
81
|
+
session[:leads_current_query] = "bill"
|
82
|
+
@leads = [ FactoryGirl.create(:lead, :user => current_user) ]
|
83
|
+
xhr :get, :index
|
84
|
+
|
85
|
+
assigns[:current_page].should == 1
|
86
|
+
assigns[:leads].should == @leads
|
87
|
+
response.should render_template("leads/index")
|
88
|
+
end
|
77
89
|
end
|
78
90
|
|
79
91
|
describe "with mime type of JSON" do
|
@@ -106,7 +118,7 @@ describe LeadsController do
|
|
106
118
|
|
107
119
|
describe "with mime type of HTML" do
|
108
120
|
before(:each) do
|
109
|
-
@lead = FactoryGirl.create(:lead, :id => 42, :user =>
|
121
|
+
@lead = FactoryGirl.create(:lead, :id => 42, :user => current_user)
|
110
122
|
@comment = Comment.new
|
111
123
|
end
|
112
124
|
|
@@ -125,7 +137,7 @@ describe LeadsController do
|
|
125
137
|
|
126
138
|
describe "with mime type of JSON" do
|
127
139
|
it "should render the requested lead as JSON" do
|
128
|
-
@lead = FactoryGirl.create(:lead, :id => 42, :user =>
|
140
|
+
@lead = FactoryGirl.create(:lead, :id => 42, :user => current_user)
|
129
141
|
Lead.should_receive(:find).and_return(@lead)
|
130
142
|
@lead.should_receive(:to_json).and_return("generated JSON")
|
131
143
|
|
@@ -137,7 +149,7 @@ describe LeadsController do
|
|
137
149
|
|
138
150
|
describe "with mime type of XML" do
|
139
151
|
it "should render the requested lead as xml" do
|
140
|
-
@lead = FactoryGirl.create(:lead, :id => 42, :user =>
|
152
|
+
@lead = FactoryGirl.create(:lead, :id => 42, :user => current_user)
|
141
153
|
Lead.should_receive(:find).and_return(@lead)
|
142
154
|
@lead.should_receive(:to_xml).and_return("generated XML")
|
143
155
|
|
@@ -149,7 +161,7 @@ describe LeadsController do
|
|
149
161
|
|
150
162
|
describe "lead got deleted or otherwise unavailable" do
|
151
163
|
it "should redirect to lead index if the lead got deleted" do
|
152
|
-
@lead = FactoryGirl.create(:lead, :user =>
|
164
|
+
@lead = FactoryGirl.create(:lead, :user => current_user)
|
153
165
|
@lead.destroy
|
154
166
|
|
155
167
|
get :show, :id => @lead.id
|
@@ -166,7 +178,7 @@ describe LeadsController do
|
|
166
178
|
end
|
167
179
|
|
168
180
|
it "should return 404 (Not Found) JSON error" do
|
169
|
-
@lead = FactoryGirl.create(:lead, :user =>
|
181
|
+
@lead = FactoryGirl.create(:lead, :user => current_user)
|
170
182
|
@lead.destroy
|
171
183
|
request.env["HTTP_ACCEPT"] = "application/json"
|
172
184
|
|
@@ -175,7 +187,7 @@ describe LeadsController do
|
|
175
187
|
end
|
176
188
|
|
177
189
|
it "should return 404 (Not Found) XML error" do
|
178
|
-
@lead = FactoryGirl.create(:lead, :user =>
|
190
|
+
@lead = FactoryGirl.create(:lead, :user => current_user)
|
179
191
|
@lead.destroy
|
180
192
|
request.env["HTTP_ACCEPT"] = "application/xml"
|
181
193
|
|
@@ -192,14 +204,12 @@ describe LeadsController do
|
|
192
204
|
describe "responding to GET new" do
|
193
205
|
|
194
206
|
it "should expose a new lead as @lead and render [new] template" do
|
195
|
-
@lead = FactoryGirl.build(:lead, :user =>
|
207
|
+
@lead = FactoryGirl.build(:lead, :user => current_user, :campaign => nil)
|
196
208
|
Lead.stub!(:new).and_return(@lead)
|
197
|
-
@
|
198
|
-
@campaigns = [ FactoryGirl.create(:campaign, :user => @current_user) ]
|
209
|
+
@campaigns = [ FactoryGirl.create(:campaign, :user => current_user) ]
|
199
210
|
|
200
211
|
xhr :get, :new
|
201
212
|
assigns[:lead].attributes.should == @lead.attributes
|
202
|
-
assigns[:users].should == @users
|
203
213
|
assigns[:campaigns].should == @campaigns
|
204
214
|
response.should render_template("leads/new")
|
205
215
|
end
|
@@ -236,13 +246,11 @@ describe LeadsController do
|
|
236
246
|
describe "responding to GET edit" do
|
237
247
|
|
238
248
|
it "should expose the requested lead as @lead and render [edit] template" do
|
239
|
-
@lead = FactoryGirl.create(:lead, :id => 42, :user =>
|
240
|
-
@
|
241
|
-
@campaigns = [ FactoryGirl.create(:campaign, :user => @current_user) ]
|
249
|
+
@lead = FactoryGirl.create(:lead, :id => 42, :user => current_user, :campaign => nil)
|
250
|
+
@campaigns = [ FactoryGirl.create(:campaign, :user => current_user) ]
|
242
251
|
|
243
252
|
xhr :get, :edit, :id => 42
|
244
253
|
assigns[:lead].should == @lead
|
245
|
-
assigns[:users].should == @users
|
246
254
|
assigns[:campaigns].should == @campaigns
|
247
255
|
response.should render_template("leads/edit")
|
248
256
|
end
|
@@ -257,7 +265,7 @@ describe LeadsController do
|
|
257
265
|
|
258
266
|
describe "lead got deleted or is otherwise unavailable" do
|
259
267
|
it "should reload current page with the flash message if the lead got deleted" do
|
260
|
-
@lead = FactoryGirl.create(:lead, :user =>
|
268
|
+
@lead = FactoryGirl.create(:lead, :user => current_user)
|
261
269
|
@lead.destroy
|
262
270
|
|
263
271
|
xhr :get, :edit, :id => @lead.id
|
@@ -276,7 +284,7 @@ describe LeadsController do
|
|
276
284
|
|
277
285
|
describe "(previous lead got deleted or is otherwise unavailable)" do
|
278
286
|
before(:each) do
|
279
|
-
@lead = FactoryGirl.create(:lead, :user =>
|
287
|
+
@lead = FactoryGirl.create(:lead, :user => current_user)
|
280
288
|
@previous = FactoryGirl.create(:lead, :user => FactoryGirl.create(:user))
|
281
289
|
end
|
282
290
|
|
@@ -308,14 +316,12 @@ describe LeadsController do
|
|
308
316
|
describe "with valid params" do
|
309
317
|
|
310
318
|
it "should expose a newly created lead as @lead and render [create] template" do
|
311
|
-
@lead = FactoryGirl.build(:lead, :user =>
|
319
|
+
@lead = FactoryGirl.build(:lead, :user => current_user, :campaign => nil)
|
312
320
|
Lead.stub!(:new).and_return(@lead)
|
313
|
-
@
|
314
|
-
@campaigns = [ FactoryGirl.create(:campaign, :user => @current_user) ]
|
321
|
+
@campaigns = [ FactoryGirl.create(:campaign, :user => current_user) ]
|
315
322
|
|
316
|
-
xhr :post, :create, :lead => { :first_name => "Billy", :last_name => "Bones" }
|
323
|
+
xhr :post, :create, :lead => { :first_name => "Billy", :last_name => "Bones" }
|
317
324
|
assigns(:lead).should == @lead
|
318
|
-
assigns(:users).should == @users
|
319
325
|
assigns(:campaigns).should == @campaigns
|
320
326
|
assigns[:lead_status_total].should be_nil
|
321
327
|
response.should render_template("leads/create")
|
@@ -329,10 +335,11 @@ describe LeadsController do
|
|
329
335
|
@campaign.permissions << FactoryGirl.build(:permission, :user => she, :asset => @campaign)
|
330
336
|
@campaign.save
|
331
337
|
|
332
|
-
@lead = FactoryGirl.build(:lead, :campaign => @campaign, :user =>
|
338
|
+
@lead = FactoryGirl.build(:lead, :campaign => @campaign, :user => current_user, :access => "Shared")
|
333
339
|
Lead.stub!(:new).and_return(@lead)
|
334
340
|
|
335
|
-
xhr :
|
341
|
+
xhr :post, :create, :lead => { :first_name => "Billy", :last_name => "Bones", :access => "Campaign", :user_ids => %w(7 8) }, :campaign => @campaign.id
|
342
|
+
assigns(:lead).should == @lead
|
336
343
|
@lead.reload.access.should == "Shared"
|
337
344
|
@lead.permissions.map(&:user_id).sort.should == [ 7, 8 ]
|
338
345
|
@lead.permissions.map(&:asset_id).should == [ @lead.id, @lead.id ]
|
@@ -340,45 +347,49 @@ describe LeadsController do
|
|
340
347
|
end
|
341
348
|
|
342
349
|
it "should get the data to update leads sidebar if called from leads index" do
|
343
|
-
@lead = FactoryGirl.build(:lead, :user =>
|
350
|
+
@lead = FactoryGirl.build(:lead, :user => current_user, :campaign => nil)
|
344
351
|
Lead.stub!(:new).and_return(@lead)
|
345
352
|
|
346
353
|
request.env["HTTP_REFERER"] = "http://localhost/leads"
|
347
|
-
xhr :post, :create, :lead => { :first_name => "Billy", :last_name => "Bones" }
|
354
|
+
xhr :post, :create, :lead => { :first_name => "Billy", :last_name => "Bones" }
|
348
355
|
assigns[:lead_status_total].should be_an_instance_of(HashWithIndifferentAccess)
|
349
356
|
end
|
350
357
|
|
351
358
|
it "should reload leads to update pagination if called from leads index" do
|
352
|
-
@lead = FactoryGirl.build(:lead, :user =>
|
359
|
+
@lead = FactoryGirl.build(:lead, :user => current_user, :campaign => nil)
|
353
360
|
Lead.stub!(:new).and_return(@lead)
|
354
361
|
|
355
362
|
request.env["HTTP_REFERER"] = "http://localhost/leads"
|
356
|
-
xhr :post, :create, :lead => { :first_name => "Billy", :last_name => "Bones" }
|
363
|
+
xhr :post, :create, :lead => { :first_name => "Billy", :last_name => "Bones" }
|
357
364
|
assigns[:leads].should == [ @lead ]
|
358
365
|
end
|
359
366
|
|
360
367
|
it "should reload lead campaign if called from campaign landing page" do
|
361
368
|
@campaign = FactoryGirl.create(:campaign)
|
362
|
-
@lead = FactoryGirl.build(:lead, :user =>
|
369
|
+
@lead = FactoryGirl.build(:lead, :user => current_user, :campaign => @campaign)
|
363
370
|
|
364
371
|
request.env["HTTP_REFERER"] = "http://localhost/campaigns/#{@campaign.id}"
|
365
372
|
xhr :put, :create, :lead => { :first_name => "Billy", :last_name => "Bones"}, :campaign => @campaign.id
|
366
373
|
assigns[:campaign].should == @campaign
|
367
374
|
end
|
368
|
-
|
375
|
+
|
376
|
+
it "should add a new comment to the newly created lead when specified" do
|
377
|
+
@lead = FactoryGirl.create(:lead)
|
378
|
+
Lead.stub!(:new).and_return(@lead)
|
379
|
+
xhr :post, :create, :lead => { :first_name => "Test", :last_name => "Lead" }, :comment_body => "This is an important lead."
|
380
|
+
@lead.reload.comments.map(&:comment).should include("This is an important lead.")
|
381
|
+
end
|
369
382
|
end
|
370
383
|
|
371
384
|
describe "with invalid params" do
|
372
385
|
|
373
386
|
it "should expose a newly created but unsaved lead as @lead and still render [create] template" do
|
374
|
-
@lead = FactoryGirl.build(:lead, :user =>
|
387
|
+
@lead = FactoryGirl.build(:lead, :user => current_user, :first_name => nil, :campaign => nil)
|
375
388
|
Lead.stub!(:new).and_return(@lead)
|
376
|
-
@
|
377
|
-
@campaigns = [ FactoryGirl.create(:campaign, :user => @current_user) ]
|
389
|
+
@campaigns = [ FactoryGirl.create(:campaign, :user => current_user) ]
|
378
390
|
|
379
|
-
xhr :post, :create, :lead => { :first_name => nil }
|
391
|
+
xhr :post, :create, :lead => { :first_name => nil }
|
380
392
|
assigns(:lead).should == @lead
|
381
|
-
assigns(:users).should == @users
|
382
393
|
assigns(:campaigns).should == @campaigns
|
383
394
|
assigns[:lead_status_total].should == nil
|
384
395
|
response.should render_template("leads/create")
|
@@ -396,7 +407,7 @@ describe LeadsController do
|
|
396
407
|
describe "with valid params" do
|
397
408
|
|
398
409
|
it "should update the requested lead, expose it as @lead, and render [update] template" do
|
399
|
-
@lead = FactoryGirl.create(:lead, :first_name => "Billy", :user =>
|
410
|
+
@lead = FactoryGirl.create(:lead, :first_name => "Billy", :user => current_user)
|
400
411
|
|
401
412
|
xhr :put, :update, :id => @lead.id, :lead => { :first_name => "Bones" }
|
402
413
|
@lead.reload.first_name.should == "Bones"
|
@@ -406,14 +417,14 @@ describe LeadsController do
|
|
406
417
|
end
|
407
418
|
|
408
419
|
it "should update lead status" do
|
409
|
-
@lead = FactoryGirl.create(:lead, :status => "new", :user =>
|
420
|
+
@lead = FactoryGirl.create(:lead, :status => "new", :user => current_user)
|
410
421
|
|
411
422
|
xhr :put, :update, :id => @lead.id, :lead => { :status => "rejected" }
|
412
423
|
@lead.reload.status.should == "rejected"
|
413
424
|
end
|
414
425
|
|
415
426
|
it "should update lead source" do
|
416
|
-
@lead = FactoryGirl.create(:lead, :source => "campaign", :user =>
|
427
|
+
@lead = FactoryGirl.create(:lead, :source => "campaign", :user => current_user)
|
417
428
|
|
418
429
|
xhr :put, :update, :id => @lead.id, :lead => { :source => "cald_call" }
|
419
430
|
@lead.reload.source.should == "cald_call"
|
@@ -458,13 +469,13 @@ describe LeadsController do
|
|
458
469
|
@campaigns[:new].reload.leads_count.should == @counts[:new] + 1
|
459
470
|
end
|
460
471
|
|
461
|
-
it "should update shared permissions for the
|
462
|
-
@lead = FactoryGirl.create(:lead, :user =>
|
472
|
+
it "should update shared permissions for the lead" do
|
473
|
+
@lead = FactoryGirl.create(:lead, :user => current_user)
|
463
474
|
he = FactoryGirl.create(:user, :id => 7)
|
464
475
|
she = FactoryGirl.create(:user, :id => 8)
|
465
476
|
|
466
|
-
xhr :put, :update, :id => @lead.id, :lead => { :access => "Shared"
|
467
|
-
@lead.
|
477
|
+
xhr :put, :update, :id => @lead.id, :lead => { :access => "Shared", :user_ids => %w(7 8) }
|
478
|
+
@lead.user_ids.sort.should == [ 7, 8 ]
|
468
479
|
end
|
469
480
|
|
470
481
|
it "should get the data for leads sidebar when called from leads index" do
|
@@ -487,7 +498,7 @@ describe LeadsController do
|
|
487
498
|
|
488
499
|
describe "lead got deleted or otherwise unavailable" do
|
489
500
|
it "should reload current page with the flash message if the lead got deleted" do
|
490
|
-
@lead = FactoryGirl.create(:lead, :user =>
|
501
|
+
@lead = FactoryGirl.create(:lead, :user => current_user)
|
491
502
|
@lead.destroy
|
492
503
|
|
493
504
|
xhr :put, :update, :id => @lead.id
|
@@ -508,13 +519,11 @@ describe LeadsController do
|
|
508
519
|
describe "with invalid params" do
|
509
520
|
|
510
521
|
it "should not update the lead, but still expose it as @lead and render [update] template" do
|
511
|
-
@lead = FactoryGirl.create(:lead, :id => 42, :user =>
|
512
|
-
@
|
513
|
-
@campaigns = [ FactoryGirl.create(:campaign, :user => @current_user) ]
|
522
|
+
@lead = FactoryGirl.create(:lead, :id => 42, :user => current_user, :campaign => nil)
|
523
|
+
@campaigns = [ FactoryGirl.create(:campaign, :user => current_user) ]
|
514
524
|
|
515
525
|
xhr :put, :update, :id => 42, :lead => { :first_name => nil }
|
516
526
|
assigns[:lead].should == @lead
|
517
|
-
assigns[:users].should == @users
|
518
527
|
assigns[:campaigns].should == @campaigns
|
519
528
|
response.should render_template("leads/update")
|
520
529
|
end
|
@@ -529,7 +538,7 @@ describe LeadsController do
|
|
529
538
|
describe "responding to DELETE destroy" do
|
530
539
|
|
531
540
|
before(:each) do
|
532
|
-
@lead = FactoryGirl.create(:lead, :user =>
|
541
|
+
@lead = FactoryGirl.create(:lead, :user => current_user)
|
533
542
|
end
|
534
543
|
|
535
544
|
describe "AJAX request" do
|
@@ -547,7 +556,7 @@ describe LeadsController do
|
|
547
556
|
end
|
548
557
|
|
549
558
|
it "should get data for the sidebar" do
|
550
|
-
@another_lead = FactoryGirl.create(:lead, :user =>
|
559
|
+
@another_lead = FactoryGirl.create(:lead, :user => current_user)
|
551
560
|
|
552
561
|
xhr :delete, :destroy, :id => @lead.id
|
553
562
|
assigns[:leads].should == [ @another_lead ] # @lead got deleted
|
@@ -576,7 +585,7 @@ describe LeadsController do
|
|
576
585
|
describe "when called from campaign landing page" do
|
577
586
|
before(:each) do
|
578
587
|
@campaign = FactoryGirl.create(:campaign)
|
579
|
-
@lead = FactoryGirl.create(:lead, :user =>
|
588
|
+
@lead = FactoryGirl.create(:lead, :user => current_user, :campaign => @campaign)
|
580
589
|
request.env["HTTP_REFERER"] = "http://localhost/campaigns/#{@campaign.id}"
|
581
590
|
end
|
582
591
|
|
@@ -595,7 +604,7 @@ describe LeadsController do
|
|
595
604
|
|
596
605
|
describe "lead got deleted or otherwise unavailable" do
|
597
606
|
it "should reload current page with the flash message if the lead got deleted" do
|
598
|
-
@lead = FactoryGirl.create(:lead, :user =>
|
607
|
+
@lead = FactoryGirl.create(:lead, :user => current_user)
|
599
608
|
@lead.destroy
|
600
609
|
|
601
610
|
xhr :delete, :destroy, :id => @lead.id
|
@@ -622,7 +631,7 @@ describe LeadsController do
|
|
622
631
|
end
|
623
632
|
|
624
633
|
it "should redirect to lead index with the flash message is the lead got deleted" do
|
625
|
-
@lead = FactoryGirl.create(:lead, :user =>
|
634
|
+
@lead = FactoryGirl.create(:lead, :user => current_user)
|
626
635
|
@lead.destroy
|
627
636
|
|
628
637
|
delete :destroy, :id => @lead.id
|
@@ -646,16 +655,14 @@ describe LeadsController do
|
|
646
655
|
describe "responding to GET convert" do
|
647
656
|
|
648
657
|
it "should should collect necessary data and render [convert] template" do
|
649
|
-
@campaign = FactoryGirl.create(:campaign, :user =>
|
650
|
-
@lead = FactoryGirl.create(:lead, :user =>
|
651
|
-
@
|
652
|
-
@
|
653
|
-
@
|
654
|
-
@opportunity = Opportunity.new(:user => @current_user, :access => "Lead", :stage => "prospecting", :campaign => @lead.campaign, :source => @lead.source)
|
658
|
+
@campaign = FactoryGirl.create(:campaign, :user => current_user)
|
659
|
+
@lead = FactoryGirl.create(:lead, :user => current_user, :campaign => @campaign, :source => "cold_call")
|
660
|
+
@accounts = [ FactoryGirl.create(:account, :user => current_user) ]
|
661
|
+
@account = Account.new(:user => current_user, :name => @lead.company, :access => "Lead")
|
662
|
+
@opportunity = Opportunity.new(:user => current_user, :access => "Lead", :stage => "prospecting", :campaign => @lead.campaign, :source => @lead.source)
|
655
663
|
|
656
664
|
xhr :get, :convert, :id => @lead.id
|
657
665
|
assigns[:lead].should == @lead
|
658
|
-
assigns[:users].should == @users
|
659
666
|
assigns[:accounts].should == @accounts
|
660
667
|
assigns[:account].attributes.should == @account.attributes
|
661
668
|
assigns[:opportunity].attributes.should == @opportunity.attributes
|
@@ -665,7 +672,7 @@ describe LeadsController do
|
|
665
672
|
|
666
673
|
describe "(lead got deleted or is otherwise unavailable)" do
|
667
674
|
it "should reload current page with the flash message if the lead got deleted" do
|
668
|
-
@lead = FactoryGirl.create(:lead, :user =>
|
675
|
+
@lead = FactoryGirl.create(:lead, :user => current_user)
|
669
676
|
@lead.destroy
|
670
677
|
|
671
678
|
xhr :get, :convert, :id => @lead.id
|
@@ -684,7 +691,7 @@ describe LeadsController do
|
|
684
691
|
|
685
692
|
describe "(previous lead got deleted or is otherwise unavailable)" do
|
686
693
|
before(:each) do
|
687
|
-
@lead = FactoryGirl.create(:lead, :user =>
|
694
|
+
@lead = FactoryGirl.create(:lead, :user => current_user)
|
688
695
|
@previous = FactoryGirl.create(:lead, :user => FactoryGirl.create(:user))
|
689
696
|
end
|
690
697
|
|
@@ -714,19 +721,17 @@ describe LeadsController do
|
|
714
721
|
describe "responding to PUT promote" do
|
715
722
|
|
716
723
|
it "on success: should change lead's status to [converted] and render [promote] template" do
|
717
|
-
@lead = FactoryGirl.create(:lead, :id => 42, :user =>
|
718
|
-
@
|
719
|
-
@
|
720
|
-
@opportunity = FactoryGirl.build(:opportunity, :user => @current_user, :campaign => @lead.campaign,
|
724
|
+
@lead = FactoryGirl.create(:lead, :id => 42, :user => current_user, :campaign => nil)
|
725
|
+
@account = FactoryGirl.create(:account, :id => 123, :user => current_user)
|
726
|
+
@opportunity = FactoryGirl.build(:opportunity, :user => current_user, :campaign => @lead.campaign,
|
721
727
|
:account => @account)
|
722
728
|
Opportunity.stub!(:new).and_return(@opportunity)
|
723
|
-
@contact = FactoryGirl.build(:contact, :user =>
|
729
|
+
@contact = FactoryGirl.build(:contact, :user => current_user, :lead => @lead)
|
724
730
|
Contact.stub!(:new).and_return(@contact)
|
725
731
|
|
726
732
|
xhr :put, :promote, :id => 42, :account => { :id => 123 }, :opportunity => { :name => "Hello" }
|
727
733
|
@lead.reload.status.should == "converted"
|
728
734
|
assigns[:lead].should == @lead
|
729
|
-
assigns[:users].should == @users
|
730
735
|
assigns[:account].should == @account
|
731
736
|
assigns[:accounts].should == [ @account ]
|
732
737
|
assigns[:opportunity].should == @opportunity
|
@@ -742,16 +747,16 @@ describe LeadsController do
|
|
742
747
|
@lead.permissions << FactoryGirl.build(:permission, :user => he, :asset => @lead)
|
743
748
|
@lead.permissions << FactoryGirl.build(:permission, :user => she, :asset => @lead)
|
744
749
|
@lead.save
|
745
|
-
@account = FactoryGirl.build(:account, :user =>
|
750
|
+
@account = FactoryGirl.build(:account, :user => current_user, :access => "Shared")
|
746
751
|
@account.permissions << FactoryGirl.create(:permission, :user => he, :asset => @account)
|
747
752
|
@account.permissions << FactoryGirl.create(:permission, :user => she, :asset => @account)
|
748
753
|
@account.stub!(:new).and_return(@account)
|
749
|
-
@opportunity = FactoryGirl.build(:opportunity, :user =>
|
754
|
+
@opportunity = FactoryGirl.build(:opportunity, :user => current_user, :access => "Shared")
|
750
755
|
@opportunity.permissions << FactoryGirl.create(:permission, :user => he, :asset => @opportunity)
|
751
756
|
@opportunity.permissions << FactoryGirl.create(:permission, :user => she, :asset => @opportunity)
|
752
757
|
@opportunity.stub!(:new).and_return(@opportunity)
|
753
758
|
|
754
|
-
xhr :put, :promote, :id => @lead.id, :access => "Lead", :account => { :name => "Hello", :access => "Lead", :user_id =>
|
759
|
+
xhr :put, :promote, :id => @lead.id, :access => "Lead", :account => { :name => "Hello", :access => "Lead", :user_id => current_user.id }, :opportunity => { :name => "World", :access => "Lead", :user_id => current_user.id }
|
755
760
|
@account.access.should == "Shared"
|
756
761
|
@account.permissions.map(&:user_id).sort.should == [ 7, 8 ]
|
757
762
|
@account.permissions.map(&:asset_id).should == [ @account.id, @account.id ]
|
@@ -764,14 +769,14 @@ describe LeadsController do
|
|
764
769
|
|
765
770
|
it "should assign lead's campaign to the newly created opportunity" do
|
766
771
|
@campaign = FactoryGirl.create(:campaign)
|
767
|
-
@lead = FactoryGirl.create(:lead, :user =>
|
772
|
+
@lead = FactoryGirl.create(:lead, :user => current_user, :campaign => @campaign)
|
768
773
|
|
769
774
|
xhr :put, :promote, :id => @lead.id, :account => { :name => "Hello" }, :opportunity => { :name => "Hello", :campaign_id => @campaign.id }
|
770
775
|
assigns[:opportunity].campaign.should == @campaign
|
771
776
|
end
|
772
777
|
|
773
778
|
it "should assign lead's source to the newly created opportunity" do
|
774
|
-
@lead = FactoryGirl.create(:lead, :user =>
|
779
|
+
@lead = FactoryGirl.create(:lead, :user => current_user, :source => "cold_call")
|
775
780
|
|
776
781
|
xhr :put, :promote, :id => @lead.id, :account => { :name => "Hello" }, :opportunity => { :name => "Hello", :source => @lead.source }
|
777
782
|
assigns[:opportunity].source.should == @lead.source
|
@@ -796,9 +801,8 @@ describe LeadsController do
|
|
796
801
|
end
|
797
802
|
|
798
803
|
it "on failure: should not change lead's status and still render [promote] template" do
|
799
|
-
@lead = FactoryGirl.create(:lead, :id => 42, :user =>
|
800
|
-
@
|
801
|
-
@account = FactoryGirl.create(:account, :id => 123, :user => @current_user)
|
804
|
+
@lead = FactoryGirl.create(:lead, :id => 42, :user => current_user, :status => "new")
|
805
|
+
@account = FactoryGirl.create(:account, :id => 123, :user => current_user)
|
802
806
|
@contact = FactoryGirl.build(:contact, :first_name => nil) # make it fail
|
803
807
|
Contact.stub!(:new).and_return(@contact)
|
804
808
|
|
@@ -809,7 +813,7 @@ describe LeadsController do
|
|
809
813
|
|
810
814
|
describe "lead got deleted or otherwise unavailable" do
|
811
815
|
it "should reload current page with the flash message if the lead got deleted" do
|
812
|
-
@lead = FactoryGirl.create(:lead, :user =>
|
816
|
+
@lead = FactoryGirl.create(:lead, :user => current_user)
|
813
817
|
@lead.destroy
|
814
818
|
|
815
819
|
xhr :put, :promote, :id => @lead.id
|
@@ -833,7 +837,7 @@ describe LeadsController do
|
|
833
837
|
describe "responding to PUT reject" do
|
834
838
|
|
835
839
|
before(:each) do
|
836
|
-
@lead = FactoryGirl.create(:lead, :user =>
|
840
|
+
@lead = FactoryGirl.create(:lead, :user => current_user, :status => "new")
|
837
841
|
end
|
838
842
|
|
839
843
|
describe "AJAX request" do
|
@@ -863,7 +867,7 @@ describe LeadsController do
|
|
863
867
|
|
864
868
|
describe "lead got deleted or otherwise unavailable" do
|
865
869
|
it "should reload current page with the flash message if the lead got deleted" do
|
866
|
-
@lead = FactoryGirl.create(:lead, :user =>
|
870
|
+
@lead = FactoryGirl.create(:lead, :user => current_user)
|
867
871
|
@lead.destroy
|
868
872
|
|
869
873
|
xhr :put, :reject, :id => @lead.id
|
@@ -893,7 +897,7 @@ describe LeadsController do
|
|
893
897
|
|
894
898
|
describe "lead got deleted or otherwise unavailable" do
|
895
899
|
it "should redirect to lead index if the lead got deleted" do
|
896
|
-
@lead = FactoryGirl.create(:lead, :user =>
|
900
|
+
@lead = FactoryGirl.create(:lead, :user => current_user)
|
897
901
|
@lead.destroy
|
898
902
|
|
899
903
|
put :reject, :id => @lead.id
|
@@ -943,7 +947,7 @@ describe LeadsController do
|
|
943
947
|
#----------------------------------------------------------------------------
|
944
948
|
describe "responding to POST discard" do
|
945
949
|
before(:each) do
|
946
|
-
@attachment = FactoryGirl.create(:task, :assigned_to =>
|
950
|
+
@attachment = FactoryGirl.create(:task, :assigned_to => current_user)
|
947
951
|
@model = FactoryGirl.create(:lead)
|
948
952
|
@model.tasks << @attachment
|
949
953
|
end
|
@@ -955,63 +959,38 @@ describe LeadsController do
|
|
955
959
|
#----------------------------------------------------------------------------
|
956
960
|
describe "responding to POST auto_complete" do
|
957
961
|
before(:each) do
|
958
|
-
@auto_complete_matches = [ FactoryGirl.create(:lead, :first_name => "Hello", :last_name => "World", :user =>
|
962
|
+
@auto_complete_matches = [ FactoryGirl.create(:lead, :first_name => "Hello", :last_name => "World", :user => current_user) ]
|
959
963
|
end
|
960
964
|
|
961
965
|
it_should_behave_like("auto complete")
|
962
966
|
end
|
963
967
|
|
964
|
-
# GET /leads/options AJAX
|
965
|
-
#----------------------------------------------------------------------------
|
966
|
-
describe "responding to GET options" do
|
967
|
-
it "should set current user preferences when showing options" do
|
968
|
-
@per_page = FactoryGirl.create(:preference, :user => @current_user, :name => "leads_per_page", :value => Base64.encode64(Marshal.dump(42)))
|
969
|
-
@outline = FactoryGirl.create(:preference, :user => @current_user, :name => "leads_outline", :value => Base64.encode64(Marshal.dump("option_long")))
|
970
|
-
@sort_by = FactoryGirl.create(:preference, :user => @current_user, :name => "leads_sort_by", :value => Base64.encode64(Marshal.dump("leads.first_name ASC")))
|
971
|
-
@naming = FactoryGirl.create(:preference, :user => @current_user, :name => "leads_naming", :value => Base64.encode64(Marshal.dump("option_after")))
|
972
|
-
|
973
|
-
xhr :get, :options
|
974
|
-
assigns[:per_page].should == 42
|
975
|
-
assigns[:outline].should == "option_long"
|
976
|
-
assigns[:sort_by].should == "leads.first_name ASC"
|
977
|
-
assigns[:naming].should == "option_after"
|
978
|
-
end
|
979
|
-
|
980
|
-
it "should not assign instance variables when hiding options" do
|
981
|
-
xhr :get, :options, :cancel => "true"
|
982
|
-
assigns[:per_page].should == nil
|
983
|
-
assigns[:outline].should == nil
|
984
|
-
assigns[:sort_by].should == nil
|
985
|
-
assigns[:naming].should == nil
|
986
|
-
end
|
987
|
-
end
|
988
|
-
|
989
968
|
# POST /leads/redraw AJAX
|
990
969
|
#----------------------------------------------------------------------------
|
991
970
|
describe "responding to POST redraw" do
|
992
971
|
it "should save user selected lead preference" do
|
993
|
-
xhr :post, :redraw, :per_page => 42, :
|
994
|
-
|
995
|
-
|
996
|
-
|
997
|
-
|
972
|
+
xhr :post, :redraw, :per_page => 42, :view => "long", :sort_by => "first_name", :naming => "after"
|
973
|
+
current_user.preference[:leads_per_page].should == "42"
|
974
|
+
current_user.preference[:leads_index_view].should == "long"
|
975
|
+
current_user.preference[:leads_sort_by].should == "leads.first_name ASC"
|
976
|
+
current_user.preference[:leads_naming].should == "after"
|
998
977
|
end
|
999
978
|
|
1000
979
|
it "should set similar options for Contacts" do
|
1001
980
|
xhr :post, :redraw, :sort_by => "first_name", :naming => "after"
|
1002
|
-
|
1003
|
-
|
981
|
+
current_user.pref[:contacts_sort_by].should == "contacts.first_name ASC"
|
982
|
+
current_user.pref[:contacts_naming].should == "after"
|
1004
983
|
end
|
1005
984
|
|
1006
985
|
it "should reset current page to 1" do
|
1007
|
-
xhr :post, :redraw, :per_page => 42, :
|
986
|
+
xhr :post, :redraw, :per_page => 42, :view => "long", :sort_by => "first_name", :naming => "after"
|
1008
987
|
session[:leads_current_page].should == 1
|
1009
988
|
end
|
1010
989
|
|
1011
990
|
it "should select @leads and render [index] template" do
|
1012
991
|
@leads = [
|
1013
|
-
FactoryGirl.create(:lead, :first_name => "Alice", :user =>
|
1014
|
-
FactoryGirl.create(:lead, :first_name => "Bobby", :user =>
|
992
|
+
FactoryGirl.create(:lead, :first_name => "Alice", :user => current_user),
|
993
|
+
FactoryGirl.create(:lead, :first_name => "Bobby", :user => current_user)
|
1015
994
|
]
|
1016
995
|
|
1017
996
|
xhr :post, :redraw, :per_page => 1, :sort_by => "first_name"
|
@@ -1027,7 +1006,7 @@ describe LeadsController do
|
|
1027
1006
|
it "should filter out leads as @leads and render :index action" do
|
1028
1007
|
session[:leads_filter] = "contacted,rejected"
|
1029
1008
|
|
1030
|
-
@leads = [ FactoryGirl.create(:lead, :user =>
|
1009
|
+
@leads = [ FactoryGirl.create(:lead, :user => current_user, :status => "new") ]
|
1031
1010
|
xhr :post, :filter, :status => "new"
|
1032
1011
|
assigns[:leads].should == @leads
|
1033
1012
|
response.should be_a_success
|
@@ -1044,4 +1023,3 @@ describe LeadsController do
|
|
1044
1023
|
end
|
1045
1024
|
|
1046
1025
|
end
|
1047
|
-
|