fat_free_crm 0.11.3 → 0.11.4
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of fat_free_crm might be problematic. Click here for more details.
- 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
@@ -156,7 +156,7 @@ describe CommentsController do
|
|
156
156
|
COMMENTABLE.each do |asset|
|
157
157
|
it "should expose the requested comment as @commment and render [edit] template" do
|
158
158
|
@asset = FactoryGirl.create(asset)
|
159
|
-
@comment = FactoryGirl.create(:comment, :id => 42, :commentable => @asset, :user =>
|
159
|
+
@comment = FactoryGirl.create(:comment, :id => 42, :commentable => @asset, :user => current_user)
|
160
160
|
Comment.stub!(:new).and_return(@comment)
|
161
161
|
|
162
162
|
xhr :get, :edit, :id => 42
|
@@ -176,10 +176,10 @@ describe CommentsController do
|
|
176
176
|
COMMENTABLE.each do |asset|
|
177
177
|
it "should expose a newly created comment as @comment for the #{asset}" do
|
178
178
|
@asset = FactoryGirl.create(asset)
|
179
|
-
@comment = FactoryGirl.build(:comment, :commentable => @asset, :user =>
|
179
|
+
@comment = FactoryGirl.build(:comment, :commentable => @asset, :user => current_user)
|
180
180
|
Comment.stub!(:new).and_return(@comment)
|
181
181
|
|
182
|
-
xhr :post, :create, :comment => { :commentable_type => asset.to_s.classify, :commentable_id => @asset.id, :user_id =>
|
182
|
+
xhr :post, :create, :comment => { :commentable_type => asset.to_s.classify, :commentable_id => @asset.id, :user_id => current_user.id, :comment => "Hello" }
|
183
183
|
assigns[:comment].should == @comment
|
184
184
|
response.should render_template("comments/create")
|
185
185
|
end
|
@@ -190,7 +190,7 @@ describe CommentsController do
|
|
190
190
|
COMMENTABLE.each do |asset|
|
191
191
|
it "should expose a newly created but unsaved comment as @comment for #{asset}" do
|
192
192
|
@asset = FactoryGirl.create(asset)
|
193
|
-
@comment = FactoryGirl.build(:comment, :commentable => @asset, :user =>
|
193
|
+
@comment = FactoryGirl.build(:comment, :commentable => @asset, :user => current_user)
|
194
194
|
Comment.stub!(:new).and_return(@comment)
|
195
195
|
|
196
196
|
xhr :post, :create, :comment => {}
|
@@ -258,7 +258,7 @@ describe CommentsController do
|
|
258
258
|
COMMENTABLE.each do |asset|
|
259
259
|
it "should destroy the requested comment and render [destroy] template" do
|
260
260
|
@asset = FactoryGirl.create(asset)
|
261
|
-
@comment = FactoryGirl.create(:comment, :commentable => @asset, :user =>
|
261
|
+
@comment = FactoryGirl.create(:comment, :commentable => @asset, :user => current_user)
|
262
262
|
Comment.stub!(:new).and_return(@comment)
|
263
263
|
|
264
264
|
xhr :delete, :destroy, :id => @comment.id
|
@@ -271,4 +271,3 @@ describe CommentsController do
|
|
271
271
|
end
|
272
272
|
|
273
273
|
end
|
274
|
-
|
@@ -16,7 +16,7 @@ describe EmailsController, "handling GET /emails" do
|
|
16
16
|
MEDIATOR.each do |asset|
|
17
17
|
it "should destroy the requested email and render [destroy] template" do
|
18
18
|
@asset = FactoryGirl.create(asset)
|
19
|
-
@email = FactoryGirl.create(:email, :mediator => @asset, :user =>
|
19
|
+
@email = FactoryGirl.create(:email, :mediator => @asset, :user => current_user)
|
20
20
|
Email.stub!(:new).and_return(@email)
|
21
21
|
|
22
22
|
xhr :delete, :destroy, :id => @email.id
|
@@ -29,4 +29,3 @@ describe EmailsController, "handling GET /emails" do
|
|
29
29
|
end
|
30
30
|
|
31
31
|
end
|
32
|
-
|
@@ -19,14 +19,14 @@ describe AccountsController do
|
|
19
19
|
end
|
20
20
|
|
21
21
|
it "should expose all accounts as @accounts and render [index] template" do
|
22
|
-
@accounts = [ FactoryGirl.create(:account, :user =>
|
22
|
+
@accounts = [ FactoryGirl.create(:account, :user => current_user) ]
|
23
23
|
get :index
|
24
24
|
assigns[:accounts].should == @accounts
|
25
25
|
response.should render_template("accounts/index")
|
26
26
|
end
|
27
27
|
|
28
28
|
it "should collect the data for the accounts sidebar" do
|
29
|
-
@accounts = [ FactoryGirl.create(:account, :user =>
|
29
|
+
@accounts = [ FactoryGirl.create(:account, :user => current_user) ]
|
30
30
|
|
31
31
|
get :index
|
32
32
|
(assigns[:account_category_total].keys.map(&:to_sym) - (@category << :all << :other)).should == []
|
@@ -36,19 +36,19 @@ describe AccountsController do
|
|
36
36
|
categories = %w(customer vendor)
|
37
37
|
controller.session[:accounts_filter] = categories.join(',')
|
38
38
|
@accounts = [
|
39
|
-
FactoryGirl.create(:account, :user =>
|
40
|
-
FactoryGirl.create(:account, :user =>
|
39
|
+
FactoryGirl.create(:account, :user => current_user, :category => categories.first),
|
40
|
+
FactoryGirl.create(:account, :user => current_user, :category => categories.last)
|
41
41
|
]
|
42
42
|
# This one should be filtered out.
|
43
|
-
FactoryGirl.create(:account, :user =>
|
43
|
+
FactoryGirl.create(:account, :user => current_user, :category => "competitor")
|
44
44
|
|
45
45
|
get :index
|
46
46
|
assigns[:accounts].should == @accounts
|
47
47
|
end
|
48
48
|
|
49
49
|
it "should perform lookup using query string" do
|
50
|
-
@first = FactoryGirl.create(:account, :user =>
|
51
|
-
@second = FactoryGirl.create(:account, :user =>
|
50
|
+
@first = FactoryGirl.create(:account, :user => current_user, :name => "The first one")
|
51
|
+
@second = FactoryGirl.create(:account, :user => current_user, :name => "The second one")
|
52
52
|
|
53
53
|
get :index, :query => "second"
|
54
54
|
assigns[:accounts].should == [ @second ]
|
@@ -58,7 +58,7 @@ describe AccountsController do
|
|
58
58
|
|
59
59
|
describe "AJAX pagination" do
|
60
60
|
it "should pick up page number from params" do
|
61
|
-
@accounts = [ FactoryGirl.create(:account, :user =>
|
61
|
+
@accounts = [ FactoryGirl.create(:account, :user => current_user) ]
|
62
62
|
xhr :get, :index, :page => 42
|
63
63
|
|
64
64
|
assigns[:current_page].to_i.should == 42
|
@@ -69,13 +69,24 @@ describe AccountsController do
|
|
69
69
|
|
70
70
|
it "should pick up saved page number from session" do
|
71
71
|
session[:accounts_current_page] = 42
|
72
|
-
@accounts = [ FactoryGirl.create(:account, :user =>
|
72
|
+
@accounts = [ FactoryGirl.create(:account, :user => current_user) ]
|
73
73
|
xhr :get, :index
|
74
74
|
|
75
75
|
assigns[:current_page].should == 42
|
76
76
|
assigns[:accounts].should == []
|
77
77
|
response.should render_template("accounts/index")
|
78
78
|
end
|
79
|
+
|
80
|
+
it "should reset current_page when query is altered" do
|
81
|
+
session[:accounts_current_page] = 42
|
82
|
+
session[:accounts_current_query] = "bill"
|
83
|
+
@accounts = [ FactoryGirl.create(:account, :user => current_user) ]
|
84
|
+
xhr :get, :index
|
85
|
+
|
86
|
+
assigns[:current_page].should == 1
|
87
|
+
assigns[:accounts].should == @accounts
|
88
|
+
response.should render_template("accounts/index")
|
89
|
+
end
|
79
90
|
end
|
80
91
|
|
81
92
|
describe "with mime type of JSON" do
|
@@ -108,7 +119,7 @@ describe AccountsController do
|
|
108
119
|
|
109
120
|
describe "with mime type of HTML" do
|
110
121
|
before do
|
111
|
-
@account = FactoryGirl.create(:account, :user =>
|
122
|
+
@account = FactoryGirl.create(:account, :user => current_user)
|
112
123
|
@stage = Setting.unroll(:opportunity_stage)
|
113
124
|
@comment = Comment.new
|
114
125
|
end
|
@@ -129,7 +140,7 @@ describe AccountsController do
|
|
129
140
|
|
130
141
|
describe "with mime type of JSON" do
|
131
142
|
it "should render the requested account as json" do
|
132
|
-
@account = FactoryGirl.create(:account, :user =>
|
143
|
+
@account = FactoryGirl.create(:account, :user => current_user)
|
133
144
|
Account.should_receive(:find).and_return(@account)
|
134
145
|
@account.should_receive(:to_json).and_return("generated JSON")
|
135
146
|
|
@@ -141,7 +152,7 @@ describe AccountsController do
|
|
141
152
|
|
142
153
|
describe "with mime type of XML" do
|
143
154
|
it "should render the requested account as xml" do
|
144
|
-
@account = FactoryGirl.create(:account, :user =>
|
155
|
+
@account = FactoryGirl.create(:account, :user => current_user)
|
145
156
|
Account.should_receive(:find).and_return(@account)
|
146
157
|
@account.should_receive(:to_xml).and_return("generated XML")
|
147
158
|
|
@@ -153,7 +164,7 @@ describe AccountsController do
|
|
153
164
|
|
154
165
|
describe "account got deleted or otherwise unavailable" do
|
155
166
|
it "should redirect to account index if the account got deleted" do
|
156
|
-
@account = FactoryGirl.create(:account, :user =>
|
167
|
+
@account = FactoryGirl.create(:account, :user => current_user)
|
157
168
|
@account.destroy
|
158
169
|
|
159
170
|
get :show, :id => @account.id
|
@@ -170,7 +181,7 @@ describe AccountsController do
|
|
170
181
|
end
|
171
182
|
|
172
183
|
it "should return 404 (Not Found) JSON error" do
|
173
|
-
@account = FactoryGirl.create(:account, :user =>
|
184
|
+
@account = FactoryGirl.create(:account, :user => current_user)
|
174
185
|
@account.destroy
|
175
186
|
request.env["HTTP_ACCEPT"] = "application/json"
|
176
187
|
|
@@ -179,7 +190,7 @@ describe AccountsController do
|
|
179
190
|
end
|
180
191
|
|
181
192
|
it "should return 404 (Not Found) XML error" do
|
182
|
-
@account = FactoryGirl.create(:account, :user =>
|
193
|
+
@account = FactoryGirl.create(:account, :user => current_user)
|
183
194
|
@account.destroy
|
184
195
|
request.env["HTTP_ACCEPT"] = "application/xml"
|
185
196
|
|
@@ -196,12 +207,10 @@ describe AccountsController do
|
|
196
207
|
describe "responding to GET new" do
|
197
208
|
|
198
209
|
it "should expose a new account as @account and render [new] template" do
|
199
|
-
@account = Account.new(:user =>
|
200
|
-
|
201
|
-
|
210
|
+
@account = Account.new(:user => current_user,
|
211
|
+
:access => Setting.default_access)
|
202
212
|
xhr :get, :new
|
203
213
|
assigns[:account].attributes.should == @account.attributes
|
204
|
-
assigns[:users].should == @users
|
205
214
|
assigns[:contact].should == nil
|
206
215
|
response.should render_template("accounts/new")
|
207
216
|
end
|
@@ -220,12 +229,10 @@ describe AccountsController do
|
|
220
229
|
describe "responding to GET edit" do
|
221
230
|
|
222
231
|
it "should expose the requested account as @account and render [edit] template" do
|
223
|
-
@account = FactoryGirl.create(:account, :id => 42, :user =>
|
224
|
-
@users = [ FactoryGirl.create(:user) ]
|
232
|
+
@account = FactoryGirl.create(:account, :id => 42, :user => current_user)
|
225
233
|
|
226
234
|
xhr :get, :edit, :id => 42
|
227
235
|
assigns[:account].should == @account
|
228
|
-
assigns[:users].should == @users
|
229
236
|
assigns[:previous].should == nil
|
230
237
|
response.should render_template("accounts/edit")
|
231
238
|
end
|
@@ -240,7 +247,7 @@ describe AccountsController do
|
|
240
247
|
|
241
248
|
describe "(account got deleted or is otherwise unavailable)" do
|
242
249
|
it "should reload current page with the flash message if the account got deleted" do
|
243
|
-
@account = FactoryGirl.create(:account, :user =>
|
250
|
+
@account = FactoryGirl.create(:account, :user => current_user)
|
244
251
|
@account.destroy
|
245
252
|
|
246
253
|
xhr :get, :edit, :id => @account.id
|
@@ -259,7 +266,7 @@ describe AccountsController do
|
|
259
266
|
|
260
267
|
describe "(previous account got deleted or is otherwise unavailable)" do
|
261
268
|
before do
|
262
|
-
@account = FactoryGirl.create(:account, :user =>
|
269
|
+
@account = FactoryGirl.create(:account, :user => current_user)
|
263
270
|
@previous = FactoryGirl.create(:account, :user => FactoryGirl.create(:user))
|
264
271
|
end
|
265
272
|
|
@@ -291,44 +298,47 @@ describe AccountsController do
|
|
291
298
|
describe "with valid params" do
|
292
299
|
|
293
300
|
it "should expose a newly created account as @account and render [create] template" do
|
294
|
-
@account = FactoryGirl.build(:account, :name => "Hello world", :user =>
|
301
|
+
@account = FactoryGirl.build(:account, :name => "Hello world", :user => current_user)
|
295
302
|
Account.stub!(:new).and_return(@account)
|
296
|
-
@users = [ FactoryGirl.create(:user) ]
|
297
303
|
|
298
|
-
xhr :post, :create, :account => { :name => "Hello world" }
|
304
|
+
xhr :post, :create, :account => { :name => "Hello world" }
|
299
305
|
assigns(:account).should == @account
|
300
|
-
assigns(:users).should == @users
|
301
306
|
response.should render_template("accounts/create")
|
302
307
|
end
|
303
308
|
|
304
309
|
# Note: [Create Account] is shown only on Accounts index page.
|
305
310
|
it "should reload accounts to update pagination" do
|
306
|
-
@account = FactoryGirl.build(:account, :user =>
|
311
|
+
@account = FactoryGirl.build(:account, :user => current_user)
|
307
312
|
Account.stub!(:new).and_return(@account)
|
308
313
|
|
309
|
-
xhr :post, :create, :account => { :name => "Hello" }
|
314
|
+
xhr :post, :create, :account => { :name => "Hello" }
|
310
315
|
assigns[:accounts].should == [ @account ]
|
311
316
|
end
|
312
317
|
|
313
318
|
it "should get data to update account sidebar" do
|
314
|
-
@account = FactoryGirl.build(:account, :name => "Hello", :user =>
|
319
|
+
@account = FactoryGirl.build(:account, :name => "Hello", :user => current_user)
|
315
320
|
Campaign.stub!(:new).and_return(@account)
|
316
|
-
@users = [ FactoryGirl.create(:user) ]
|
317
321
|
|
318
|
-
xhr :post, :create, :account => { :name => "Hello" }
|
322
|
+
xhr :post, :create, :account => { :name => "Hello" }
|
319
323
|
assigns[:account_category_total].should be_instance_of(HashWithIndifferentAccess)
|
320
324
|
end
|
325
|
+
|
326
|
+
it "should add a new comment to the newly created account when specified" do
|
327
|
+
@account = FactoryGirl.build(:account, :name => "Hello world", :user => current_user)
|
328
|
+
Account.stub!(:new).and_return(@account)
|
329
|
+
|
330
|
+
xhr :post, :create, :account => { :name => "Hello world" }, :comment_body => "Awesome comment is awesome"
|
331
|
+
assigns[:account].comments.map(&:comment).should include("Awesome comment is awesome")
|
332
|
+
end
|
321
333
|
end
|
322
334
|
|
323
335
|
describe "with invalid params" do
|
324
336
|
it "should expose a newly created but unsaved account as @account and still render [create] template" do
|
325
337
|
@account = FactoryGirl.build(:account, :name => nil, :user => nil)
|
326
338
|
Account.stub!(:new).and_return(@account)
|
327
|
-
@users = [ FactoryGirl.create(:user) ]
|
328
339
|
|
329
|
-
xhr :post, :create, :account => {}
|
340
|
+
xhr :post, :create, :account => {}
|
330
341
|
assigns(:account).should == @account
|
331
|
-
assigns(:users).should == @users
|
332
342
|
response.should render_template("accounts/create")
|
333
343
|
end
|
334
344
|
end
|
@@ -353,25 +363,22 @@ describe AccountsController do
|
|
353
363
|
@account = FactoryGirl.create(:account, :id => 42)
|
354
364
|
request.env["HTTP_REFERER"] = "http://localhost/accounts"
|
355
365
|
|
356
|
-
xhr :put, :update, :id => 42, :account => { :name => "Hello" }
|
366
|
+
xhr :put, :update, :id => 42, :account => { :name => "Hello" }
|
357
367
|
assigns(:account).should == @account
|
358
368
|
assigns[:account_category_total].should be_instance_of(HashWithIndifferentAccess)
|
359
369
|
end
|
360
370
|
|
361
371
|
it "should update account permissions when sharing with specific users" do
|
362
372
|
@account = FactoryGirl.create(:account, :id => 42, :access => "Public")
|
363
|
-
he = FactoryGirl.create(:user, :id => 7)
|
364
|
-
she = FactoryGirl.create(:user, :id => 8)
|
365
373
|
|
366
|
-
xhr :put, :update, :id => 42, :account => { :name => "Hello", :access => "Shared"
|
367
|
-
|
368
|
-
|
369
|
-
assigns[:account].should == @account
|
374
|
+
xhr :put, :update, :id => 42, :account => { :name => "Hello", :access => "Shared", :user_ids => [7, 8] }
|
375
|
+
assigns[:account].access.should == "Shared"
|
376
|
+
assigns[:account].user_ids.sort.should == [7, 8]
|
370
377
|
end
|
371
378
|
|
372
379
|
describe "account got deleted or otherwise unavailable" do
|
373
380
|
it "should reload current page is the account got deleted" do
|
374
|
-
@account = FactoryGirl.create(:account, :user =>
|
381
|
+
@account = FactoryGirl.create(:account, :user => current_user)
|
375
382
|
@account.destroy
|
376
383
|
|
377
384
|
xhr :put, :update, :id => @account.id
|
@@ -394,7 +401,7 @@ describe AccountsController do
|
|
394
401
|
@account = FactoryGirl.create(:account, :id => 42, :name => "Hello people")
|
395
402
|
|
396
403
|
xhr :put, :update, :id => 42, :account => { :name => nil }
|
397
|
-
|
404
|
+
assigns(:account).reload.name.should == "Hello people"
|
398
405
|
assigns(:account).should == @account
|
399
406
|
response.should render_template("accounts/update")
|
400
407
|
end
|
@@ -407,12 +414,12 @@ describe AccountsController do
|
|
407
414
|
#----------------------------------------------------------------------------
|
408
415
|
describe "responding to DELETE destroy" do
|
409
416
|
before do
|
410
|
-
@account = FactoryGirl.create(:account, :user =>
|
417
|
+
@account = FactoryGirl.create(:account, :user => current_user)
|
411
418
|
end
|
412
419
|
|
413
420
|
describe "AJAX request" do
|
414
421
|
it "should destroy the requested account and render [destroy] template" do
|
415
|
-
@another_account = FactoryGirl.create(:account, :user =>
|
422
|
+
@another_account = FactoryGirl.create(:account, :user => current_user)
|
416
423
|
xhr :delete, :destroy, :id => @account.id
|
417
424
|
|
418
425
|
lambda { Account.find(@account) }.should raise_error(ActiveRecord::RecordNotFound)
|
@@ -444,7 +451,7 @@ describe AccountsController do
|
|
444
451
|
|
445
452
|
describe "account got deleted or otherwise unavailable" do
|
446
453
|
it "should reload current page is the account got deleted" do
|
447
|
-
@account = FactoryGirl.create(:account, :user =>
|
454
|
+
@account = FactoryGirl.create(:account, :user => current_user)
|
448
455
|
@account.destroy
|
449
456
|
|
450
457
|
xhr :delete, :destroy, :id => @account.id
|
@@ -471,7 +478,7 @@ describe AccountsController do
|
|
471
478
|
end
|
472
479
|
|
473
480
|
it "should redirect to account index with the flash message is the account got deleted" do
|
474
|
-
@account = FactoryGirl.create(:account, :user =>
|
481
|
+
@account = FactoryGirl.create(:account, :user => current_user)
|
475
482
|
@account.destroy
|
476
483
|
|
477
484
|
delete :destroy, :id => @account.id
|
@@ -548,53 +555,31 @@ describe AccountsController do
|
|
548
555
|
#----------------------------------------------------------------------------
|
549
556
|
describe "responding to POST auto_complete" do
|
550
557
|
before do
|
551
|
-
@auto_complete_matches = [ FactoryGirl.create(:account, :name => "Hello World", :user =>
|
558
|
+
@auto_complete_matches = [ FactoryGirl.create(:account, :name => "Hello World", :user => current_user) ]
|
552
559
|
end
|
553
560
|
|
554
561
|
it_should_behave_like("auto complete")
|
555
562
|
end
|
556
563
|
|
557
|
-
# GET /accounts/options AJAX
|
558
|
-
#----------------------------------------------------------------------------
|
559
|
-
describe "responding to GET options" do
|
560
|
-
it "should set current user preferences when showing options" do
|
561
|
-
@per_page = FactoryGirl.create(:preference, :user => @current_user, :name => "accounts_per_page", :value => Base64.encode64(Marshal.dump(42)))
|
562
|
-
@outline = FactoryGirl.create(:preference, :user => @current_user, :name => "accounts_outline", :value => Base64.encode64(Marshal.dump("option_long")))
|
563
|
-
@sort_by = FactoryGirl.create(:preference, :user => @current_user, :name => "accounts_sort_by", :value => Base64.encode64(Marshal.dump("accounts.name ASC")))
|
564
|
-
|
565
|
-
xhr :get, :options
|
566
|
-
assigns[:per_page].should == 42
|
567
|
-
assigns[:outline].should == "option_long"
|
568
|
-
assigns[:sort_by].should == "accounts.name ASC"
|
569
|
-
end
|
570
|
-
|
571
|
-
it "should not assign instance variables when hiding options" do
|
572
|
-
xhr :get, :options, :cancel => "true"
|
573
|
-
assigns[:per_page].should == nil
|
574
|
-
assigns[:outline].should == nil
|
575
|
-
assigns[:sort_by].should == nil
|
576
|
-
end
|
577
|
-
end
|
578
|
-
|
579
564
|
# POST /accounts/redraw AJAX
|
580
565
|
#----------------------------------------------------------------------------
|
581
566
|
describe "responding to POST redraw" do
|
582
567
|
it "should save user selected account preference" do
|
583
|
-
xhr :post, :redraw, :per_page => 42, :
|
584
|
-
|
585
|
-
|
586
|
-
|
568
|
+
xhr :post, :redraw, :per_page => 42, :view => "brief", :sort_by => "name"
|
569
|
+
current_user.preference[:accounts_per_page].should == "42"
|
570
|
+
current_user.preference[:accounts_index_view].should == "brief"
|
571
|
+
current_user.preference[:accounts_sort_by].should == "accounts.name ASC"
|
587
572
|
end
|
588
573
|
|
589
574
|
it "should reset current page to 1" do
|
590
|
-
xhr :post, :redraw, :per_page => 42, :
|
575
|
+
xhr :post, :redraw, :per_page => 42, :view => "brief", :sort_by => "name"
|
591
576
|
session[:accounts_current_page].should == 1
|
592
577
|
end
|
593
578
|
|
594
579
|
it "should select @accounts and render [index] template" do
|
595
580
|
@accounts = [
|
596
|
-
FactoryGirl.create(:account, :name => "A", :user =>
|
597
|
-
FactoryGirl.create(:account, :name => "B", :user =>
|
581
|
+
FactoryGirl.create(:account, :name => "A", :user => current_user),
|
582
|
+
FactoryGirl.create(:account, :name => "B", :user => current_user)
|
598
583
|
]
|
599
584
|
|
600
585
|
xhr :post, :redraw, :per_page => 1, :sort_by => "name"
|
@@ -608,7 +593,7 @@ describe AccountsController do
|
|
608
593
|
describe "responding to POST filter" do
|
609
594
|
it "should expose filtered accounts as @accounts and render [index] template" do
|
610
595
|
session[:accounts_filter] = "customer,vendor"
|
611
|
-
@accounts = [ FactoryGirl.create(:account, :category => "partner", :user =>
|
596
|
+
@accounts = [ FactoryGirl.create(:account, :category => "partner", :user => current_user) ]
|
612
597
|
|
613
598
|
xhr :post, :filter, :category => "partner"
|
614
599
|
assigns(:accounts).should == @accounts
|
@@ -623,4 +608,3 @@ describe AccountsController do
|
|
623
608
|
end
|
624
609
|
end
|
625
610
|
end
|
626
|
-
|
@@ -21,7 +21,7 @@ describe CampaignsController do
|
|
21
21
|
end
|
22
22
|
|
23
23
|
it "should expose all campaigns as @campaigns and render [index] template" do
|
24
|
-
@campaigns = [ FactoryGirl.create(:campaign, :user =>
|
24
|
+
@campaigns = [ FactoryGirl.create(:campaign, :user => current_user) ]
|
25
25
|
|
26
26
|
get :index
|
27
27
|
assigns[:campaigns].should == @campaigns
|
@@ -29,7 +29,7 @@ describe CampaignsController do
|
|
29
29
|
end
|
30
30
|
|
31
31
|
it "should collect the data for the opportunities sidebar" do
|
32
|
-
@campaigns = [ FactoryGirl.create(:campaign, :user =>
|
32
|
+
@campaigns = [ FactoryGirl.create(:campaign, :user => current_user) ]
|
33
33
|
|
34
34
|
get :index
|
35
35
|
(assigns[:campaign_status_total].keys.map(&:to_sym) - (@status << :all << :other)).should == []
|
@@ -38,12 +38,12 @@ describe CampaignsController do
|
|
38
38
|
it "should filter out campaigns by status" do
|
39
39
|
controller.session[:campaigns_filter] = "planned,started"
|
40
40
|
@campaigns = [
|
41
|
-
FactoryGirl.create(:campaign, :user =>
|
42
|
-
FactoryGirl.create(:campaign, :user =>
|
41
|
+
FactoryGirl.create(:campaign, :user => current_user, :status => "started"),
|
42
|
+
FactoryGirl.create(:campaign, :user => current_user, :status => "planned")
|
43
43
|
]
|
44
44
|
|
45
45
|
# This one should be filtered out.
|
46
|
-
FactoryGirl.create(:campaign, :user =>
|
46
|
+
FactoryGirl.create(:campaign, :user => current_user, :status => "completed")
|
47
47
|
|
48
48
|
get :index
|
49
49
|
# Note: can't compare campaigns directly because of BigDecimal objects.
|
@@ -52,8 +52,8 @@ describe CampaignsController do
|
|
52
52
|
end
|
53
53
|
|
54
54
|
it "should perform lookup using query string" do
|
55
|
-
@first = FactoryGirl.create(:campaign, :user =>
|
56
|
-
@second = FactoryGirl.create(:campaign, :user =>
|
55
|
+
@first = FactoryGirl.create(:campaign, :user => current_user, :name => "Hello, world!")
|
56
|
+
@second = FactoryGirl.create(:campaign, :user => current_user, :name => "Hello again")
|
57
57
|
|
58
58
|
get :index, :query => "again"
|
59
59
|
assigns[:campaigns].should == [ @second ]
|
@@ -63,7 +63,7 @@ describe CampaignsController do
|
|
63
63
|
|
64
64
|
describe "AJAX pagination" do
|
65
65
|
it "should pick up page number from params" do
|
66
|
-
@campaigns = [ FactoryGirl.create(:campaign, :user =>
|
66
|
+
@campaigns = [ FactoryGirl.create(:campaign, :user => current_user) ]
|
67
67
|
xhr :get, :index, :page => 42
|
68
68
|
|
69
69
|
assigns[:current_page].to_i.should == 42
|
@@ -74,13 +74,24 @@ describe CampaignsController do
|
|
74
74
|
|
75
75
|
it "should pick up saved page number from session" do
|
76
76
|
session[:campaigns_current_page] = 42
|
77
|
-
@campaigns = [ FactoryGirl.create(:campaign, :user =>
|
77
|
+
@campaigns = [ FactoryGirl.create(:campaign, :user => current_user) ]
|
78
78
|
xhr :get, :index
|
79
79
|
|
80
80
|
assigns[:current_page].should == 42
|
81
81
|
assigns[:campaigns].should == []
|
82
82
|
response.should render_template("campaigns/index")
|
83
83
|
end
|
84
|
+
|
85
|
+
it "should reset current_page when query is altered" do
|
86
|
+
session[:campaigns_current_page] = 42
|
87
|
+
session[:campaigns_current_query] = "bill"
|
88
|
+
@campaigns = [ FactoryGirl.create(:campaign, :user => current_user) ]
|
89
|
+
xhr :get, :index
|
90
|
+
|
91
|
+
assigns[:current_page].should == 1
|
92
|
+
assigns[:campaigns].should == @campaigns
|
93
|
+
response.should render_template("campaigns/index")
|
94
|
+
end
|
84
95
|
end
|
85
96
|
|
86
97
|
describe "with mime type of JSON" do
|
@@ -113,7 +124,7 @@ describe CampaignsController do
|
|
113
124
|
|
114
125
|
describe "with mime type of HTML" do
|
115
126
|
before(:each) do
|
116
|
-
@campaign = FactoryGirl.create(:campaign, :id => 42, :user =>
|
127
|
+
@campaign = FactoryGirl.create(:campaign, :id => 42, :user => current_user)
|
117
128
|
@stage = Setting.unroll(:opportunity_stage)
|
118
129
|
@comment = Comment.new
|
119
130
|
end
|
@@ -134,7 +145,7 @@ describe CampaignsController do
|
|
134
145
|
|
135
146
|
describe "with mime type of JSON" do
|
136
147
|
it "should render the requested campaign as JSON" do
|
137
|
-
@campaign = FactoryGirl.create(:campaign, :id => 42, :user =>
|
148
|
+
@campaign = FactoryGirl.create(:campaign, :id => 42, :user => current_user)
|
138
149
|
Campaign.should_receive(:find).and_return(@campaign)
|
139
150
|
@campaign.should_receive(:to_json).and_return("generated JSON")
|
140
151
|
|
@@ -146,7 +157,7 @@ describe CampaignsController do
|
|
146
157
|
|
147
158
|
describe "with mime type of XML" do
|
148
159
|
it "should render the requested campaign as XML" do
|
149
|
-
@campaign = FactoryGirl.create(:campaign, :id => 42, :user =>
|
160
|
+
@campaign = FactoryGirl.create(:campaign, :id => 42, :user => current_user)
|
150
161
|
Campaign.should_receive(:find).and_return(@campaign)
|
151
162
|
@campaign.should_receive(:to_xml).and_return("generated XML")
|
152
163
|
|
@@ -158,7 +169,7 @@ describe CampaignsController do
|
|
158
169
|
|
159
170
|
describe "campaign got deleted or otherwise unavailable" do
|
160
171
|
it "should redirect to campaign index if the campaign got deleted" do
|
161
|
-
@campaign = FactoryGirl.create(:campaign, :user =>
|
172
|
+
@campaign = FactoryGirl.create(:campaign, :user => current_user)
|
162
173
|
@campaign.destroy
|
163
174
|
|
164
175
|
get :show, :id => @campaign.id
|
@@ -175,7 +186,7 @@ describe CampaignsController do
|
|
175
186
|
end
|
176
187
|
|
177
188
|
it "should return 404 (Not Found) JSON error" do
|
178
|
-
@campaign = FactoryGirl.create(:campaign, :user =>
|
189
|
+
@campaign = FactoryGirl.create(:campaign, :user => current_user)
|
179
190
|
@campaign.destroy
|
180
191
|
request.env["HTTP_ACCEPT"] = "application/json"
|
181
192
|
|
@@ -184,7 +195,7 @@ describe CampaignsController do
|
|
184
195
|
end
|
185
196
|
|
186
197
|
it "should return 404 (Not Found) XML error" do
|
187
|
-
@campaign = FactoryGirl.create(:campaign, :user =>
|
198
|
+
@campaign = FactoryGirl.create(:campaign, :user => current_user)
|
188
199
|
@campaign.destroy
|
189
200
|
request.env["HTTP_ACCEPT"] = "application/xml"
|
190
201
|
|
@@ -200,12 +211,10 @@ describe CampaignsController do
|
|
200
211
|
describe "responding to GET new" do
|
201
212
|
|
202
213
|
it "should expose a new campaign as @campaign" do
|
203
|
-
@campaign = Campaign.new(:user =>
|
204
|
-
|
205
|
-
|
214
|
+
@campaign = Campaign.new(:user => current_user,
|
215
|
+
:access => Setting.default_access)
|
206
216
|
xhr :get, :new
|
207
217
|
assigns[:campaign].attributes.should == @campaign.attributes
|
208
|
-
assigns[:users].should == @users
|
209
218
|
response.should render_template("campaigns/new")
|
210
219
|
end
|
211
220
|
|
@@ -222,12 +231,10 @@ describe CampaignsController do
|
|
222
231
|
describe "responding to GET edit" do
|
223
232
|
|
224
233
|
it "should expose the requested campaign as @campaign and render [edit] template" do
|
225
|
-
@campaign = FactoryGirl.create(:campaign, :id => 42, :user =>
|
226
|
-
@users = [ FactoryGirl.create(:user) ]
|
234
|
+
@campaign = FactoryGirl.create(:campaign, :id => 42, :user => current_user)
|
227
235
|
|
228
236
|
xhr :get, :edit, :id => 42
|
229
237
|
assigns[:campaign].should == @campaign
|
230
|
-
assigns[:users].should == @users
|
231
238
|
response.should render_template("campaigns/edit")
|
232
239
|
end
|
233
240
|
|
@@ -242,7 +249,7 @@ describe CampaignsController do
|
|
242
249
|
|
243
250
|
describe "(campaign got deleted or is otherwise unavailable)" do
|
244
251
|
it "should reload current page with the flash message if the campaign got deleted" do
|
245
|
-
@campaign = FactoryGirl.create(:campaign, :user =>
|
252
|
+
@campaign = FactoryGirl.create(:campaign, :user => current_user)
|
246
253
|
@campaign.destroy
|
247
254
|
|
248
255
|
xhr :get, :edit, :id => @campaign.id
|
@@ -261,7 +268,7 @@ describe CampaignsController do
|
|
261
268
|
|
262
269
|
describe "(previous campaign got deleted or is otherwise unavailable)" do
|
263
270
|
before(:each) do
|
264
|
-
@campaign = FactoryGirl.create(:campaign, :user =>
|
271
|
+
@campaign = FactoryGirl.create(:campaign, :user => current_user)
|
265
272
|
@previous = FactoryGirl.create(:campaign, :user => FactoryGirl.create(:user))
|
266
273
|
end
|
267
274
|
|
@@ -293,44 +300,47 @@ describe CampaignsController do
|
|
293
300
|
describe "with valid params" do
|
294
301
|
|
295
302
|
it "should expose a newly created campaign as @campaign and render [create] template" do
|
296
|
-
@campaign = FactoryGirl.build(:campaign, :name => "Hello", :user =>
|
303
|
+
@campaign = FactoryGirl.build(:campaign, :name => "Hello", :user => current_user)
|
297
304
|
Campaign.stub!(:new).and_return(@campaign)
|
298
|
-
@users = [ FactoryGirl.create(:user) ]
|
299
305
|
|
300
|
-
xhr :post, :create, :campaign => { :name => "Hello" }
|
306
|
+
xhr :post, :create, :campaign => { :name => "Hello" }
|
301
307
|
assigns(:campaign).should == @campaign
|
302
|
-
assigns(:users).should == @users
|
303
308
|
response.should render_template("campaigns/create")
|
304
309
|
end
|
305
310
|
|
306
311
|
it "should get data to update campaign sidebar" do
|
307
|
-
@campaign = FactoryGirl.build(:campaign, :name => "Hello", :user =>
|
312
|
+
@campaign = FactoryGirl.build(:campaign, :name => "Hello", :user => current_user)
|
308
313
|
Campaign.stub!(:new).and_return(@campaign)
|
309
|
-
@users = [ FactoryGirl.create(:user) ]
|
310
314
|
|
311
|
-
xhr :post, :create, :campaign => { :name => "Hello" }
|
315
|
+
xhr :post, :create, :campaign => { :name => "Hello" }
|
312
316
|
assigns[:campaign_status_total].should be_instance_of(HashWithIndifferentAccess)
|
313
317
|
end
|
314
318
|
|
315
319
|
it "should reload campaigns to update pagination" do
|
316
|
-
@campaign = FactoryGirl.build(:campaign, :user =>
|
320
|
+
@campaign = FactoryGirl.build(:campaign, :user => current_user)
|
317
321
|
Campaign.stub!(:new).and_return(@campaign)
|
318
322
|
|
319
|
-
xhr :post, :create, :campaign => { :name => "Hello" }
|
323
|
+
xhr :post, :create, :campaign => { :name => "Hello" }
|
320
324
|
assigns[:campaigns].should == [ @campaign ]
|
321
325
|
end
|
326
|
+
|
327
|
+
it "should add a new comment to the newly created campaign when specified" do
|
328
|
+
@campaign = FactoryGirl.build(:campaign, :name => "Hello world", :user => current_user)
|
329
|
+
Campaign.stub!(:new).and_return(@campaign)
|
330
|
+
|
331
|
+
xhr :post, :create, :campaign => { :name => "Hello world" }, :comment_body => "Awesome comment is awesome"
|
332
|
+
@campaign.reload.comments.map(&:comment).should include("Awesome comment is awesome")
|
333
|
+
end
|
322
334
|
end
|
323
335
|
|
324
336
|
describe "with invalid params" do
|
325
337
|
|
326
338
|
it "should expose a newly created but unsaved campaign as @campaign and still render [create] template" do
|
327
|
-
@campaign = FactoryGirl.build(:campaign, :id => nil, :name => nil, :user =>
|
339
|
+
@campaign = FactoryGirl.build(:campaign, :id => nil, :name => nil, :user => current_user)
|
328
340
|
Campaign.stub!(:new).and_return(@campaign)
|
329
|
-
@users = [ FactoryGirl.create(:user) ]
|
330
341
|
|
331
|
-
xhr :post, :create, :campaign => nil
|
342
|
+
xhr :post, :create, :campaign => nil
|
332
343
|
assigns(:campaign).should == @campaign
|
333
|
-
assigns(:users).should == @users
|
334
344
|
response.should render_template("campaigns/create")
|
335
345
|
end
|
336
346
|
end
|
@@ -346,7 +356,7 @@ describe CampaignsController do
|
|
346
356
|
it "should update the requested campaign and render [update] template" do
|
347
357
|
@campaign = FactoryGirl.create(:campaign, :id => 42, :name => "Bye")
|
348
358
|
|
349
|
-
xhr :put, :update, :id => 42, :campaign => { :name => "Hello" }
|
359
|
+
xhr :put, :update, :id => 42, :campaign => { :name => "Hello" }
|
350
360
|
@campaign.reload.name.should == "Hello"
|
351
361
|
assigns(:campaign).should == @campaign
|
352
362
|
response.should render_template("campaigns/update")
|
@@ -356,7 +366,7 @@ describe CampaignsController do
|
|
356
366
|
@campaign = FactoryGirl.create(:campaign, :id => 42)
|
357
367
|
request.env["HTTP_REFERER"] = "http://localhost/campaigns"
|
358
368
|
|
359
|
-
xhr :put, :update, :id => 42, :campaign => { :name => "Hello" }
|
369
|
+
xhr :put, :update, :id => 42, :campaign => { :name => "Hello" }
|
360
370
|
assigns(:campaign).should == @campaign
|
361
371
|
assigns[:campaign_status_total].should be_instance_of(HashWithIndifferentAccess)
|
362
372
|
end
|
@@ -366,18 +376,17 @@ describe CampaignsController do
|
|
366
376
|
he = FactoryGirl.create(:user, :id => 7)
|
367
377
|
she = FactoryGirl.create(:user, :id => 8)
|
368
378
|
|
369
|
-
xhr :put, :update, :id => 42, :campaign => { :name => "Hello", :access => "Shared"
|
370
|
-
|
371
|
-
|
372
|
-
assigns[:campaign].should == @campaign
|
379
|
+
xhr :put, :update, :id => 42, :campaign => { :name => "Hello", :access => "Shared", :user_ids => %w(7 8) }
|
380
|
+
assigns[:campaign].access.should == "Shared"
|
381
|
+
assigns[:campaign].user_ids.sort.should == [ 7, 8 ]
|
373
382
|
end
|
374
383
|
|
375
384
|
describe "campaign got deleted or otherwise unavailable" do
|
376
385
|
it "should reload current page with the flash message if the campaign got deleted" do
|
377
|
-
@campaign = FactoryGirl.create(:campaign, :user =>
|
386
|
+
@campaign = FactoryGirl.create(:campaign, :user => current_user)
|
378
387
|
@campaign.destroy
|
379
388
|
|
380
|
-
xhr :put, :update, :id => @campaign.id
|
389
|
+
xhr :put, :update, :id => @campaign.id
|
381
390
|
flash[:warning].should_not == nil
|
382
391
|
response.body.should == "window.location.reload();"
|
383
392
|
end
|
@@ -385,7 +394,7 @@ describe CampaignsController do
|
|
385
394
|
it "should reload current page with the flash message if the campaign is protected" do
|
386
395
|
@private = FactoryGirl.create(:campaign, :user => FactoryGirl.create(:user), :access => "Private")
|
387
396
|
|
388
|
-
xhr :put, :update, :id => @private.id
|
397
|
+
xhr :put, :update, :id => @private.id
|
389
398
|
flash[:warning].should_not == nil
|
390
399
|
response.body.should == "window.location.reload();"
|
391
400
|
end
|
@@ -395,13 +404,11 @@ describe CampaignsController do
|
|
395
404
|
describe "with invalid params" do
|
396
405
|
|
397
406
|
it "should not update the requested campaign, but still expose it as @campaign and still render [update] template" do
|
398
|
-
@campaign = FactoryGirl.create(:campaign, :id => 42, :name => "Hello", :user =>
|
399
|
-
@users = [ FactoryGirl.create(:user) ]
|
407
|
+
@campaign = FactoryGirl.create(:campaign, :id => 42, :name => "Hello", :user => current_user)
|
400
408
|
|
401
409
|
xhr :put, :update, :id => 42, :campaign => { :name => nil }
|
402
410
|
@campaign.reload.name.should == "Hello"
|
403
411
|
assigns(:campaign).should == @campaign
|
404
|
-
assigns(:users).should == @users
|
405
412
|
response.should render_template("campaigns/update")
|
406
413
|
end
|
407
414
|
end
|
@@ -412,12 +419,12 @@ describe CampaignsController do
|
|
412
419
|
#----------------------------------------------------------------------------
|
413
420
|
describe "responding to DELETE destroy" do
|
414
421
|
before(:each) do
|
415
|
-
@campaign = FactoryGirl.create(:campaign, :user =>
|
422
|
+
@campaign = FactoryGirl.create(:campaign, :user => current_user)
|
416
423
|
end
|
417
424
|
|
418
425
|
describe "AJAX request" do
|
419
426
|
it "should destroy the requested campaign and render [destroy] template" do
|
420
|
-
@another_campaign = FactoryGirl.create(:campaign, :user =>
|
427
|
+
@another_campaign = FactoryGirl.create(:campaign, :user => current_user)
|
421
428
|
xhr :delete, :destroy, :id => @campaign.id
|
422
429
|
|
423
430
|
assigns[:campaigns].should == [ @another_campaign ]
|
@@ -449,7 +456,7 @@ describe CampaignsController do
|
|
449
456
|
|
450
457
|
describe "campaign got deleted or otherwise unavailable" do
|
451
458
|
it "should reload current page with the flash message if the campaign got deleted" do
|
452
|
-
@campaign = FactoryGirl.create(:campaign, :user =>
|
459
|
+
@campaign = FactoryGirl.create(:campaign, :user => current_user)
|
453
460
|
@campaign.destroy
|
454
461
|
|
455
462
|
xhr :delete, :destroy, :id => @campaign.id
|
@@ -476,7 +483,7 @@ describe CampaignsController do
|
|
476
483
|
end
|
477
484
|
|
478
485
|
it "should redirect to campaign index with the flash message is the campaign got deleted" do
|
479
|
-
@campaign = FactoryGirl.create(:campaign, :user =>
|
486
|
+
@campaign = FactoryGirl.create(:campaign, :user => current_user)
|
480
487
|
@campaign.destroy
|
481
488
|
|
482
489
|
delete :destroy, :id => @campaign.id
|
@@ -587,53 +594,31 @@ describe CampaignsController do
|
|
587
594
|
#----------------------------------------------------------------------------
|
588
595
|
describe "responding to POST auto_complete" do
|
589
596
|
before(:each) do
|
590
|
-
@auto_complete_matches = [ FactoryGirl.create(:campaign, :name => "Hello World", :user =>
|
597
|
+
@auto_complete_matches = [ FactoryGirl.create(:campaign, :name => "Hello World", :user => current_user) ]
|
591
598
|
end
|
592
599
|
|
593
600
|
it_should_behave_like("auto complete")
|
594
601
|
end
|
595
602
|
|
596
|
-
# GET /campaigns/options AJAX
|
597
|
-
#----------------------------------------------------------------------------
|
598
|
-
describe "responding to GET options" do
|
599
|
-
it "should set current user preferences when showing options" do
|
600
|
-
@per_page = FactoryGirl.create(:preference, :user => @current_user, :name => "campaigns_per_page", :value => Base64.encode64(Marshal.dump(42)))
|
601
|
-
@outline = FactoryGirl.create(:preference, :user => @current_user, :name => "campaigns_outline", :value => Base64.encode64(Marshal.dump("option_long")))
|
602
|
-
@sort_by = FactoryGirl.create(:preference, :user => @current_user, :name => "campaigns_sort_by", :value => Base64.encode64(Marshal.dump("campaigns.name ASC")))
|
603
|
-
|
604
|
-
xhr :get, :options
|
605
|
-
assigns[:per_page].should == 42
|
606
|
-
assigns[:outline].should == "option_long"
|
607
|
-
assigns[:sort_by].should == "campaigns.name ASC"
|
608
|
-
end
|
609
|
-
|
610
|
-
it "should not assign instance variables when hiding options" do
|
611
|
-
xhr :get, :options, :cancel => "true"
|
612
|
-
assigns[:per_page].should == nil
|
613
|
-
assigns[:outline].should == nil
|
614
|
-
assigns[:sort_by].should == nil
|
615
|
-
end
|
616
|
-
end
|
617
|
-
|
618
603
|
# POST /campaigns/redraw AJAX
|
619
604
|
#----------------------------------------------------------------------------
|
620
605
|
describe "responding to POST redraw" do
|
621
606
|
it "should save user selected campaign preference" do
|
622
|
-
xhr :post, :redraw, :per_page => 42, :
|
623
|
-
|
624
|
-
|
625
|
-
|
607
|
+
xhr :post, :redraw, :per_page => 42, :view => "brief", :sort_by => "name"
|
608
|
+
current_user.preference[:campaigns_per_page].should == "42"
|
609
|
+
current_user.preference[:campaigns_index_view].should == "brief"
|
610
|
+
current_user.preference[:campaigns_sort_by].should == "campaigns.name ASC"
|
626
611
|
end
|
627
612
|
|
628
613
|
it "should reset current page to 1" do
|
629
|
-
xhr :post, :redraw, :per_page => 42, :
|
614
|
+
xhr :post, :redraw, :per_page => 42, :view => "brief", :sort_by => "name"
|
630
615
|
session[:campaigns_current_page].should == 1
|
631
616
|
end
|
632
617
|
|
633
618
|
it "should select @campaigns and render [index] template" do
|
634
619
|
@campaigns = [
|
635
|
-
FactoryGirl.create(:campaign, :name => "A", :user =>
|
636
|
-
FactoryGirl.create(:campaign, :name => "B", :user =>
|
620
|
+
FactoryGirl.create(:campaign, :name => "A", :user => current_user),
|
621
|
+
FactoryGirl.create(:campaign, :name => "B", :user => current_user)
|
637
622
|
]
|
638
623
|
|
639
624
|
xhr :post, :redraw, :per_page => 1, :sort_by => "name"
|
@@ -648,7 +633,7 @@ describe CampaignsController do
|
|
648
633
|
|
649
634
|
it "should expose filtered campaigns as @campaigns and render [index] template" do
|
650
635
|
session[:campaigns_filter] = "planned,started"
|
651
|
-
@campaigns = [ FactoryGirl.create(:campaign, :status => "completed", :user =>
|
636
|
+
@campaigns = [ FactoryGirl.create(:campaign, :status => "completed", :user => current_user) ]
|
652
637
|
|
653
638
|
xhr :post, :filter, :status => "completed"
|
654
639
|
assigns(:campaigns).should == @campaigns
|
@@ -665,4 +650,3 @@ describe CampaignsController do
|
|
665
650
|
end
|
666
651
|
|
667
652
|
end
|
668
|
-
|