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
@@ -21,7 +21,7 @@ describe OpportunitiesController do
|
|
21
21
|
end
|
22
22
|
|
23
23
|
it "should expose all opportunities as @opportunities and render [index] template" do
|
24
|
-
@opportunities = [ FactoryGirl.create(:opportunity, :user =>
|
24
|
+
@opportunities = [ FactoryGirl.create(:opportunity, :user => current_user) ]
|
25
25
|
|
26
26
|
get :index
|
27
27
|
assigns[:opportunities].should == @opportunities
|
@@ -37,11 +37,11 @@ describe OpportunitiesController do
|
|
37
37
|
it "should filter out opportunities by stage" do
|
38
38
|
controller.session[:opportunities_filter] = "prospecting,negotiation"
|
39
39
|
@opportunities = [
|
40
|
-
FactoryGirl.create(:opportunity, :user =>
|
41
|
-
FactoryGirl.create(:opportunity, :user =>
|
40
|
+
FactoryGirl.create(:opportunity, :user => current_user, :stage => "negotiation"),
|
41
|
+
FactoryGirl.create(:opportunity, :user => current_user, :stage => "prospecting")
|
42
42
|
]
|
43
43
|
# This one should be filtered out.
|
44
|
-
FactoryGirl.create(:opportunity, :user =>
|
44
|
+
FactoryGirl.create(:opportunity, :user => current_user, :stage => "analysis")
|
45
45
|
|
46
46
|
get :index
|
47
47
|
# Note: can't compare opportunities directly because of BigDecimal objects.
|
@@ -50,8 +50,8 @@ describe OpportunitiesController do
|
|
50
50
|
end
|
51
51
|
|
52
52
|
it "should perform lookup using query string" do
|
53
|
-
@first = FactoryGirl.create(:opportunity, :user =>
|
54
|
-
@second = FactoryGirl.create(:opportunity, :user =>
|
53
|
+
@first = FactoryGirl.create(:opportunity, :user => current_user, :name => "The first one")
|
54
|
+
@second = FactoryGirl.create(:opportunity, :user => current_user, :name => "The second one")
|
55
55
|
|
56
56
|
get :index, :query => "second"
|
57
57
|
assigns[:opportunities].should == [ @second ]
|
@@ -61,7 +61,7 @@ describe OpportunitiesController do
|
|
61
61
|
|
62
62
|
describe "AJAX pagination" do
|
63
63
|
it "should pick up page number from params" do
|
64
|
-
@opportunities = [ FactoryGirl.create(:opportunity, :user =>
|
64
|
+
@opportunities = [ FactoryGirl.create(:opportunity, :user => current_user) ]
|
65
65
|
xhr :get, :index, :page => 42
|
66
66
|
|
67
67
|
assigns[:current_page].to_i.should == 42
|
@@ -72,13 +72,24 @@ describe OpportunitiesController do
|
|
72
72
|
|
73
73
|
it "should pick up saved page number from session" do
|
74
74
|
session[:opportunities_current_page] = 42
|
75
|
-
@opportunities = [ FactoryGirl.create(:opportunity, :user =>
|
75
|
+
@opportunities = [ FactoryGirl.create(:opportunity, :user => current_user) ]
|
76
76
|
xhr :get, :index
|
77
77
|
|
78
78
|
assigns[:current_page].should == 42
|
79
79
|
assigns[:opportunities].should == []
|
80
80
|
response.should render_template("opportunities/index")
|
81
81
|
end
|
82
|
+
|
83
|
+
it "should reset current_page when query is altered" do
|
84
|
+
session[:opportunities_current_page] = 42
|
85
|
+
session[:opportunities_current_query] = "bill"
|
86
|
+
@opportunities = [ FactoryGirl.create(:opportunity, :user => current_user) ]
|
87
|
+
xhr :get, :index
|
88
|
+
|
89
|
+
assigns[:current_page].should == 1
|
90
|
+
assigns[:opportunities].should == @opportunities
|
91
|
+
response.should render_template("opportunities/index")
|
92
|
+
end
|
82
93
|
end
|
83
94
|
|
84
95
|
describe "with mime type of JSON" do
|
@@ -167,7 +178,7 @@ describe OpportunitiesController do
|
|
167
178
|
|
168
179
|
describe "opportunity got deleted or otherwise unavailable" do
|
169
180
|
it "should redirect to opportunity index if the opportunity got deleted" do
|
170
|
-
@opportunity = FactoryGirl.create(:opportunity, :user =>
|
181
|
+
@opportunity = FactoryGirl.create(:opportunity, :user => current_user)
|
171
182
|
@opportunity.destroy
|
172
183
|
|
173
184
|
get :show, :id => @opportunity.id
|
@@ -184,7 +195,7 @@ describe OpportunitiesController do
|
|
184
195
|
end
|
185
196
|
|
186
197
|
it "should return 404 (Not Found) JSON error" do
|
187
|
-
@opportunity = FactoryGirl.create(:opportunity, :user =>
|
198
|
+
@opportunity = FactoryGirl.create(:opportunity, :user => current_user)
|
188
199
|
@opportunity.destroy
|
189
200
|
request.env["HTTP_ACCEPT"] = "application/json"
|
190
201
|
|
@@ -193,7 +204,7 @@ describe OpportunitiesController do
|
|
193
204
|
end
|
194
205
|
|
195
206
|
it "should return 404 (Not Found) XML error" do
|
196
|
-
@opportunity = FactoryGirl.create(:opportunity, :user =>
|
207
|
+
@opportunity = FactoryGirl.create(:opportunity, :user => current_user)
|
197
208
|
@opportunity.destroy
|
198
209
|
request.env["HTTP_ACCEPT"] = "application/xml"
|
199
210
|
|
@@ -209,15 +220,13 @@ describe OpportunitiesController do
|
|
209
220
|
describe "responding to GET new" do
|
210
221
|
|
211
222
|
it "should expose a new opportunity as @opportunity and render [new] template" do
|
212
|
-
@opportunity = Opportunity.new(:user =>
|
213
|
-
@account = Account.new(:user =>
|
214
|
-
@
|
215
|
-
@accounts = [ FactoryGirl.create(:account, :user => @current_user) ]
|
223
|
+
@opportunity = Opportunity.new(:user => current_user, :access => Setting.default_access, :stage => "prospecting")
|
224
|
+
@account = Account.new(:user => current_user, :access => Setting.default_access)
|
225
|
+
@accounts = [ FactoryGirl.create(:account, :user => current_user) ]
|
216
226
|
|
217
227
|
xhr :get, :new
|
218
228
|
assigns[:opportunity].attributes.should == @opportunity.attributes
|
219
229
|
assigns[:account].attributes.should == @account.attributes
|
220
|
-
assigns[:users].should == @users
|
221
230
|
assigns[:accounts].should == @accounts
|
222
231
|
response.should render_template("opportunities/new")
|
223
232
|
end
|
@@ -256,10 +265,9 @@ describe OpportunitiesController do
|
|
256
265
|
it "should expose the requested opportunity as @opportunity and render [edit] template" do
|
257
266
|
# Note: campaign => nil makes sure campaign factory is not invoked which has a side
|
258
267
|
# effect of creating an extra (campaign) user.
|
259
|
-
@account = FactoryGirl.create(:account, :user =>
|
260
|
-
@opportunity = FactoryGirl.create(:opportunity, :id => 42, :user =>
|
268
|
+
@account = FactoryGirl.create(:account, :user => current_user)
|
269
|
+
@opportunity = FactoryGirl.create(:opportunity, :id => 42, :user => current_user, :campaign => nil,
|
261
270
|
:account => @account)
|
262
|
-
@users = [ FactoryGirl.create(:user) ]
|
263
271
|
@stage = Setting.unroll(:opportunity_stage)
|
264
272
|
@accounts = [ @account ]
|
265
273
|
|
@@ -268,7 +276,6 @@ describe OpportunitiesController do
|
|
268
276
|
assigns[:opportunity].should == @opportunity
|
269
277
|
assigns[:account].attributes.should == @opportunity.account.attributes
|
270
278
|
assigns[:accounts].should == @accounts
|
271
|
-
assigns[:users].should == @users
|
272
279
|
assigns[:stage].should == @stage
|
273
280
|
assigns[:previous].should == nil
|
274
281
|
response.should render_template("opportunities/edit")
|
@@ -284,7 +291,7 @@ describe OpportunitiesController do
|
|
284
291
|
|
285
292
|
describe "opportunity got deleted or is otherwise unavailable" do
|
286
293
|
it "should reload current page with the flash message if the opportunity got deleted" do
|
287
|
-
@opportunity = FactoryGirl.create(:opportunity, :user =>
|
294
|
+
@opportunity = FactoryGirl.create(:opportunity, :user => current_user)
|
288
295
|
@opportunity.destroy
|
289
296
|
|
290
297
|
xhr :get, :edit, :id => @opportunity.id
|
@@ -303,7 +310,7 @@ describe OpportunitiesController do
|
|
303
310
|
|
304
311
|
describe "(previous opportunity got deleted or is otherwise unavailable)" do
|
305
312
|
before do
|
306
|
-
@opportunity = FactoryGirl.create(:opportunity, :user =>
|
313
|
+
@opportunity = FactoryGirl.create(:opportunity, :user => current_user)
|
307
314
|
@previous = FactoryGirl.create(:opportunity, :user => FactoryGirl.create(:user))
|
308
315
|
end
|
309
316
|
|
@@ -335,13 +342,13 @@ describe OpportunitiesController do
|
|
335
342
|
describe "with valid params" do
|
336
343
|
|
337
344
|
before do
|
338
|
-
@opportunity = FactoryGirl.build(:opportunity, :user =>
|
345
|
+
@opportunity = FactoryGirl.build(:opportunity, :user => current_user)
|
339
346
|
Opportunity.stub!(:new).and_return(@opportunity)
|
340
347
|
@stage = Setting.unroll(:opportunity_stage)
|
341
348
|
end
|
342
349
|
|
343
350
|
it "should expose a newly created opportunity as @opportunity and render [create] template" do
|
344
|
-
xhr :post, :create, :opportunity => { :name => "Hello" }, :account => { :name => "Hello again" }
|
351
|
+
xhr :post, :create, :opportunity => { :name => "Hello" }, :account => { :name => "Hello again" }
|
345
352
|
assigns(:opportunity).should == @opportunity
|
346
353
|
assigns(:stage).should == @stage
|
347
354
|
assigns(:opportunity_stage_total).should be_nil
|
@@ -350,29 +357,29 @@ describe OpportunitiesController do
|
|
350
357
|
|
351
358
|
it "should get sidebar data if called from opportunities index" do
|
352
359
|
request.env["HTTP_REFERER"] = "http://localhost/opportunities"
|
353
|
-
xhr :post, :create, :opportunity => { :name => "Hello" }, :account => { :name => "Hello again" }
|
360
|
+
xhr :post, :create, :opportunity => { :name => "Hello" }, :account => { :name => "Hello again" }
|
354
361
|
assigns(:opportunity_stage_total).should be_an_instance_of(HashWithIndifferentAccess)
|
355
362
|
end
|
356
363
|
|
357
364
|
it "should find related account if called from account landing page" do
|
358
|
-
@account = FactoryGirl.create(:account, :user =>
|
365
|
+
@account = FactoryGirl.create(:account, :user => current_user)
|
359
366
|
request.env["HTTP_REFERER"] = "http://localhost/accounts/#{@account.id}"
|
360
367
|
|
361
|
-
xhr :post, :create, :opportunity => { :name => "Hello" }, :account => { :id => @account.id }
|
368
|
+
xhr :post, :create, :opportunity => { :name => "Hello" }, :account => { :id => @account.id }
|
362
369
|
assigns(:account).should == @account
|
363
370
|
end
|
364
371
|
|
365
372
|
it "should find related campaign if called from campaign landing page" do
|
366
|
-
@campaign = FactoryGirl.create(:campaign, :user =>
|
373
|
+
@campaign = FactoryGirl.create(:campaign, :user => current_user)
|
367
374
|
request.env["HTTP_REFERER"] = "http://localhost/campaigns/#{@campaign.id}"
|
368
375
|
|
369
|
-
xhr :post, :create, :opportunity => { :name => "Hello" }, :campaign => @campaign.id, :account => { :name => "Hello again" }
|
376
|
+
xhr :post, :create, :opportunity => { :name => "Hello" }, :campaign => @campaign.id, :account => { :name => "Hello again" }
|
370
377
|
assigns(:campaign).should == @campaign
|
371
378
|
end
|
372
379
|
|
373
380
|
it "should reload opportunities to update pagination if called from opportunities index" do
|
374
381
|
request.env["HTTP_REFERER"] = "http://localhost/opportunities"
|
375
|
-
xhr :post, :create, :opportunity => { :name => "Hello" }, :account => { :name => "Hello again" }
|
382
|
+
xhr :post, :create, :opportunity => { :name => "Hello" }, :account => { :name => "Hello again" }
|
376
383
|
assigns[:opportunities].should == [ @opportunity ]
|
377
384
|
end
|
378
385
|
|
@@ -380,7 +387,7 @@ describe OpportunitiesController do
|
|
380
387
|
@campaign = FactoryGirl.create(:campaign)
|
381
388
|
|
382
389
|
request.env["HTTP_REFERER"] = "http://localhost/campaigns/#{@campaign.id}"
|
383
|
-
xhr :post, :create, :opportunity => { :name => "Hello" }, :campaign => @campaign.id, :account => { :name => "Test Account" }
|
390
|
+
xhr :post, :create, :opportunity => { :name => "Hello" }, :campaign => @campaign.id, :account => { :name => "Test Account" }
|
384
391
|
assigns(:opportunity).should == @opportunity
|
385
392
|
assigns(:campaign).should == @campaign
|
386
393
|
@opportunity.campaign.should == @campaign
|
@@ -390,7 +397,7 @@ describe OpportunitiesController do
|
|
390
397
|
@contact = FactoryGirl.create(:contact, :id => 42)
|
391
398
|
|
392
399
|
request.env["HTTP_REFERER"] = "http://localhost/contacts/42"
|
393
|
-
xhr :post, :create, :opportunity => { :name => "Hello" }, :contact => 42, :account => { :name => "Hello again" }
|
400
|
+
xhr :post, :create, :opportunity => { :name => "Hello" }, :contact => 42, :account => { :name => "Hello again" }
|
394
401
|
assigns(:opportunity).should == @opportunity
|
395
402
|
@opportunity.contacts.should include(@contact)
|
396
403
|
@contact.opportunities.should include(@opportunity)
|
@@ -405,7 +412,7 @@ describe OpportunitiesController do
|
|
405
412
|
it "should associate opportunity with the existing account" do
|
406
413
|
@account = FactoryGirl.create(:account, :id => 42)
|
407
414
|
|
408
|
-
xhr :post, :create, :opportunity => { :name => "Hello world" }, :account => { :id => 42 }
|
415
|
+
xhr :post, :create, :opportunity => { :name => "Hello world" }, :account => { :id => 42 }
|
409
416
|
assigns(:opportunity).should == @opportunity
|
410
417
|
@opportunity.account.should == @account
|
411
418
|
@account.opportunities.should include(@opportunity)
|
@@ -413,7 +420,7 @@ describe OpportunitiesController do
|
|
413
420
|
|
414
421
|
it "should update related campaign revenue if won" do
|
415
422
|
@campaign = FactoryGirl.create(:campaign, :revenue => 0)
|
416
|
-
@opportunity = FactoryGirl.build(:opportunity, :user =>
|
423
|
+
@opportunity = FactoryGirl.build(:opportunity, :user => current_user, :stage => "won", :amount => 1100, :discount => 100)
|
417
424
|
Opportunity.stub!(:new).and_return(@opportunity)
|
418
425
|
|
419
426
|
xhr :post, :create, :opportunity => { :name => "Hello world" }, :campaign => @campaign.id, :account => { :name => "Test Account" }
|
@@ -421,40 +428,44 @@ describe OpportunitiesController do
|
|
421
428
|
@opportunity.campaign.should == @campaign.reload
|
422
429
|
@campaign.revenue.to_i.should == 1000 # 1000 - 100 discount.
|
423
430
|
end
|
431
|
+
|
432
|
+
it "should add a new comment to the newly created opportunity when specified" do
|
433
|
+
@opportunity = FactoryGirl.build(:opportunity, :user => current_user)
|
434
|
+
Opportunity.stub!(:new).and_return(@opportunity)
|
435
|
+
|
436
|
+
xhr :post, :create, :opportunity => { :name => "Opportunity Knocks" }, :account => { :name => "My Account" }, :comment_body => "Awesome comment is awesome"
|
437
|
+
@opportunity.reload.comments.map(&:comment).should include("Awesome comment is awesome")
|
438
|
+
end
|
424
439
|
end
|
425
440
|
|
426
441
|
describe "with invalid params" do
|
427
442
|
|
428
443
|
it "should expose a newly created but unsaved opportunity as @opportunity with blank @account and render [create] template" do
|
429
|
-
@account = Account.new(:user =>
|
430
|
-
@opportunity = FactoryGirl.build(:opportunity, :name => nil, :campaign => nil, :user =>
|
444
|
+
@account = Account.new(:user => current_user)
|
445
|
+
@opportunity = FactoryGirl.build(:opportunity, :name => nil, :campaign => nil, :user => current_user,
|
431
446
|
:account => @account)
|
432
447
|
Opportunity.stub!(:new).and_return(@opportunity)
|
433
448
|
@stage = Setting.unroll(:opportunity_stage)
|
434
|
-
@
|
435
|
-
@accounts = [ FactoryGirl.create(:account, :user => @current_user) ]
|
449
|
+
@accounts = [ FactoryGirl.create(:account, :user => current_user) ]
|
436
450
|
|
437
451
|
# Expect to redraw [create] form with blank account.
|
438
|
-
xhr :post, :create, :opportunity => {}, :account => { :user_id =>
|
452
|
+
xhr :post, :create, :opportunity => {}, :account => { :user_id => current_user.id }
|
439
453
|
assigns(:opportunity).should == @opportunity
|
440
|
-
assigns(:users).should == @users
|
441
454
|
assigns(:account).attributes.should == @account.attributes
|
442
455
|
assigns(:accounts).should == @accounts
|
443
456
|
response.should render_template("opportunities/create")
|
444
457
|
end
|
445
458
|
|
446
459
|
it "should expose a newly created but unsaved opportunity as @opportunity with existing @account and render [create] template" do
|
447
|
-
@account = FactoryGirl.create(:account, :id => 42, :user =>
|
448
|
-
@opportunity = FactoryGirl.build(:opportunity, :name => nil, :campaign => nil, :user =>
|
460
|
+
@account = FactoryGirl.create(:account, :id => 42, :user => current_user)
|
461
|
+
@opportunity = FactoryGirl.build(:opportunity, :name => nil, :campaign => nil, :user => current_user,
|
449
462
|
:account => @account)
|
450
463
|
Opportunity.stub!(:new).and_return(@opportunity)
|
451
464
|
@stage = Setting.unroll(:opportunity_stage)
|
452
|
-
@users = [ FactoryGirl.create(:user) ]
|
453
465
|
|
454
466
|
# Expect to redraw [create] form with selected account.
|
455
|
-
xhr :post, :create, :opportunity => {}, :account => { :id => 42, :user_id =>
|
467
|
+
xhr :post, :create, :opportunity => {}, :account => { :id => 42, :user_id => current_user.id }
|
456
468
|
assigns(:opportunity).should == @opportunity
|
457
|
-
assigns(:users).should == @users
|
458
469
|
assigns(:account).should == @account
|
459
470
|
assigns(:accounts).should == [ @account ]
|
460
471
|
response.should render_template("opportunities/create")
|
@@ -464,7 +475,7 @@ describe OpportunitiesController do
|
|
464
475
|
@campaign = FactoryGirl.create(:campaign, :id => 42)
|
465
476
|
|
466
477
|
request.env["HTTP_REFERER"] = "http://localhost/campaigns/42"
|
467
|
-
xhr :post, :create, :opportunity => { :name => nil }, :campaign => 42, :account => { :name => "Test Account" }
|
478
|
+
xhr :post, :create, :opportunity => { :name => nil }, :campaign => 42, :account => { :name => "Test Account" }
|
468
479
|
assigns(:campaign).should == @campaign
|
469
480
|
response.should render_template("opportunities/create")
|
470
481
|
end
|
@@ -473,7 +484,7 @@ describe OpportunitiesController do
|
|
473
484
|
@contact = FactoryGirl.create(:contact, :id => 42)
|
474
485
|
|
475
486
|
request.env["HTTP_REFERER"] = "http://localhost/contacts/42"
|
476
|
-
xhr :post, :create, :opportunity => { :name => nil }, :contact => 42, :account => { :name => "Test Account" }
|
487
|
+
xhr :post, :create, :opportunity => { :name => nil }, :contact => 42, :account => { :name => "Test Account" }
|
477
488
|
assigns(:contact).should == @contact
|
478
489
|
response.should render_template("opportunities/create")
|
479
490
|
end
|
@@ -493,7 +504,7 @@ describe OpportunitiesController do
|
|
493
504
|
@opportunity = FactoryGirl.create(:opportunity, :id => 42)
|
494
505
|
@stage = Setting.unroll(:opportunity_stage)
|
495
506
|
|
496
|
-
xhr :put, :update, :id => 42, :opportunity => { :name => "Hello world" }, :account => { :name => "Test Account" }
|
507
|
+
xhr :put, :update, :id => 42, :opportunity => { :name => "Hello world" }, :account => { :name => "Test Account" }
|
497
508
|
@opportunity.reload.name.should == "Hello world"
|
498
509
|
assigns(:opportunity).should == @opportunity
|
499
510
|
assigns(:stage).should == @stage
|
@@ -510,7 +521,7 @@ describe OpportunitiesController do
|
|
510
521
|
end
|
511
522
|
|
512
523
|
it "should find related account if called from account landing page" do
|
513
|
-
@account = FactoryGirl.create(:account, :user =>
|
524
|
+
@account = FactoryGirl.create(:account, :user => current_user)
|
514
525
|
@opportunity = FactoryGirl.create(:opportunity, :id => 42, :account => @account)
|
515
526
|
request.env["HTTP_REFERER"] = "http://localhost/accounts/#{@account.id}"
|
516
527
|
|
@@ -519,7 +530,7 @@ describe OpportunitiesController do
|
|
519
530
|
end
|
520
531
|
|
521
532
|
it "should remove related account if blank :account param is given" do
|
522
|
-
@account = FactoryGirl.create(:account, :user =>
|
533
|
+
@account = FactoryGirl.create(:account, :user => current_user)
|
523
534
|
@opportunity = FactoryGirl.create(:opportunity, :id => 42, :account => @account)
|
524
535
|
request.env["HTTP_REFERER"] = "http://localhost/accounts/#{@account.id}"
|
525
536
|
|
@@ -528,8 +539,8 @@ describe OpportunitiesController do
|
|
528
539
|
end
|
529
540
|
|
530
541
|
it "should find related campaign if called from campaign landing page" do
|
531
|
-
@campaign = FactoryGirl.create(:campaign, :user =>
|
532
|
-
@opportunity = FactoryGirl.create(:opportunity, :id => 42, :user =>
|
542
|
+
@campaign = FactoryGirl.create(:campaign, :user => current_user)
|
543
|
+
@opportunity = FactoryGirl.create(:opportunity, :id => 42, :user => current_user)
|
533
544
|
@campaign.opportunities << @opportunity
|
534
545
|
request.env["HTTP_REFERER"] = "http://localhost/campaigns/#{@campaign.id}"
|
535
546
|
|
@@ -553,20 +564,16 @@ describe OpportunitiesController do
|
|
553
564
|
@opportunity = FactoryGirl.create(:opportunity, :id => 42, :account => @old_account)
|
554
565
|
|
555
566
|
xhr :put, :update, :id => 42, :opportunity => { :name => "Hello" }, :account => { :id => 999 }
|
556
|
-
@opportunity.reload
|
557
567
|
assigns[:opportunity].should == @opportunity
|
558
|
-
|
568
|
+
assigns[:opportunity].account.should == @new_account
|
559
569
|
end
|
560
570
|
|
561
571
|
it "should update opportunity permissions when sharing with specific users" do
|
562
572
|
@opportunity = FactoryGirl.create(:opportunity, :id => 42, :access => "Public")
|
563
|
-
he = FactoryGirl.create(:user, :id => 7)
|
564
|
-
she = FactoryGirl.create(:user, :id => 8)
|
565
573
|
|
566
|
-
xhr :put, :update, :id => 42, :opportunity => { :name => "Hello", :access => "Shared"
|
567
|
-
|
568
|
-
|
569
|
-
assigns[:opportunity].should == @opportunity
|
574
|
+
xhr :put, :update, :id => 42, :opportunity => { :name => "Hello", :access => "Shared", :user_ids => [7, 8] }, :account => { :name => "Test Account" }
|
575
|
+
assigns[:opportunity].access.should == "Shared"
|
576
|
+
assigns[:opportunity].user_ids.sort.should == [ 7, 8 ]
|
570
577
|
end
|
571
578
|
|
572
579
|
it "should reload opportunity campaign if called from campaign landing page" do
|
@@ -581,7 +588,7 @@ describe OpportunitiesController do
|
|
581
588
|
describe "updating campaign revenue (same campaign)" do
|
582
589
|
it "should add to actual revenue when opportunity is closed/won" do
|
583
590
|
@campaign = FactoryGirl.create(:campaign, :revenue => 1000)
|
584
|
-
@opportunity = FactoryGirl.create(:opportunity, :campaign => @campaign, :stage =>
|
591
|
+
@opportunity = FactoryGirl.create(:opportunity, :campaign => @campaign, :stage => 'prospecting', :amount => 1100, :discount => 100)
|
585
592
|
|
586
593
|
xhr :put, :update, :id => @opportunity, :opportunity => { :stage => "won" }, :account => { :name => "Test Account" }
|
587
594
|
@campaign.reload.revenue.to_i.should == 2000 # 1000 -> 2000
|
@@ -592,13 +599,13 @@ describe OpportunitiesController do
|
|
592
599
|
@opportunity = FactoryGirl.create(:opportunity, :campaign => @campaign, :stage => "won", :amount => 1100, :discount => 100)
|
593
600
|
# @campaign.revenue is now $2000 since we created winning opportunity.
|
594
601
|
|
595
|
-
xhr :put, :update, :id => @opportunity, :opportunity => { :stage =>
|
602
|
+
xhr :put, :update, :id => @opportunity, :opportunity => { :stage => 'prospecting' }, :account => { :name => "Test Account" }
|
596
603
|
@campaign.reload.revenue.to_i.should == 1000 # Should be adjusted back to $1000.
|
597
604
|
end
|
598
605
|
|
599
606
|
it "should not update actual revenue when opportunity is not closed/won" do
|
600
607
|
@campaign = FactoryGirl.create(:campaign, :revenue => 1000)
|
601
|
-
@opportunity = FactoryGirl.create(:opportunity, :campaign => @campaign, :stage =>
|
608
|
+
@opportunity = FactoryGirl.create(:opportunity, :campaign => @campaign, :stage => 'prospecting', :amount => 1100, :discount => 100)
|
602
609
|
|
603
610
|
xhr :put, :update, :id => @opportunity, :opportunity => { :stage => "lost" }, :account => { :name => "Test Account" }
|
604
611
|
@campaign.reload.revenue.to_i.should == 1000 # Stays the same.
|
@@ -608,7 +615,7 @@ describe OpportunitiesController do
|
|
608
615
|
describe "updating campaign revenue (diferent campaigns)" do
|
609
616
|
it "should update newly assigned campaign when opportunity is closed/won" do
|
610
617
|
@campaigns = { :old => FactoryGirl.create(:campaign, :revenue => 1000), :new => FactoryGirl.create(:campaign, :revenue => 1000) }
|
611
|
-
@opportunity = FactoryGirl.create(:opportunity, :campaign => @campaigns[:old], :stage =>
|
618
|
+
@opportunity = FactoryGirl.create(:opportunity, :campaign => @campaigns[:old], :stage => 'prospecting', :amount => 1100, :discount => 100)
|
612
619
|
|
613
620
|
xhr :put, :update, :id => @opportunity, :opportunity => { :stage => "won", :campaign_id => @campaigns[:new].id }, :account => { :name => "Test Account" }
|
614
621
|
|
@@ -621,14 +628,14 @@ describe OpportunitiesController do
|
|
621
628
|
@opportunity = FactoryGirl.create(:opportunity, :campaign => @campaigns[:old], :stage => "won", :amount => 1100, :discount => 100)
|
622
629
|
# @campaign.revenue is now $2000 since we created winning opportunity.
|
623
630
|
|
624
|
-
xhr :put, :update, :id => @opportunity, :opportunity => { :stage =>
|
631
|
+
xhr :put, :update, :id => @opportunity, :opportunity => { :stage => 'prospecting', :campaign_id => @campaigns[:new].id }, :account => { :name => "Test Account" }
|
625
632
|
@campaigns[:old].reload.revenue.to_i.should == 1000 # Should be adjusted back to $1000.
|
626
633
|
@campaigns[:new].reload.revenue.to_i.should == 1000 # Stays the same.
|
627
634
|
end
|
628
635
|
|
629
636
|
it "should not update campaigns when opportunity is not closed/won" do
|
630
637
|
@campaigns = { :old => FactoryGirl.create(:campaign, :revenue => 1000), :new => FactoryGirl.create(:campaign, :revenue => 1000) }
|
631
|
-
@opportunity = FactoryGirl.create(:opportunity, :campaign => @campaigns[:old], :stage =>
|
638
|
+
@opportunity = FactoryGirl.create(:opportunity, :campaign => @campaigns[:old], :stage => 'prospecting', :amount => 1100, :discount => 100)
|
632
639
|
|
633
640
|
xhr :put, :update, :id => @opportunity, :opportunity => { :stage => "lost", :campaign_id => @campaigns[:new].id }, :account => { :name => "Test Account" }
|
634
641
|
@campaigns[:old].reload.revenue.to_i.should == 1000 # Stays the same.
|
@@ -638,7 +645,7 @@ describe OpportunitiesController do
|
|
638
645
|
|
639
646
|
describe "opportunity got deleted or otherwise unavailable" do
|
640
647
|
it "should reload current page with the flash message if the opportunity got deleted" do
|
641
|
-
@opportunity = FactoryGirl.create(:opportunity, :user =>
|
648
|
+
@opportunity = FactoryGirl.create(:opportunity, :user => current_user)
|
642
649
|
@opportunity.destroy
|
643
650
|
|
644
651
|
xhr :put, :update, :id => @opportunity.id
|
@@ -684,7 +691,7 @@ describe OpportunitiesController do
|
|
684
691
|
#----------------------------------------------------------------------------
|
685
692
|
describe "responding to DELETE destroy" do
|
686
693
|
before do
|
687
|
-
@opportunity = FactoryGirl.create(:opportunity, :user =>
|
694
|
+
@opportunity = FactoryGirl.create(:opportunity, :user => current_user)
|
688
695
|
end
|
689
696
|
|
690
697
|
describe "AJAX request" do
|
@@ -734,7 +741,7 @@ describe OpportunitiesController do
|
|
734
741
|
|
735
742
|
it "should reload campaiign to be able to refresh its summary" do
|
736
743
|
@account = FactoryGirl.create(:account)
|
737
|
-
@opportunity = FactoryGirl.create(:opportunity, :user =>
|
744
|
+
@opportunity = FactoryGirl.create(:opportunity, :user => current_user, :account => @account)
|
738
745
|
request.env["HTTP_REFERER"] = "http://localhost/accounts/#{@account.id}"
|
739
746
|
|
740
747
|
xhr :delete, :destroy, :id => @opportunity.id
|
@@ -744,7 +751,7 @@ describe OpportunitiesController do
|
|
744
751
|
|
745
752
|
it "should reload campaiign to be able to refresh its summary" do
|
746
753
|
@campaign = FactoryGirl.create(:campaign)
|
747
|
-
@opportunity = FactoryGirl.create(:opportunity, :user =>
|
754
|
+
@opportunity = FactoryGirl.create(:opportunity, :user => current_user, :campaign => @campaign)
|
748
755
|
request.env["HTTP_REFERER"] = "http://localhost/campaigns/#{@campaign.id}"
|
749
756
|
|
750
757
|
xhr :delete, :destroy, :id => @opportunity.id
|
@@ -755,7 +762,7 @@ describe OpportunitiesController do
|
|
755
762
|
|
756
763
|
describe "opportunity got deleted or otherwise unavailable" do
|
757
764
|
it "should reload current page is the opportunity got deleted" do
|
758
|
-
@opportunity = FactoryGirl.create(:opportunity, :user =>
|
765
|
+
@opportunity = FactoryGirl.create(:opportunity, :user => current_user)
|
759
766
|
@opportunity.destroy
|
760
767
|
|
761
768
|
xhr :delete, :destroy, :id => @opportunity.id
|
@@ -781,7 +788,7 @@ describe OpportunitiesController do
|
|
781
788
|
end
|
782
789
|
|
783
790
|
it "should redirect to opportunity index with the flash message is the opportunity got deleted" do
|
784
|
-
@opportunity = FactoryGirl.create(:opportunity, :user =>
|
791
|
+
@opportunity = FactoryGirl.create(:opportunity, :user => current_user)
|
785
792
|
@opportunity.destroy
|
786
793
|
|
787
794
|
delete :destroy, :id => @opportunity.id
|
@@ -846,53 +853,31 @@ describe OpportunitiesController do
|
|
846
853
|
#----------------------------------------------------------------------------
|
847
854
|
describe "responding to POST auto_complete" do
|
848
855
|
before do
|
849
|
-
@auto_complete_matches = [ FactoryGirl.create(:opportunity, :name => "Hello World", :user =>
|
856
|
+
@auto_complete_matches = [ FactoryGirl.create(:opportunity, :name => "Hello World", :user => current_user) ]
|
850
857
|
end
|
851
858
|
|
852
859
|
it_should_behave_like("auto complete")
|
853
860
|
end
|
854
861
|
|
855
|
-
# GET /opportunities/options AJAX
|
856
|
-
#----------------------------------------------------------------------------
|
857
|
-
describe "responding to GET options" do
|
858
|
-
it "should set current user preferences when showing options" do
|
859
|
-
@per_page = FactoryGirl.create(:preference, :user => @current_user, :name => "opportunities_per_page", :value => Base64.encode64(Marshal.dump(42)))
|
860
|
-
@outline = FactoryGirl.create(:preference, :user => @current_user, :name => "opportunities_outline", :value => Base64.encode64(Marshal.dump("option_long")))
|
861
|
-
@sort_by = FactoryGirl.create(:preference, :user => @current_user, :name => "opportunities_sort_by", :value => Base64.encode64(Marshal.dump("opportunities.name ASC")))
|
862
|
-
|
863
|
-
xhr :get, :options
|
864
|
-
assigns[:per_page].should == 42
|
865
|
-
assigns[:outline].should == "option_long"
|
866
|
-
assigns[:sort_by].should == "opportunities.name ASC"
|
867
|
-
end
|
868
|
-
|
869
|
-
it "should not assign instance variables when hiding options" do
|
870
|
-
xhr :get, :options, :cancel => "true"
|
871
|
-
assigns[:per_page].should == nil
|
872
|
-
assigns[:outline].should == nil
|
873
|
-
assigns[:sort_by].should == nil
|
874
|
-
end
|
875
|
-
end
|
876
|
-
|
877
862
|
# POST /opportunities/redraw AJAX
|
878
863
|
#----------------------------------------------------------------------------
|
879
864
|
describe "responding to POST redraw" do
|
880
865
|
it "should save user selected opportunity preference" do
|
881
|
-
xhr :post, :redraw, :per_page => 42, :
|
882
|
-
|
883
|
-
|
884
|
-
|
866
|
+
xhr :post, :redraw, :per_page => 42, :view => "brief", :sort_by => "name"
|
867
|
+
current_user.preference[:opportunities_per_page].should == "42"
|
868
|
+
current_user.preference[:opportunities_index_view].should == "brief"
|
869
|
+
current_user.preference[:opportunities_sort_by].should == "opportunities.name ASC"
|
885
870
|
end
|
886
871
|
|
887
872
|
it "should reset current page to 1" do
|
888
|
-
xhr :post, :redraw, :per_page => 42, :
|
873
|
+
xhr :post, :redraw, :per_page => 42, :view => "brief", :sort_by => "name"
|
889
874
|
session[:opportunities_current_page].should == 1
|
890
875
|
end
|
891
876
|
|
892
877
|
it "should select @opportunities and render [index] template" do
|
893
878
|
@opportunities = [
|
894
|
-
FactoryGirl.create(:opportunity, :name => "A", :user =>
|
895
|
-
FactoryGirl.create(:opportunity, :name => "B", :user =>
|
879
|
+
FactoryGirl.create(:opportunity, :name => "A", :user => current_user),
|
880
|
+
FactoryGirl.create(:opportunity, :name => "B", :user => current_user)
|
896
881
|
]
|
897
882
|
|
898
883
|
xhr :post, :redraw, :per_page => 1, :sort_by => "name"
|
@@ -907,7 +892,7 @@ describe OpportunitiesController do
|
|
907
892
|
|
908
893
|
it "should expose filtered opportunities as @opportunity and render [filter] template" do
|
909
894
|
session[:opportunities_filter] = "negotiation,analysis"
|
910
|
-
@opportunities = [ FactoryGirl.create(:opportunity, :stage => "prospecting", :user =>
|
895
|
+
@opportunities = [ FactoryGirl.create(:opportunity, :stage => "prospecting", :user => current_user) ]
|
911
896
|
@stage = Setting.unroll(:opportunity_stage)
|
912
897
|
|
913
898
|
xhr :get, :filter, :stage => "prospecting"
|