fat_free_crm 0.13.6 → 0.14.0
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of fat_free_crm might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/.rubocop.yml +5 -0
- data/.travis.yml +8 -5
- data/CHANGELOG +26 -0
- data/Gemfile +26 -26
- data/Gemfile.lock +280 -250
- data/Guardfile +0 -1
- data/README.md +7 -9
- data/Rakefile +1 -1
- data/app/assets/javascripts/application.js.erb +1 -0
- data/app/assets/javascripts/crm.js.coffee +6 -7
- data/app/assets/javascripts/search.js.coffee +7 -1
- data/app/assets/stylesheets/about.css.scss +10 -0
- data/app/assets/stylesheets/application.css.erb +2 -0
- data/app/assets/stylesheets/common.scss +1 -1
- data/app/controllers/admin/application_controller.rb +3 -3
- data/app/controllers/admin/field_groups_controller.rb +12 -7
- data/app/controllers/admin/fields_controller.rb +21 -17
- data/app/controllers/admin/groups_controller.rb +10 -4
- data/app/controllers/admin/plugins_controller.rb +1 -2
- data/app/controllers/admin/settings_controller.rb +1 -2
- data/app/controllers/admin/tags_controller.rb +10 -4
- data/app/controllers/admin/users_controller.rb +32 -12
- data/app/controllers/application_controller.rb +58 -38
- data/app/controllers/authentications_controller.rb +5 -8
- data/app/controllers/comments_controller.rb +15 -11
- data/app/controllers/emails_controller.rb +1 -2
- data/app/controllers/entities/accounts_controller.rb +20 -20
- data/app/controllers/entities/campaigns_controller.rb +25 -22
- data/app/controllers/entities/contacts_controller.rb +25 -24
- data/app/controllers/entities/leads_controller.rb +33 -31
- data/app/controllers/entities/opportunities_controller.rb +31 -28
- data/app/controllers/entities_controller.rb +26 -22
- data/app/controllers/home_controller.rb +18 -18
- data/app/controllers/lists_controller.rb +11 -7
- data/app/controllers/passwords_controller.rb +5 -6
- data/app/controllers/tasks_controller.rb +23 -18
- data/app/controllers/users_controller.rb +31 -7
- data/app/helpers/accounts_helper.rb +40 -42
- data/app/helpers/addresses_helper.rb +1 -3
- data/app/helpers/admin/application_helper.rb +4 -4
- data/app/helpers/admin/field_groups_helper.rb +5 -7
- data/app/helpers/admin/fields_helper.rb +2 -3
- data/app/helpers/admin/plugins_helper.rb +0 -1
- data/app/helpers/admin/settings_helper.rb +0 -1
- data/app/helpers/admin/tags_helper.rb +1 -1
- data/app/helpers/admin/users_helper.rb +16 -18
- data/app/helpers/application_helper.rb +127 -119
- data/app/helpers/authentications_helper.rb +0 -1
- data/app/helpers/campaigns_helper.rb +5 -7
- data/app/helpers/comments_helper.rb +0 -1
- data/app/helpers/contacts_helper.rb +0 -1
- data/app/helpers/home_helper.rb +14 -14
- data/app/helpers/javascript_helper.rb +30 -0
- data/app/helpers/leads_helper.rb +7 -7
- data/app/helpers/opportunities_helper.rb +8 -10
- data/app/helpers/passwords_helper.rb +0 -1
- data/app/helpers/tags_helper.rb +1 -3
- data/app/helpers/tasks_helper.rb +24 -26
- data/app/helpers/users_helper.rb +6 -7
- data/app/helpers/versions_helper.rb +3 -5
- data/app/inputs/date_pair_input.rb +6 -7
- data/app/inputs/date_time_input.rb +3 -4
- data/app/inputs/datetime_pair_input.rb +0 -1
- data/app/inputs/text_input.rb +2 -2
- data/app/mailers/dropbox_mailer.rb +4 -7
- data/app/mailers/subscription_mailer.rb +4 -5
- data/app/mailers/user_mailer.rb +7 -9
- data/app/models/entities/account.rb +31 -28
- data/app/models/entities/account_contact.rb +2 -1
- data/app/models/entities/account_opportunity.rb +1 -1
- data/app/models/entities/campaign.rb +22 -19
- data/app/models/entities/contact.rb +55 -53
- data/app/models/entities/contact_opportunity.rb +1 -1
- data/app/models/entities/lead.rb +49 -41
- data/app/models/entities/opportunity.rb +38 -38
- data/app/models/fields/custom_field.rb +21 -27
- data/app/models/fields/custom_field_date_pair.rb +7 -8
- data/app/models/fields/custom_field_datetime_pair.rb +0 -2
- data/app/models/fields/custom_field_pair.rb +8 -10
- data/app/models/fields/field.rb +29 -30
- data/app/models/fields/field_group.rb +4 -4
- data/app/models/list.rb +1 -1
- data/app/models/observers/entity_observer.rb +1 -1
- data/app/models/observers/lead_observer.rb +1 -1
- data/app/models/observers/opportunity_observer.rb +1 -1
- data/app/models/observers/task_observer.rb +1 -1
- data/app/models/polymorphic/address.rb +7 -7
- data/app/models/polymorphic/avatar.rb +8 -9
- data/app/models/polymorphic/comment.rb +16 -10
- data/app/models/polymorphic/email.rb +13 -6
- data/app/models/polymorphic/tag.rb +2 -2
- data/app/models/polymorphic/task.rb +45 -45
- data/{config/initializers/paper_trail.rb → app/models/polymorphic/version.rb} +26 -31
- data/app/models/setting.rb +12 -17
- data/app/models/users/ability.rb +5 -6
- data/app/models/users/authentication.rb +6 -5
- data/app/models/users/group.rb +1 -3
- data/app/models/users/permission.rb +3 -3
- data/app/models/users/preference.rb +7 -7
- data/app/models/users/user.rb +36 -43
- data/app/views/accounts/_top_section.html.haml +2 -2
- data/app/views/accounts/edit.js.haml +0 -1
- data/app/views/admin/fields/_field.html.haml +1 -1
- data/app/views/admin/tags/_tag.html.haml +1 -1
- data/app/views/admin/users/_user.html.haml +4 -4
- data/app/views/campaigns/_top_section.html.haml +1 -1
- data/app/views/campaigns/edit.js.haml +0 -2
- data/app/views/contacts/_top_section.html.haml +1 -1
- data/app/views/contacts/edit.js.haml +0 -1
- data/app/views/entities/_basic_search.html.haml +1 -1
- data/app/views/home/_account.html.haml +2 -2
- data/app/views/home/_opportunity.html.haml +2 -2
- data/app/views/layouts/_about.html.haml +1 -1
- data/app/views/leads/_top_section.html.haml +1 -1
- data/app/views/leads/edit.js.haml +0 -2
- data/app/views/lists/_sidebar.html.haml +1 -1
- data/app/views/opportunities/_top_section.html.haml +2 -2
- data/app/views/opportunities/edit.js.haml +0 -1
- data/app/views/shared/_tags.html.haml +2 -1
- data/app/views/tasks/_edit.html.haml +2 -3
- data/app/views/tasks/_top_section.html.haml +1 -1
- data/app/views/users/_user.html.haml +2 -1
- data/app/views/users/opportunities_overview.html.haml +2 -2
- data/bin/bundle +3 -0
- data/bin/rails +4 -0
- data/bin/rake +4 -0
- data/config/application.rb +16 -33
- data/config/boot.rb +1 -1
- data/config/database.mysql.mac.yml +1 -0
- data/config/database.mysql.yml +1 -0
- data/config/database.postgres.docker.yml +1 -1
- data/config/database.postgres.yml +1 -0
- data/config/database.sqlite.yml +1 -0
- data/config/deploy.example.rb +3 -5
- data/config/environments/development.rb +13 -14
- data/config/environments/production.rb +8 -7
- data/config/environments/staging.rb +43 -41
- data/config/environments/test.rb +12 -14
- data/config/initializers/assets.rb +14 -0
- data/config/initializers/backtrace_silencers.rb +7 -0
- data/config/initializers/cookies_serializer.rb +3 -0
- data/config/initializers/custom_field_ransack_translations.rb +1 -1
- data/config/initializers/filter_parameter_logging.rb +4 -0
- data/config/initializers/inflections.rb +16 -0
- data/config/initializers/mime_types.rb +0 -1
- data/config/initializers/paginate_arrays.rb +0 -1
- data/config/initializers/ransack.rb +5 -5
- data/config/initializers/session_store.rb +5 -0
- data/config/initializers/simple_form.rb +1 -1
- data/config/initializers/views.rb +33 -33
- data/config/initializers/wrap_parameters.rb +14 -0
- data/config/locales/cz_fat_free_crm.yml +1 -1
- data/config/locales/de_fat_free_crm.yml +2 -2
- data/config/locales/en-GB_fat_free_crm.yml +2 -3
- data/config/locales/en-US_fat_free_crm.yml +2 -3
- data/config/locales/en.yml +23 -0
- data/config/locales/es-CL.yml +227 -0
- data/config/locales/es-CL_fat_free_crm.yml +929 -0
- data/config/locales/es-CL_ransack.yml +91 -0
- data/config/locales/es.yml +53 -59
- data/config/locales/es_fat_free_crm.yml +708 -370
- data/config/locales/es_ransack.yml +91 -0
- data/config/locales/fr-CA_fat_free_crm.yml +7 -7
- data/config/locales/fr_fat_free_crm.yml +285 -81
- data/config/locales/it_fat_free_crm.yml +1 -1
- data/config/locales/ja_fat_free_crm.yml +1 -1
- data/config/locales/nl.yml +210 -0
- data/config/locales/nl_fat_free_crm.yml +920 -0
- data/config/locales/nl_ransack.yml +91 -0
- data/config/locales/pl_fat_free_crm.yml +1 -1
- data/config/locales/pt-BR_fat_free_crm.yml +111 -38
- data/config/locales/ru_fat_free_crm.yml +3 -4
- data/config/locales/sv-SE_fat_free_crm.yml +1 -1
- data/config/locales/th.rb +157 -158
- data/config/locales/th_fat_free_crm.yml +1 -1
- data/config/locales/zh-CN_fat_free_crm.yml +3 -4
- data/config/routes.rb +93 -94
- data/config/unicorn.rb +25 -2
- data/custom_plan.rb +0 -2
- data/db/demo/accounts.yml +4 -5
- data/db/demo/addresses.yml +5 -5
- data/db/demo/campaigns.yml +2 -2
- data/db/demo/comments.yml +1 -1
- data/db/demo/contacts.yml +8 -8
- data/db/demo/emails.yml +5 -5
- data/db/demo/leads.yml +10 -10
- data/db/demo/opportunities.yml +2 -2
- data/db/demo/tasks.yml +2 -2
- data/db/demo/users.yml +12 -16
- data/db/migrate/20100928030598_create_sessions.rb +1 -2
- data/db/migrate/20100928030599_create_users.rb +24 -25
- data/db/migrate/20100928030600_create_openid_tables.rb +11 -12
- data/db/migrate/20100928030601_create_accounts.rb +14 -15
- data/db/migrate/20100928030602_create_permissions.rb +2 -3
- data/db/migrate/20100928030603_create_settings.rb +4 -5
- data/db/migrate/20100928030604_create_preferences.rb +3 -4
- data/db/migrate/20100928030605_create_campaigns.rb +19 -20
- data/db/migrate/20100928030606_create_leads.rb +26 -27
- data/db/migrate/20100928030607_create_contacts.rb +26 -27
- data/db/migrate/20100928030608_create_opportunities.rb +15 -16
- data/db/migrate/20100928030609_create_account_contacts.rb +2 -3
- data/db/migrate/20100928030610_create_account_opportunities.rb +2 -3
- data/db/migrate/20100928030611_create_contact_opportunities.rb +3 -4
- data/db/migrate/20100928030612_create_tasks.rb +14 -15
- data/db/migrate/20100928030613_create_comments.rb +6 -7
- data/db/migrate/20100928030614_create_activities.rb +6 -7
- data/db/migrate/20100928030615_create_avatars.rb +5 -6
- data/db/migrate/20100928030616_rename_remember_token.rb +0 -1
- data/db/migrate/20100928030617_drop_openid_tables.rb +11 -11
- data/db/migrate/20100928030618_add_admin_to_users.rb +1 -2
- data/db/migrate/20100928030619_add_suspended_to_users.rb +0 -1
- data/db/migrate/20100928030620_remove_uuid.rb +3 -3
- data/db/migrate/20100928030621_add_email_to_accounts.rb +1 -2
- data/db/migrate/20100928030622_add_background_info_to_models.rb +0 -1
- data/db/migrate/20100928030623_create_addresses.rb +14 -16
- data/db/migrate/20100928030624_add_index_on_permissions.rb +2 -3
- data/db/migrate/20100928030625_create_emails.rb +15 -16
- data/db/migrate/20100928030626_add_state_to_timeline_objects.rb +2 -3
- data/db/migrate/20100928030627_acts_as_taggable_on_migration.rb +2 -3
- data/db/migrate/20101221123456_add_single_access_token_to_users.rb +0 -1
- data/db/migrate/20101221345678_add_rating_and_category_to_accounts.rb +2 -3
- data/db/migrate/20110719082054_add_skype_to_contacts_and_leads.rb +2 -3
- data/db/migrate/20111101083437_create_fields.rb +14 -15
- data/db/migrate/20111101090312_create_field_groups.rb +4 -5
- data/db/migrate/20111116091952_add_field_groups_tag_id.rb +0 -1
- data/db/migrate/20111117041311_change_fields_collection_to_text.rb +0 -1
- data/db/migrate/20111201030535_add_field_groups_klass_name.rb +4 -4
- data/db/migrate/20120121054235_create_lists.rb +1 -1
- data/db/migrate/20120216031616_create_versions.rb +5 -5
- data/db/migrate/20120216042541_is_paranoid_to_paper_trail.rb +1 -3
- data/db/migrate/20120224073107_remove_default_value_and_clear_settings.rb +1 -1
- data/db/migrate/20120316045804_activities_to_versions.rb +6 -6
- data/db/migrate/20120405080727_change_subscribed_users_to_set.rb +5 -5
- data/db/migrate/20120405080742_change_further_subscribed_users_to_set.rb +5 -5
- data/db/migrate/20120406082136_create_groups.rb +1 -1
- data/db/migrate/20120510025219_add_not_null_constraints_for_timestamp_columns.rb +2 -1
- data/db/migrate/20120528102124_increase_length_of_version_events.rb +2 -2
- data/db/migrate/20121003063155_add_settings_to_custom_fields.rb +1 -1
- data/db/migrate/20121221033947_fix_country_mapping.rb +0 -1
- data/db/migrate/20131207033244_add_user_id_to_lists.rb +1 -1
- data/db/migrate/20141126031837_increase_email_to254_chars.rb +14 -14
- data/db/migrate/20141230021159_add_transaction_id_column_to_versions.rb +11 -0
- data/db/migrate/20141230205453_add_missing_unique_indices.acts_as_taggable_on_engine.rb +20 -0
- data/db/migrate/20141230205454_add_taggings_counter_cache_to_tags.acts_as_taggable_on_engine.rb +15 -0
- data/db/migrate/20141230205455_add_missing_taggable_index.acts_as_taggable_on_engine.rb +10 -0
- data/db/migrate/20150123060900_convert_radio_to_radio_buttons.rb +10 -0
- data/db/migrate/20150227123054_remove_last_request_at_from_users.rb +5 -0
- data/db/migrate/20150427131956_create_index_related_type.rb +9 -0
- data/db/migrate/20160511053730_add_account_contacts_index.rb +5 -0
- data/db/schema.rb +236 -228
- data/db/seeds.rb +1 -2
- data/db/seeds/fields.rb +36 -37
- data/{fig.yml → docker-compose.yml} +0 -0
- data/fat_free_crm.gemspec +31 -18
- data/lib/development_tasks/license.rake +29 -29
- data/lib/fat_free_crm.rb +1 -5
- data/lib/fat_free_crm/callback.rb +28 -20
- data/lib/fat_free_crm/comment_extensions.rb +1 -1
- data/lib/fat_free_crm/core_ext.rb +1 -1
- data/lib/fat_free_crm/core_ext/nil.rb +0 -3
- data/lib/fat_free_crm/core_ext/string.rb +7 -21
- data/lib/fat_free_crm/custom_fields.rb +2 -2
- data/lib/fat_free_crm/engine.rb +14 -0
- data/lib/fat_free_crm/errors.rb +0 -2
- data/lib/fat_free_crm/exceptions.rb +3 -4
- data/lib/fat_free_crm/export_csv.rb +0 -2
- data/lib/fat_free_crm/exportable.rb +5 -7
- data/lib/fat_free_crm/fields.rb +7 -8
- data/lib/fat_free_crm/gem_dependencies.rb +4 -1
- data/lib/fat_free_crm/gem_ext/active_record/schema_dumper.rb +2 -2
- data/lib/fat_free_crm/gem_ext/active_support/buffered_logger.rb +0 -3
- data/lib/fat_free_crm/gem_ext/rails/engine.rb +5 -12
- data/lib/fat_free_crm/gem_ext/rake/task.rb +1 -1
- data/lib/fat_free_crm/gem_ext/simple_form/action_view_extensions/form_helper.rb +1 -2
- data/lib/fat_free_crm/i18n.rb +2 -3
- data/lib/fat_free_crm/load_settings.rb +0 -2
- data/lib/fat_free_crm/mail_processor/base.rb +15 -16
- data/lib/fat_free_crm/mail_processor/comment_replies.rb +5 -10
- data/lib/fat_free_crm/mail_processor/dropbox.rb +56 -59
- data/lib/fat_free_crm/permissions.rb +18 -15
- data/lib/fat_free_crm/renderers.rb +2 -2
- data/lib/fat_free_crm/secret_token_generator.rb +3 -9
- data/lib/fat_free_crm/sortable.rb +4 -8
- data/lib/fat_free_crm/version.rb +2 -2
- data/lib/fat_free_crm/view_factory.rb +3 -8
- data/lib/gravatar_image_tag.rb +19 -24
- data/lib/missing_translation_detector.rb +10 -10
- data/lib/tasks/ffcrm/comment_replies.rake +3 -5
- data/lib/tasks/ffcrm/config.rake +3 -5
- data/lib/tasks/ffcrm/demo.rake +14 -16
- data/lib/tasks/ffcrm/dropbox.rake +3 -5
- data/lib/tasks/ffcrm/missing_translations.rake +1 -1
- data/lib/tasks/ffcrm/secret.rake +1 -3
- data/lib/tasks/ffcrm/settings.rake +2 -4
- data/lib/tasks/ffcrm/setup.rake +3 -6
- data/lib/tasks/ffcrm/update_data.rake +110 -116
- data/spec/controllers/admin/groups_controller_spec.rb +0 -1
- data/spec/controllers/admin/users_controller_spec.rb +98 -102
- data/spec/controllers/applications_controller_spec.rb +17 -21
- data/spec/controllers/authentications_controller_spec.rb +57 -61
- data/spec/controllers/comments_controller_spec.rb +32 -39
- data/spec/controllers/emails_controller_spec.rb +6 -7
- data/spec/controllers/entities/accounts_controller_spec.rb +204 -214
- data/spec/controllers/entities/campaigns_controller_spec.rb +210 -224
- data/spec/controllers/entities/contacts_controller_spec.rb +250 -270
- data/spec/controllers/entities/leads_controller_spec.rb +415 -438
- data/spec/controllers/entities/opportunities_controller_spec.rb +344 -359
- data/spec/controllers/entities_controller_spec.rb +10 -14
- data/spec/controllers/home_controller_spec.rb +85 -92
- data/spec/controllers/lists_controller_spec.rb +0 -1
- data/spec/controllers/passwords_controller_spec.rb +5 -9
- data/spec/controllers/tasks_controller_spec.rb +193 -210
- data/spec/controllers/users_controller_spec.rb +137 -146
- data/spec/factories/account_factories.rb +11 -13
- data/spec/factories/campaign_factories.rb +6 -6
- data/spec/factories/contact_factories.rb +21 -22
- data/spec/factories/field_factories.rb +8 -10
- data/spec/factories/lead_factories.rb +16 -16
- data/spec/factories/list_factories.rb +2 -2
- data/spec/factories/opportunity_factories.rb +8 -10
- data/spec/factories/sequences.rb +8 -9
- data/spec/factories/setting_factories.rb +2 -2
- data/spec/factories/shared_factories.rb +26 -30
- data/spec/factories/tag_factories.rb +1 -1
- data/spec/factories/task_factories.rb +11 -11
- data/spec/factories/user_factories.rb +22 -27
- data/spec/features/acceptance_helper.rb +1 -1
- data/spec/features/accounts_spec.rb +65 -61
- data/spec/features/admin/groups_spec.rb +11 -12
- data/spec/features/admin/users_spec.rb +17 -19
- data/spec/features/campaigns_spec.rb +61 -57
- data/spec/features/contacts_spec.rb +90 -59
- data/spec/features/dashboard_spec.rb +20 -21
- data/spec/features/leads_spec.rb +88 -67
- data/spec/features/opportunities_overview_spec.rb +31 -31
- data/spec/features/opportunities_spec.rb +64 -60
- data/spec/features/support/browser.rb +2 -2
- data/spec/features/support/headless.rb +1 -1
- data/spec/features/support/helpers.rb +5 -6
- data/spec/features/support/paths.rb +1 -2
- data/spec/features/support/selector_helpers.rb +2 -2
- data/spec/features/tasks_spec.rb +60 -54
- data/spec/helpers/accounts_helper_spec.rb +2 -5
- data/spec/helpers/admin/field_groups_helper_spec.rb +4 -4
- data/spec/helpers/admin/plugins_helper_spec.rb +0 -1
- data/spec/helpers/admin/settings_helper_spec.rb +0 -1
- data/spec/helpers/admin/users_helper_spec.rb +0 -1
- data/spec/helpers/application_helper_spec.rb +30 -33
- data/spec/helpers/authentications_helper_spec.rb +2 -5
- data/spec/helpers/campaigns_helper_spec.rb +2 -5
- data/spec/helpers/comments_helper_spec.rb +2 -5
- data/spec/helpers/contacts_helper_spec.rb +2 -5
- data/spec/helpers/emails_helper_spec.rb +0 -1
- data/spec/helpers/fields_helper_spec.rb +0 -1
- data/spec/helpers/groups_helper_spec.rb +0 -1
- data/spec/helpers/home_helper_spec.rb +2 -5
- data/spec/helpers/leads_helper_spec.rb +2 -5
- data/spec/helpers/lists_helper_spec.rb +0 -1
- data/spec/helpers/opportunities_helper_spec.rb +2 -5
- data/spec/helpers/passwords_helper_spec.rb +2 -5
- data/spec/helpers/tasks_helper_spec.rb +1 -5
- data/spec/helpers/users_helper_spec.rb +9 -11
- data/spec/lib/comment_extensions_spec.rb +3 -3
- data/spec/lib/core_ext/string_spec.rb +1 -1
- data/spec/lib/errors_spec.rb +10 -10
- data/spec/lib/fields_spec.rb +23 -33
- data/spec/lib/mail_processor/base_spec.rb +41 -43
- data/spec/lib/mail_processor/comment_replies_spec.rb +17 -17
- data/spec/lib/mail_processor/dropbox_spec.rb +91 -95
- data/spec/lib/mail_processor/sample_emails/dropbox.rb +13 -14
- data/spec/lib/permissions_spec.rb +44 -47
- data/spec/lib/secret_token_generator_spec.rb +16 -28
- data/spec/lib/view_factory_spec.rb +18 -24
- data/spec/mailers/subscription_mailer_spec.rb +14 -16
- data/spec/mailers/user_mailer_spec.rb +33 -34
- data/spec/models/entities/account_contact_spec.rb +2 -3
- data/spec/models/entities/account_opportunity_spec.rb +2 -3
- data/spec/models/entities/account_spec.rb +52 -59
- data/spec/models/entities/campaign_spec.rb +32 -39
- data/spec/models/entities/contact_opportunity_spec.rb +2 -3
- data/spec/models/entities/contact_spec.rb +71 -72
- data/spec/models/entities/lead_spec.rb +15 -22
- data/spec/models/entities/opportunity_spec.rb +104 -103
- data/spec/models/fields/custom_field_date_pair_spec.rb +38 -44
- data/spec/models/fields/custom_field_pair_spec.rb +28 -36
- data/spec/models/fields/custom_field_spec.rb +50 -56
- data/spec/models/fields/field_group_spec.rb +1 -2
- data/spec/models/fields/field_spec.rb +13 -15
- data/spec/models/list_spec.rb +4 -4
- data/spec/models/observers/entity_observer_spec.rb +18 -21
- data/spec/models/polymorphic/address_spec.rb +1 -3
- data/spec/models/polymorphic/avatar_spec.rb +6 -8
- data/spec/models/polymorphic/comment_spec.rb +7 -9
- data/spec/models/polymorphic/email_spec.rb +1 -2
- data/spec/models/polymorphic/task_spec.rb +130 -142
- data/spec/models/polymorphic/version_spec.rb +84 -91
- data/spec/models/setting_spec.rb +17 -19
- data/spec/models/users/abilities/user_ability_spec.rb +25 -20
- data/spec/models/users/authentication_spec.rb +0 -1
- data/spec/models/users/group_spec.rb +0 -1
- data/spec/models/users/permission_spec.rb +12 -13
- data/spec/models/users/preference_spec.rb +15 -15
- data/spec/models/users/user_spec.rb +53 -55
- data/spec/routing/accounts_routing_spec.rb +12 -14
- data/spec/routing/admin/users_routing_spec.rb +7 -9
- data/spec/routing/campaigns_routing_spec.rb +13 -14
- data/spec/routing/comments_routing_spec.rb +5 -6
- data/spec/routing/contacts_routing_spec.rb +12 -14
- data/spec/routing/emails_routing_spec.rb +7 -8
- data/spec/routing/leads_routing_spec.rb +19 -21
- data/spec/routing/opportunities_routing_spec.rb +13 -15
- data/spec/routing/tasks_routing_spec.rb +14 -15
- data/spec/routing/users_routing_spec.rb +18 -19
- data/spec/shared/controllers.rb +35 -35
- data/spec/shared/models.rb +52 -55
- data/spec/spec_helper.rb +21 -42
- data/spec/support/assert_select.rb +19 -18
- data/spec/support/auth_macros.rb +3 -3
- data/spec/support/macros.rb +5 -6
- data/spec/support/mail_processor_mocks.rb +11 -11
- data/spec/views/accounts/_edit.haml_spec.rb +9 -9
- data/spec/views/accounts/_new.haml_spec.rb +8 -9
- data/spec/views/accounts/create.js.haml_spec.rb +11 -12
- data/spec/views/accounts/destroy.js.haml_spec.rb +6 -7
- data/spec/views/accounts/edit.js.haml_spec.rb +12 -13
- data/spec/views/accounts/index.haml_spec.rb +8 -8
- data/spec/views/accounts/index.js.haml_spec.rb +7 -8
- data/spec/views/accounts/new.js.haml_spec.rb +7 -8
- data/spec/views/accounts/show.haml_spec.rb +11 -12
- data/spec/views/accounts/update.js.haml_spec.rb +18 -18
- data/spec/views/admin/field_groups/create.js.haml_spec.rb +8 -10
- data/spec/views/admin/field_groups/destroy.js.haml_spec.rb +7 -9
- data/spec/views/admin/field_groups/edit.js.haml_spec.rb +5 -7
- data/spec/views/admin/field_groups/new.js.haml_spec.rb +6 -8
- data/spec/views/admin/field_groups/update.js.haml_spec.rb +7 -9
- data/spec/views/admin/users/_create.haml_spec.rb +4 -4
- data/spec/views/admin/users/create.js.haml_spec.rb +8 -9
- data/spec/views/admin/users/destroy.js.haml_spec.rb +6 -6
- data/spec/views/admin/users/edit.js.haml_spec.rb +7 -9
- data/spec/views/admin/users/index.haml_spec.rb +4 -5
- data/spec/views/admin/users/index.js.haml_spec.rb +6 -8
- data/spec/views/admin/users/new.js.haml_spec.rb +4 -6
- data/spec/views/admin/users/reactivate.js.haml_spec.rb +4 -4
- data/spec/views/admin/users/show.haml_spec.rb +0 -1
- data/spec/views/admin/users/suspend.js.haml_spec.rb +4 -4
- data/spec/views/admin/users/update.js.haml_spec.rb +6 -7
- data/spec/views/application/auto_complete.haml_spec.rb +12 -14
- data/spec/views/authentications/new.haml_spec.rb +6 -7
- data/spec/views/campaigns/_edit.haml_spec.rb +9 -9
- data/spec/views/campaigns/_new.haml_spec.rb +8 -8
- data/spec/views/campaigns/create.js.haml_spec.rb +11 -12
- data/spec/views/campaigns/destroy.js.haml_spec.rb +7 -8
- data/spec/views/campaigns/edit.js.haml_spec.rb +12 -20
- data/spec/views/campaigns/index.haml_spec.rb +6 -7
- data/spec/views/campaigns/index.js.haml_spec.rb +9 -10
- data/spec/views/campaigns/new.js.haml_spec.rb +7 -8
- data/spec/views/campaigns/show.haml_spec.rb +12 -13
- data/spec/views/campaigns/update.js.haml_spec.rb +16 -16
- data/spec/views/comments/edit.js.haml_spec.rb +7 -7
- data/spec/views/contacts/_edit.haml_spec.rb +21 -21
- data/spec/views/contacts/_new.haml_spec.rb +12 -13
- data/spec/views/contacts/create.js.haml_spec.rb +12 -13
- data/spec/views/contacts/destroy.js.haml_spec.rb +6 -7
- data/spec/views/contacts/edit.js.haml_spec.rb +15 -17
- data/spec/views/contacts/index.haml_spec.rb +6 -7
- data/spec/views/contacts/index.js.html_spec.rb +7 -8
- data/spec/views/contacts/new.js.haml_spec.rb +8 -9
- data/spec/views/contacts/show.haml_spec.rb +9 -10
- data/spec/views/contacts/update.js.haml_spec.rb +26 -26
- data/spec/views/home/index.haml_spec.rb +4 -5
- data/spec/views/home/index.js.haml_spec.rb +6 -7
- data/spec/views/home/options.js.haml_spec.rb +10 -10
- data/spec/views/leads/_convert.haml_spec.rb +5 -6
- data/spec/views/leads/_edit.haml_spec.rb +13 -13
- data/spec/views/leads/_new.haml_spec.rb +11 -11
- data/spec/views/leads/_sidebar_show.haml_spec.rb +9 -9
- data/spec/views/leads/convert.js.haml_spec.rb +16 -17
- data/spec/views/leads/create.js.haml_spec.rb +16 -17
- data/spec/views/leads/destroy.js.haml_spec.rb +10 -11
- data/spec/views/leads/edit.js.haml_spec.rb +16 -17
- data/spec/views/leads/index.haml_spec.rb +7 -8
- data/spec/views/leads/index.js.haml_spec.rb +10 -11
- data/spec/views/leads/new.js.haml_spec.rb +8 -9
- data/spec/views/leads/promote.js.haml_spec.rb +30 -31
- data/spec/views/leads/reject.js.haml_spec.rb +10 -11
- data/spec/views/leads/show.haml_spec.rb +7 -8
- data/spec/views/leads/update.js.haml_spec.rb +28 -29
- data/spec/views/opportunities/_edit.haml_spec.rb +19 -19
- data/spec/views/opportunities/_new.haml_spec.rb +10 -10
- data/spec/views/opportunities/create.js.haml_spec.rb +19 -20
- data/spec/views/opportunities/destroy.js.haml_spec.rb +14 -15
- data/spec/views/opportunities/edit.js.haml_spec.rb +14 -16
- data/spec/views/opportunities/index.haml_spec.rb +6 -7
- data/spec/views/opportunities/index.js.haml_spec.rb +7 -8
- data/spec/views/opportunities/new.js.haml_spec.rb +8 -9
- data/spec/views/opportunities/show.haml_spec.rb +9 -10
- data/spec/views/opportunities/update.js.haml_spec.rb +35 -35
- data/spec/views/tasks/_edit.haml_spec.rb +9 -9
- data/spec/views/tasks/complete.js.haml_spec.rb +11 -12
- data/spec/views/tasks/create.js.haml_spec.rb +29 -31
- data/spec/views/tasks/destroy.js.haml_spec.rb +8 -8
- data/spec/views/tasks/edit.js.haml_spec.rb +12 -15
- data/spec/views/tasks/index.haml_spec.rb +7 -7
- data/spec/views/tasks/new.js.haml_spec.rb +7 -8
- data/spec/views/tasks/uncomplete.js.haml_spec.rb +6 -6
- data/spec/views/tasks/update.js.haml_spec.rb +41 -44
- data/spec/views/users/avatar.js.haml_spec.rb +7 -8
- data/spec/views/users/change_password.js.haml_spec.rb +9 -10
- data/spec/views/users/edit.js.haml_spec.rb +7 -8
- data/spec/views/users/password.js.haml_spec.rb +8 -9
- data/spec/views/users/update.js.haml_spec.rb +6 -7
- data/spec/views/users/upload_avatar.js.haml_spec.rb +9 -9
- data/vendor/assets/javascripts/jquery_timeago/index.js +2 -0
- data/vendor/assets/javascripts/jquery_timeago/jquery.timeago.es-CL.js +18 -0
- data/vendor/assets/javascripts/jquery_timeago/jquery.timeago.nl.js +20 -0
- data/vendor/assets/javascripts/jquery_ui_datepicker/jquery-ui-timepicker-es-CL.js +20 -0
- data/vendor/assets/javascripts/jquery_ui_datepicker/jquery.ui.datepicker-es-CL.js +23 -0
- data/vendor/assets/javascripts/jquery_ui_datepicker/jquery.ui.datepicker-nl.js +21 -0
- data/vendor/assets/stylesheets/{jquery-ui.custom.css → jquery-ui.custom.scss} +52 -51
- data/vendor/gems/globby-0.1.2/LICENSE.txt +20 -0
- data/vendor/gems/globby-0.1.2/README.md +65 -0
- data/vendor/gems/globby-0.1.2/Rakefile +9 -0
- data/vendor/gems/globby-0.1.2/lib/globby.rb +47 -0
- data/vendor/gems/globby-0.1.2/lib/globby/glob.rb +90 -0
- data/vendor/gems/globby-0.1.2/lib/globby/globject.rb +18 -0
- data/vendor/gems/globby-0.1.2/lib/globby/result.rb +20 -0
- data/vendor/gems/globby-0.1.2/spec/gitignore_spec.rb +109 -0
- data/vendor/gems/globby-0.1.2/spec/globby_spec.rb +93 -0
- metadata +177 -55
- data/Gemfile.ci +0 -13
- data/config/initializers/sass.rb +0 -18
- data/lib/country_select.rb +0 -570
- data/lib/fat_free_crm/plugin.rb +0 -94
@@ -6,89 +6,83 @@
|
|
6
6
|
require 'spec_helper'
|
7
7
|
|
8
8
|
describe CustomFieldDatePair do
|
9
|
-
|
10
9
|
describe "render_value" do
|
11
|
-
|
12
10
|
before(:each) do
|
13
|
-
@from = CustomFieldDatePair.new(:
|
14
|
-
@to = CustomFieldDatePair.new(:
|
15
|
-
@from.
|
11
|
+
@from = CustomFieldDatePair.new(name: 'cf_event_from')
|
12
|
+
@to = CustomFieldDatePair.new(name: 'cf_event_to')
|
13
|
+
allow(@from).to receive(:paired_with).and_return(@to)
|
16
14
|
@today = Date.today
|
17
15
|
@today_str = @today.strftime(I18n.t("date.formats.mmddyy"))
|
18
16
|
end
|
19
|
-
|
17
|
+
|
20
18
|
it "should be from..." do
|
21
|
-
foo = double(:
|
22
|
-
@from.render_value(foo).
|
19
|
+
foo = double(cf_event_from: @today, cf_event_to: nil)
|
20
|
+
expect(@from.render_value(foo)).to eq("From #{@today_str}")
|
23
21
|
end
|
24
|
-
|
22
|
+
|
25
23
|
it "should be until..." do
|
26
|
-
foo = double(:
|
27
|
-
@from.render_value(foo).
|
24
|
+
foo = double(cf_event_from: nil, cf_event_to: @today)
|
25
|
+
expect(@from.render_value(foo)).to eq("Until #{@today_str}")
|
28
26
|
end
|
29
|
-
|
27
|
+
|
30
28
|
it "should be from ... to" do
|
31
|
-
foo = double(:
|
32
|
-
@from.render_value(foo).
|
29
|
+
foo = double(cf_event_from: @today, cf_event_to: @today)
|
30
|
+
expect(@from.render_value(foo)).to eq("From #{@today_str} to #{@today_str}")
|
33
31
|
end
|
34
|
-
|
32
|
+
|
35
33
|
it "should be empty string" do
|
36
|
-
foo = double(:
|
37
|
-
@from.render_value(foo).
|
34
|
+
foo = double(cf_event_from: nil, cf_event_to: nil)
|
35
|
+
expect(@from.render_value(foo)).to eq("")
|
38
36
|
end
|
39
|
-
|
40
37
|
end
|
41
38
|
|
42
39
|
describe "custom_validator" do
|
43
|
-
|
44
40
|
before(:each) do
|
45
|
-
@from = CustomFieldDatePair.new(:
|
46
|
-
@to = CustomFieldDatePair.new(:
|
47
|
-
CustomFieldPair.
|
41
|
+
@from = CustomFieldDatePair.new(name: 'cf_event_from')
|
42
|
+
@to = CustomFieldDatePair.new(name: 'cf_event_to', pair_id: 1)
|
43
|
+
allow(CustomFieldPair).to receive(:find).and_return(@from)
|
48
44
|
@today = Date.today
|
49
45
|
@today_str = @today.strftime(I18n.t("date.formats.mmddyy"))
|
50
46
|
end
|
51
|
-
|
47
|
+
|
52
48
|
it "when from is nil it should be valid" do
|
53
|
-
foo = double(:
|
54
|
-
foo.
|
49
|
+
foo = double(cf_event_from: nil, cf_event_to: @today)
|
50
|
+
expect(foo).not_to receive(:errors)
|
55
51
|
@to.custom_validator(foo)
|
56
52
|
end
|
57
53
|
|
58
54
|
it "when to is nil it should be valid" do
|
59
|
-
foo = double(:
|
60
|
-
foo.
|
55
|
+
foo = double(cf_event_from: @today, cf_event_to: nil)
|
56
|
+
expect(foo).not_to receive(:errors)
|
61
57
|
@to.custom_validator(foo)
|
62
58
|
end
|
63
|
-
|
59
|
+
|
64
60
|
it "when from <= to it should be valid" do
|
65
|
-
foo = double(:
|
66
|
-
foo.
|
61
|
+
foo = double(cf_event_from: @today, cf_event_to: @today)
|
62
|
+
expect(foo).not_to receive(:errors)
|
67
63
|
@to.custom_validator(foo)
|
68
64
|
end
|
69
|
-
|
65
|
+
|
70
66
|
it "when from > to it should not be valid" do
|
71
|
-
foo = double(:
|
72
|
-
err = double(:errors); err.
|
73
|
-
foo.
|
67
|
+
foo = double(cf_event_from: @today, cf_event_to: @today - 1.day)
|
68
|
+
err = double(:errors); allow(err).to receive(:add)
|
69
|
+
expect(foo).to receive(:errors).and_return(err)
|
74
70
|
@to.custom_validator(foo)
|
75
71
|
end
|
76
|
-
|
72
|
+
|
77
73
|
it "should ignore validation when called on from" do
|
78
|
-
foo = double(:
|
79
|
-
foo.
|
80
|
-
CustomFieldPair.
|
74
|
+
foo = double(cf_event_from: @today, cf_event_to: @today - 1.day)
|
75
|
+
expect(foo).not_to receive(:errors)
|
76
|
+
expect(CustomFieldPair).not_to receive(:find)
|
81
77
|
@from.custom_validator(foo)
|
82
78
|
end
|
83
79
|
|
84
80
|
it "should call custom field validation on super class" do
|
85
|
-
from = CustomFieldDatePair.new(:
|
86
|
-
foo = double(:
|
87
|
-
err = double(:errors); err.
|
88
|
-
foo.
|
81
|
+
from = CustomFieldDatePair.new(name: 'cf_event_from', required: true)
|
82
|
+
foo = double(cf_event_from: nil)
|
83
|
+
err = double(:errors); allow(err).to receive(:add)
|
84
|
+
expect(foo).to receive(:errors).and_return(err)
|
89
85
|
from.custom_validator(foo)
|
90
86
|
end
|
91
|
-
|
92
87
|
end
|
93
|
-
|
94
88
|
end
|
@@ -6,77 +6,69 @@
|
|
6
6
|
require 'spec_helper'
|
7
7
|
|
8
8
|
describe CustomFieldPair do
|
9
|
-
|
10
9
|
class CustomFieldFooPair
|
11
10
|
end
|
12
11
|
|
13
12
|
it "should respond to pair" do
|
14
|
-
CustomFieldPair.new.
|
13
|
+
expect(CustomFieldPair.new).to respond_to(:pair)
|
15
14
|
end
|
16
15
|
|
17
16
|
describe "create_pair" do
|
18
|
-
|
19
17
|
before(:each) do
|
20
|
-
@field = {'as' => 'foopair', 'field_group_id' => 1, 'label' => 'Event'}
|
21
|
-
@pair1 = {'name' => 'pair1'}
|
22
|
-
@pair2 = {'name' => 'pair2'}
|
23
|
-
@params = { 'field' => @field, 'pair' => {'0' => @pair1, '1' => @pair2} }
|
18
|
+
@field = { 'as' => 'foopair', 'field_group_id' => 1, 'label' => 'Event' }
|
19
|
+
@pair1 = { 'name' => 'pair1' }
|
20
|
+
@pair2 = { 'name' => 'pair2' }
|
21
|
+
@params = { 'field' => @field, 'pair' => { '0' => @pair1, '1' => @pair2 } }
|
24
22
|
end
|
25
23
|
|
26
24
|
it "should create the pair" do
|
27
25
|
params1 = @field.merge(@pair1)
|
28
|
-
foo1 = double(:
|
29
|
-
CustomFieldFooPair.
|
26
|
+
foo1 = double(id: 3, required: true, disabled: 'false')
|
27
|
+
expect(CustomFieldFooPair).to receive(:create).with(params1).and_return(foo1)
|
30
28
|
params2 = @field.merge(@pair2).merge('pair_id' => 3, 'required' => true, 'disabled' => 'false')
|
31
|
-
foo2 = double(:
|
32
|
-
CustomFieldFooPair.
|
29
|
+
foo2 = double(id: 5)
|
30
|
+
expect(CustomFieldFooPair).to receive(:create).with(params2).and_return(foo2)
|
33
31
|
|
34
|
-
CustomFieldPair.create_pair(@params).
|
32
|
+
expect(CustomFieldPair.create_pair(@params)).to eq([foo1, foo2])
|
35
33
|
end
|
36
|
-
|
37
34
|
end
|
38
35
|
|
39
36
|
describe "update_pair" do
|
40
|
-
|
41
37
|
before(:each) do
|
42
|
-
@field = {'as' => 'foopair', 'field_group_id' => 1, 'label' => 'Event'}
|
43
|
-
@pair1 = {'name' => 'pair1'}
|
44
|
-
@pair2 = {'name' => 'pair2'}
|
45
|
-
@params = { 'id' => '3', 'field' => @field, 'pair' => {'0' => @pair1, '1' => @pair2} }
|
38
|
+
@field = { 'as' => 'foopair', 'field_group_id' => 1, 'label' => 'Event' }
|
39
|
+
@pair1 = { 'name' => 'pair1' }
|
40
|
+
@pair2 = { 'name' => 'pair2' }
|
41
|
+
@params = { 'id' => '3', 'field' => @field, 'pair' => { '0' => @pair1, '1' => @pair2 } }
|
46
42
|
end
|
47
43
|
|
48
44
|
it "should update the pair" do
|
49
|
-
foo1 = double(:
|
50
|
-
foo1.
|
45
|
+
foo1 = double(required: true, disabled: 'false')
|
46
|
+
expect(foo1).to receive(:update_attributes).with(@field.merge(@pair1))
|
51
47
|
foo2 = double
|
52
|
-
foo2.
|
53
|
-
foo1.
|
54
|
-
CustomFieldPair.
|
48
|
+
expect(foo2).to receive(:update_attributes).with(@field.merge(@pair2).merge('required' => true, 'disabled' => 'false'))
|
49
|
+
expect(foo1).to receive(:paired_with).and_return(foo2)
|
50
|
+
expect(CustomFieldPair).to receive(:find).with('3').and_return(foo1)
|
55
51
|
|
56
|
-
CustomFieldPair.update_pair(@params).
|
52
|
+
expect(CustomFieldPair.update_pair(@params)).to eq([foo1, foo2])
|
57
53
|
end
|
58
|
-
|
59
54
|
end
|
60
55
|
|
61
56
|
describe "paired_with" do
|
62
|
-
|
63
57
|
before(:each) do
|
64
|
-
@field1 = CustomFieldDatePair.new(:
|
65
|
-
@field2 = CustomFieldDatePair.new(:
|
58
|
+
@field1 = CustomFieldDatePair.new(name: 'cf_event_from')
|
59
|
+
@field2 = CustomFieldDatePair.new(name: 'cf_event_to')
|
66
60
|
end
|
67
61
|
|
68
62
|
it "should return the 2nd field" do
|
69
|
-
@field1.
|
70
|
-
@field1.paired_with.
|
63
|
+
expect(@field1).to receive(:pair).and_return(@field2)
|
64
|
+
expect(@field1.paired_with).to eq(@field2)
|
71
65
|
end
|
72
66
|
|
73
67
|
it "should return the 1st field" do
|
74
|
-
@field2.
|
75
|
-
@field2.
|
76
|
-
CustomFieldPair.
|
77
|
-
@field2.paired_with.
|
68
|
+
expect(@field2).to receive(:pair).and_return(nil)
|
69
|
+
expect(@field2).to receive(:id).and_return(1)
|
70
|
+
expect(CustomFieldPair).to receive(:where).with(pair_id: 1).and_return([@field1])
|
71
|
+
expect(@field2.paired_with).to eq(@field1)
|
78
72
|
end
|
79
|
-
|
80
73
|
end
|
81
|
-
|
82
74
|
end
|
@@ -24,108 +24,102 @@
|
|
24
24
|
# updated_at :datetime
|
25
25
|
#
|
26
26
|
|
27
|
-
|
28
27
|
require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
|
29
28
|
|
30
29
|
describe CustomField do
|
31
|
-
|
32
30
|
it "should add a column to the database" do
|
33
|
-
CustomField.connection.
|
34
|
-
|
35
|
-
Contact.
|
36
|
-
Contact.
|
31
|
+
expect(CustomField.connection).to receive(:add_column)
|
32
|
+
.with("contacts", "cf_test_field", 'string', {})
|
33
|
+
expect(Contact).to receive(:reset_column_information)
|
34
|
+
expect(Contact).to receive(:serialize_custom_fields!)
|
37
35
|
|
38
36
|
FactoryGirl.create(:custom_field,
|
39
|
-
:
|
40
|
-
:
|
41
|
-
:
|
42
|
-
:
|
37
|
+
as: "string",
|
38
|
+
name: "cf_test_field",
|
39
|
+
label: "Test Field",
|
40
|
+
field_group: FactoryGirl.create(:field_group, klass_name: "Contact"))
|
43
41
|
end
|
44
42
|
|
45
43
|
it "should generate a unique column name for a custom field" do
|
46
|
-
field_group = FactoryGirl.build(:field_group, :
|
47
|
-
c = FactoryGirl.build(:custom_field, :
|
44
|
+
field_group = FactoryGirl.build(:field_group, klass_name: "Contact")
|
45
|
+
c = FactoryGirl.build(:custom_field, label: "Test Field", field_group: field_group)
|
48
46
|
|
49
47
|
columns = []
|
50
48
|
%w(cf_test_field cf_test_field_2 cf_test_field_3 cf_test_field_4).each do |field|
|
51
|
-
c.send(:generate_column_name).
|
52
|
-
|
49
|
+
expect(c.send(:generate_column_name)).to eq(field)
|
50
|
+
allow(Contact).to receive(:column_names).and_return(columns << field)
|
53
51
|
end
|
54
|
-
|
55
52
|
end
|
56
53
|
|
57
54
|
it "should evaluate the safety of database transitions" do
|
58
|
-
c = FactoryGirl.build(:custom_field, :
|
59
|
-
c.send(:db_transition_safety, c.as, "email").
|
60
|
-
c.send(:db_transition_safety, c.as, "text").
|
61
|
-
c.send(:db_transition_safety, c.as, "datetime").
|
62
|
-
|
63
|
-
c = FactoryGirl.build(:custom_field, :
|
64
|
-
c.send(:db_transition_safety, c.as, "date").
|
65
|
-
c.send(:db_transition_safety, c.as, "url").
|
55
|
+
c = FactoryGirl.build(:custom_field, as: "string")
|
56
|
+
expect(c.send(:db_transition_safety, c.as, "email")).to eq(:null)
|
57
|
+
expect(c.send(:db_transition_safety, c.as, "text")).to eq(:safe)
|
58
|
+
expect(c.send(:db_transition_safety, c.as, "datetime")).to eq(:unsafe)
|
59
|
+
|
60
|
+
c = FactoryGirl.build(:custom_field, as: "datetime")
|
61
|
+
expect(c.send(:db_transition_safety, c.as, "date")).to eq(:safe)
|
62
|
+
expect(c.send(:db_transition_safety, c.as, "url")).to eq(:unsafe)
|
66
63
|
end
|
67
64
|
|
68
65
|
it "should return a safe list of types for the 'as' select options" do
|
69
|
-
{"email" => %w(check_boxes text string email url tel select
|
70
|
-
|
71
|
-
c = FactoryGirl.build(:custom_field, :
|
66
|
+
{ "email" => %w(check_boxes text string email url tel select radio_buttons),
|
67
|
+
"integer" => %w(integer float) }.each do |type, expected_arr|
|
68
|
+
c = FactoryGirl.build(:custom_field, as: type)
|
72
69
|
opts = c.available_as
|
73
|
-
opts.map(&:first).
|
70
|
+
expect(opts.map(&:first)).to match_array(expected_arr)
|
74
71
|
end
|
75
72
|
end
|
76
73
|
|
77
74
|
it "should change a column's type for safe transitions" do
|
78
|
-
CustomField.connection.
|
79
|
-
|
80
|
-
CustomField.connection.
|
81
|
-
|
82
|
-
Contact.
|
83
|
-
Contact.
|
84
|
-
|
85
|
-
field_group = FactoryGirl.create(:field_group, :
|
75
|
+
expect(CustomField.connection).to receive(:add_column)
|
76
|
+
.with("contacts", "cf_test_field", 'string', {})
|
77
|
+
expect(CustomField.connection).to receive(:change_column)
|
78
|
+
.with("contacts", "cf_test_field", 'text', {})
|
79
|
+
expect(Contact).to receive(:reset_column_information).twice
|
80
|
+
expect(Contact).to receive(:serialize_custom_fields!).twice
|
81
|
+
|
82
|
+
field_group = FactoryGirl.create(:field_group, klass_name: "Contact")
|
86
83
|
c = FactoryGirl.create(:custom_field,
|
87
|
-
:
|
88
|
-
:
|
89
|
-
:
|
90
|
-
:
|
84
|
+
label: "Test Field",
|
85
|
+
name: nil,
|
86
|
+
as: "email",
|
87
|
+
field_group: field_group)
|
91
88
|
c.as = "text"
|
92
89
|
c.save
|
93
90
|
end
|
94
91
|
|
95
92
|
describe "in case a new custom field was added by a different instance" do
|
96
93
|
it "should refresh column info and retry on assignment error" do
|
97
|
-
Contact.
|
94
|
+
expect(Contact).to receive(:reset_column_information)
|
98
95
|
|
99
|
-
|
96
|
+
expect { Contact.new cf_unknown_field: 123 }.to raise_error(ActiveRecord::UnknownAttributeError)
|
100
97
|
end
|
101
98
|
|
102
99
|
it "should refresh column info and retry on attribute error" do
|
103
|
-
Contact.
|
104
|
-
Contact.
|
100
|
+
expect(Contact).to receive(:reset_column_information)
|
101
|
+
expect(Contact).to receive(:serialize_custom_fields!)
|
105
102
|
|
106
103
|
contact = FactoryGirl.build(:contact)
|
107
|
-
contact.cf_another_new_field.
|
104
|
+
expect(contact.cf_another_new_field).to eq(nil)
|
108
105
|
end
|
109
106
|
end
|
110
107
|
|
111
108
|
describe "validation" do
|
112
|
-
|
113
109
|
it "should have errors if custom field is required" do
|
114
|
-
event = CustomField.new(:
|
115
|
-
foo = double(:
|
116
|
-
err = double(:errors); err.
|
117
|
-
foo.
|
110
|
+
event = CustomField.new(name: 'cf_event', required: true)
|
111
|
+
foo = double(cf_event: nil)
|
112
|
+
err = double(:errors); allow(err).to receive(:add)
|
113
|
+
expect(foo).to receive(:errors).and_return(err)
|
118
114
|
event.custom_validator(foo)
|
119
115
|
end
|
120
|
-
|
116
|
+
|
121
117
|
it "should have errors if custom field is longer than maxlength" do
|
122
|
-
event = CustomField.new(:
|
123
|
-
foo = double(:
|
124
|
-
err = double(:errors); err.
|
125
|
-
foo.
|
118
|
+
event = CustomField.new(name: 'cf_event', maxlength: 5)
|
119
|
+
foo = double(cf_event: "This is too long")
|
120
|
+
err = double(:errors); allow(err).to receive(:add)
|
121
|
+
expect(foo).to receive(:errors).and_return(err)
|
126
122
|
event.custom_validator(foo)
|
127
123
|
end
|
128
|
-
|
129
124
|
end
|
130
|
-
|
131
125
|
end
|
@@ -27,41 +27,39 @@
|
|
27
27
|
require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
|
28
28
|
|
29
29
|
describe Field do
|
30
|
-
|
31
30
|
it "should create a new instance given valid attributes" do
|
32
31
|
Field.create!(
|
33
|
-
:
|
34
|
-
:
|
35
|
-
:
|
36
|
-
:
|
37
|
-
:
|
32
|
+
name: 'skype_address',
|
33
|
+
label: 'Skype address',
|
34
|
+
as: 'string',
|
35
|
+
maxlength: 220,
|
36
|
+
position: 10
|
38
37
|
)
|
39
38
|
end
|
40
39
|
|
41
|
-
|
42
40
|
it "should return a list of field types" do
|
43
|
-
Field.field_types['string'].
|
41
|
+
expect(Field.field_types['string']).to eq('klass' => 'CustomField', 'type' => 'string')
|
44
42
|
end
|
45
43
|
|
46
44
|
it "should return a hash of input options" do
|
47
|
-
Field.new.input_options.
|
45
|
+
expect(Field.new.input_options).to be_a(Hash)
|
48
46
|
end
|
49
47
|
|
50
48
|
it "should be able to display a empty multi_select value" do
|
51
49
|
field = Field.new(
|
52
|
-
:
|
53
|
-
:
|
50
|
+
label: "Availability",
|
51
|
+
name: "availability"
|
54
52
|
)
|
55
53
|
object = double('Object')
|
56
54
|
|
57
55
|
# as | value | expected
|
58
56
|
[["check_boxes", [1, 2, 3], "1, 2<br />3"],
|
59
|
-
|
57
|
+
%w(checkbox 0 no),
|
60
58
|
["checkbox", 1, "yes"],
|
61
|
-
["date", DateTime.new(2011,4,19), DateTime.new(2011,4,19).strftime(I18n.t("date.formats.mmddyy"))
|
59
|
+
["date", DateTime.new(2011, 4, 19), DateTime.new(2011, 4, 19).strftime(I18n.t("date.formats.mmddyy"))]].each do |as, value, expected|
|
62
60
|
field.as = as
|
63
|
-
object.
|
64
|
-
field.render_value(object).
|
61
|
+
allow(object).to receive(field.name).and_return(value)
|
62
|
+
expect(field.render_value(object)).to eq(expected)
|
65
63
|
end
|
66
64
|
end
|
67
65
|
end
|