fat_free_crm 0.20.0 → 0.21.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/CHANGELOG.md +170 -0
- data/README.md +3 -6
- data/app/assets/config/manifest.js +3 -0
- data/app/helpers/accounts_helper.rb +2 -0
- data/app/helpers/application_helper.rb +22 -3
- data/app/helpers/tasks_helper.rb +1 -2
- data/app/models/entities/account.rb +1 -1
- data/app/models/entities/campaign.rb +1 -1
- data/app/models/entities/contact.rb +1 -1
- data/app/models/entities/lead.rb +1 -1
- data/app/models/entities/opportunity.rb +1 -1
- data/app/models/polymorphic/avatar.rb +1 -30
- data/app/models/polymorphic/task.rb +2 -0
- data/app/views/home/index.xls.builder +1 -0
- data/app/views/shared/_address.html.haml +1 -1
- data/config/application.rb +13 -0
- data/config/environments/development.rb +3 -0
- data/config/puma.rb +2 -2
- data/config/storage.yml +34 -0
- data/db/migrate/20100928030617_drop_openid_tables.rb +2 -1
- data/db/migrate/20230526211831_create_active_storage_tables.active_storage.rb +51 -0
- data/db/migrate/20230526212613_convert_to_active_storage.rb +91 -0
- data/db/schema.rb +65 -35
- data/db/seeds/fields.rb +7 -21
- data/lib/development_tasks/license.rake +10 -10
- data/lib/fat_free_crm/errors.rb +2 -10
- data/lib/fat_free_crm/exceptions.rb +1 -0
- data/lib/fat_free_crm/fields.rb +4 -5
- data/lib/fat_free_crm/gem_dependencies.rb +0 -1
- data/lib/fat_free_crm/i18n.rb +1 -1
- data/lib/fat_free_crm/version.rb +2 -2
- metadata +16 -279
- data/.docker/nginx/sites-enabled/ffcrm.conf +0 -8
- data/.github/workflows/brakeman-analysis.yml +0 -46
- data/.github/workflows/rubocop-analysis.yml +0 -40
- data/.github/workflows/ruby.yml +0 -52
- data/.gitignore +0 -39
- data/.rubocop.yml +0 -73
- data/.rubocop_todo.yml +0 -286
- data/.teatro.yml +0 -3
- data/.travis.yml +0 -60
- data/CONTRIBUTORS.md +0 -135
- data/Capfile +0 -27
- data/Dockerfile +0 -51
- data/Gemfile +0 -106
- data/Gemfile.lock +0 -529
- data/Guardfile +0 -26
- data/Procfile +0 -1
- data/SECURITY.md +0 -11
- data/Vagrantfile +0 -92
- data/custom_plan.rb +0 -11
- data/docker-compose.yml +0 -27
- data/fat_free_crm.gemspec +0 -62
- data/lib/tasks/.gitkeep +0 -0
- data/lib/tasks/.gitkeep~master +0 -0
- data/script/rails +0 -8
- data/spec/controllers/admin/groups_controller_spec.rb +0 -11
- data/spec/controllers/admin/users_controller_spec.rb +0 -251
- data/spec/controllers/applications_controller_spec.rb +0 -43
- data/spec/controllers/comments_controller_spec.rb +0 -195
- data/spec/controllers/emails_controller_spec.rb +0 -37
- data/spec/controllers/entities/accounts_controller_spec.rb +0 -607
- data/spec/controllers/entities/campaigns_controller_spec.rb +0 -645
- data/spec/controllers/entities/contacts_controller_spec.rb +0 -705
- data/spec/controllers/entities/leads_controller_spec.rb +0 -1009
- data/spec/controllers/entities/opportunities_controller_spec.rb +0 -904
- data/spec/controllers/entities_controller_spec.rb +0 -47
- data/spec/controllers/home_controller_spec.rb +0 -235
- data/spec/controllers/lists_controller_spec.rb +0 -11
- data/spec/controllers/tasks_controller_spec.rb +0 -517
- data/spec/controllers/users_controller_spec.rb +0 -375
- data/spec/factories/account_factories.rb +0 -40
- data/spec/factories/campaign_factories.rb +0 -30
- data/spec/factories/contact_factories.rb +0 -45
- data/spec/factories/field_factories.rb +0 -40
- data/spec/factories/lead_factories.rb +0 -36
- data/spec/factories/list_factories.rb +0 -13
- data/spec/factories/opportunity_factories.rb +0 -39
- data/spec/factories/sequences.rb +0 -32
- data/spec/factories/setting_factories.rb +0 -15
- data/spec/factories/shared_factories.rb +0 -70
- data/spec/factories/subscription_factories.rb +0 -13
- data/spec/factories/tag_factories.rb +0 -12
- data/spec/factories/task_factories.rb +0 -29
- data/spec/factories/user_factories.rb +0 -66
- data/spec/features/acceptance_helper.rb +0 -11
- data/spec/features/accounts_spec.rb +0 -126
- data/spec/features/admin/groups_spec.rb +0 -31
- data/spec/features/admin/users_spec.rb +0 -40
- data/spec/features/campaigns_spec.rb +0 -104
- data/spec/features/contacts_spec.rb +0 -134
- data/spec/features/dashboard_spec.rb +0 -67
- data/spec/features/devise/sign_in_spec.rb +0 -58
- data/spec/features/devise/sign_up_spec.rb +0 -36
- data/spec/features/leads_spec.rb +0 -138
- data/spec/features/opportunities_overview_spec.rb +0 -88
- data/spec/features/opportunities_spec.rb +0 -132
- data/spec/features/support/autocomlete_helper.rb +0 -17
- data/spec/features/support/browser.rb +0 -28
- data/spec/features/support/headless.rb +0 -19
- data/spec/features/support/paths.rb +0 -48
- data/spec/features/support/selector_helpers.rb +0 -36
- data/spec/features/tasks_spec.rb +0 -94
- data/spec/fixtures/rails.png +0 -0
- data/spec/helpers/accounts_helper_spec.rb +0 -73
- data/spec/helpers/admin/field_groups_helper_spec.rb +0 -20
- data/spec/helpers/admin/plugins_helper_spec.rb +0 -11
- data/spec/helpers/admin/settings_helper_spec.rb +0 -11
- data/spec/helpers/admin/users_helper_spec.rb +0 -11
- data/spec/helpers/application_helper_spec.rb +0 -86
- data/spec/helpers/authentications_helper_spec.rb +0 -16
- data/spec/helpers/campaigns_helper_spec.rb +0 -16
- data/spec/helpers/comments_helper_spec.rb +0 -16
- data/spec/helpers/contacts_helper_spec.rb +0 -16
- data/spec/helpers/emails_helper_spec.rb +0 -11
- data/spec/helpers/fields_helper_spec.rb +0 -12
- data/spec/helpers/groups_helper_spec.rb +0 -21
- data/spec/helpers/home_helper_spec.rb +0 -16
- data/spec/helpers/leads_helper_spec.rb +0 -16
- data/spec/helpers/lists_helper_spec.rb +0 -21
- data/spec/helpers/opportunities_helper_spec.rb +0 -16
- data/spec/helpers/passwords_helper_spec.rb +0 -16
- data/spec/helpers/tasks_helper_spec.rb +0 -20
- data/spec/helpers/users_helper_spec.rb +0 -39
- data/spec/lib/comment_extensions_spec.rb +0 -42
- data/spec/lib/core_ext/string_spec.rb +0 -23
- data/spec/lib/errors_spec.rb +0 -32
- data/spec/lib/fields_spec.rb +0 -101
- data/spec/lib/mail_processor/base_spec.rb +0 -169
- data/spec/lib/mail_processor/comment_replies_spec.rb +0 -70
- data/spec/lib/mail_processor/dropbox_spec.rb +0 -306
- data/spec/lib/mail_processor/sample_emails/dropbox.rb +0 -173
- data/spec/lib/permissions_spec.rb +0 -155
- data/spec/lib/secret_token_generator_spec.rb +0 -69
- data/spec/lib/view_factory_spec.rb +0 -69
- data/spec/mailers/devise_mailer_spec.rb +0 -35
- data/spec/mailers/subscription_mailer_spec.rb +0 -48
- data/spec/mailers/user_mailer_spec.rb +0 -115
- data/spec/models/entities/account_contact_spec.rb +0 -34
- data/spec/models/entities/account_opportunity_spec.rb +0 -34
- data/spec/models/entities/account_spec.rb +0 -206
- data/spec/models/entities/campaign_spec.rb +0 -131
- data/spec/models/entities/contact_opportunity_spec.rb +0 -34
- data/spec/models/entities/contact_spec.rb +0 -314
- data/spec/models/entities/lead_spec.rb +0 -102
- data/spec/models/entities/opportunity_spec.rb +0 -299
- data/spec/models/fields/custom_field_date_pair_spec.rb +0 -92
- data/spec/models/fields/custom_field_pair_spec.rb +0 -76
- data/spec/models/fields/custom_field_spec.rb +0 -129
- data/spec/models/fields/field_group_spec.rb +0 -29
- data/spec/models/fields/field_spec.rb +0 -69
- data/spec/models/list_spec.rb +0 -19
- data/spec/models/observers/entity_observer_spec.rb +0 -74
- data/spec/models/polymorphic/address_spec.rb +0 -34
- data/spec/models/polymorphic/avatar_spec.rb +0 -46
- data/spec/models/polymorphic/comment_spec.rb +0 -45
- data/spec/models/polymorphic/email_spec.rb +0 -53
- data/spec/models/polymorphic/task_spec.rb +0 -395
- data/spec/models/polymorphic/version_spec.rb +0 -241
- data/spec/models/setting_spec.rb +0 -77
- data/spec/models/users/abilities/user_ability_spec.rb +0 -70
- data/spec/models/users/group_spec.rb +0 -11
- data/spec/models/users/permission_spec.rb +0 -58
- data/spec/models/users/preference_spec.rb +0 -71
- data/spec/models/users/user_spec.rb +0 -238
- data/spec/routing/accounts_routing_spec.rb +0 -60
- data/spec/routing/admin/users_routing_spec.rb +0 -40
- data/spec/routing/campaigns_routing_spec.rb +0 -64
- data/spec/routing/comments_routing_spec.rb +0 -32
- data/spec/routing/contacts_routing_spec.rb +0 -60
- data/spec/routing/emails_routing_spec.rb +0 -40
- data/spec/routing/leads_routing_spec.rb +0 -88
- data/spec/routing/opportunities_routing_spec.rb +0 -64
- data/spec/routing/tasks_routing_spec.rb +0 -68
- data/spec/routing/users_routing_spec.rb +0 -106
- data/spec/shared/controllers.rb +0 -99
- data/spec/shared/models.rb +0 -141
- data/spec/spec_helper.rb +0 -117
- data/spec/support/assert_select.rb +0 -167
- data/spec/support/devise_helpers.rb +0 -28
- data/spec/support/feature_helpers.rb +0 -32
- data/spec/support/macros.rb +0 -49
- data/spec/support/mail_processor_mocks.rb +0 -37
- data/spec/support/uploaded_file.rb +0 -10
- data/spec/views/accounts/_edit.haml_spec.rb +0 -43
- data/spec/views/accounts/_new.haml_spec.rb +0 -42
- data/spec/views/accounts/create.js.haml_spec.rb +0 -52
- data/spec/views/accounts/destroy.js.haml_spec.rb +0 -34
- data/spec/views/accounts/edit.js.haml_spec.rb +0 -66
- data/spec/views/accounts/index.haml_spec.rb +0 -43
- data/spec/views/accounts/index.js.haml_spec.rb +0 -34
- data/spec/views/accounts/new.js.haml_spec.rb +0 -44
- data/spec/views/accounts/show.haml_spec.rb +0 -38
- data/spec/views/accounts/update.js.haml_spec.rb +0 -93
- data/spec/views/admin/field_groups/create.js.haml_spec.rb +0 -30
- data/spec/views/admin/field_groups/destroy.js.haml_spec.rb +0 -31
- data/spec/views/admin/field_groups/edit.js.haml_spec.rb +0 -24
- data/spec/views/admin/field_groups/new.js.haml_spec.rb +0 -25
- data/spec/views/admin/field_groups/update.js.haml_spec.rb +0 -29
- data/spec/views/admin/users/_create.haml_spec.rb +0 -23
- data/spec/views/admin/users/create.js.haml_spec.rb +0 -41
- data/spec/views/admin/users/destroy.js.haml_spec.rb +0 -47
- data/spec/views/admin/users/edit.js.haml_spec.rb +0 -44
- data/spec/views/admin/users/index.haml_spec.rb +0 -22
- data/spec/views/admin/users/index.js.haml_spec.rb +0 -26
- data/spec/views/admin/users/new.js.haml_spec.rb +0 -34
- data/spec/views/admin/users/reactivate.js.haml_spec.rb +0 -22
- data/spec/views/admin/users/show.haml_spec.rb +0 -18
- data/spec/views/admin/users/suspend.js.haml_spec.rb +0 -22
- data/spec/views/admin/users/update.js.haml_spec.rb +0 -37
- data/spec/views/application/auto_complete.haml_spec.rb +0 -48
- data/spec/views/campaigns/_edit.haml_spec.rb +0 -44
- data/spec/views/campaigns/_new.haml_spec.rb +0 -41
- data/spec/views/campaigns/create.js.haml_spec.rb +0 -49
- data/spec/views/campaigns/destroy.js.haml_spec.rb +0 -31
- data/spec/views/campaigns/edit.js.haml_spec.rb +0 -66
- data/spec/views/campaigns/index.haml_spec.rb +0 -37
- data/spec/views/campaigns/index.js.haml_spec.rb +0 -34
- data/spec/views/campaigns/new.js.haml_spec.rb +0 -50
- data/spec/views/campaigns/show.haml_spec.rb +0 -38
- data/spec/views/campaigns/update.js.haml_spec.rb +0 -78
- data/spec/views/comments/edit.js.haml_spec.rb +0 -30
- data/spec/views/contacts/_edit.haml_spec.rb +0 -73
- data/spec/views/contacts/_new.haml_spec.rb +0 -52
- data/spec/views/contacts/create.js.haml_spec.rb +0 -65
- data/spec/views/contacts/destroy.js.haml_spec.rb +0 -45
- data/spec/views/contacts/edit.js.haml_spec.rb +0 -74
- data/spec/views/contacts/index.haml_spec.rb +0 -37
- data/spec/views/contacts/index.js.html_spec.rb +0 -34
- data/spec/views/contacts/new.js.haml_spec.rb +0 -47
- data/spec/views/contacts/show.haml_spec.rb +0 -35
- data/spec/views/contacts/update.js.haml_spec.rb +0 -128
- data/spec/views/home/index.haml_spec.rb +0 -36
- data/spec/views/home/index.js.haml_spec.rb +0 -33
- data/spec/views/home/options.js.haml_spec.rb +0 -53
- data/spec/views/leads/_convert.haml_spec.rb +0 -30
- data/spec/views/leads/_edit.haml_spec.rb +0 -47
- data/spec/views/leads/_new.haml_spec.rb +0 -45
- data/spec/views/leads/_sidebar_show.haml_spec.rb +0 -31
- data/spec/views/leads/convert.js.haml_spec.rb +0 -79
- data/spec/views/leads/create.js.haml_spec.rb +0 -67
- data/spec/views/leads/destroy.js.haml_spec.rb +0 -47
- data/spec/views/leads/edit.js.haml_spec.rb +0 -76
- data/spec/views/leads/index.haml_spec.rb +0 -37
- data/spec/views/leads/index.js.haml_spec.rb +0 -34
- data/spec/views/leads/new.js.haml_spec.rb +0 -47
- data/spec/views/leads/promote.js.haml_spec.rb +0 -135
- data/spec/views/leads/reject.js.haml_spec.rb +0 -45
- data/spec/views/leads/show.haml_spec.rb +0 -32
- data/spec/views/leads/update.js.haml_spec.rb +0 -118
- data/spec/views/opportunities/_edit.haml_spec.rb +0 -70
- data/spec/views/opportunities/_new.haml_spec.rb +0 -51
- data/spec/views/opportunities/create.js.haml_spec.rb +0 -86
- data/spec/views/opportunities/destroy.js.haml_spec.rb +0 -64
- data/spec/views/opportunities/edit.js.haml_spec.rb +0 -75
- data/spec/views/opportunities/index.haml_spec.rb +0 -38
- data/spec/views/opportunities/index.js.haml_spec.rb +0 -35
- data/spec/views/opportunities/new.js.haml_spec.rb +0 -54
- data/spec/views/opportunities/show.haml_spec.rb +0 -35
- data/spec/views/opportunities/update.js.haml_spec.rb +0 -143
- data/spec/views/tasks/_edit.haml_spec.rb +0 -50
- data/spec/views/tasks/complete.js.haml_spec.rb +0 -67
- data/spec/views/tasks/create.js.haml_spec.rb +0 -119
- data/spec/views/tasks/destroy.js.haml_spec.rb +0 -57
- data/spec/views/tasks/edit.js.haml_spec.rb +0 -76
- data/spec/views/tasks/index.haml_spec.rb +0 -46
- data/spec/views/tasks/new.js.haml_spec.rb +0 -49
- data/spec/views/tasks/uncomplete.js.haml_spec.rb +0 -45
- data/spec/views/tasks/update.js.haml_spec.rb +0 -140
- data/spec/views/users/avatar.js.haml_spec.rb +0 -35
- data/spec/views/users/change_password.js.haml_spec.rb +0 -51
- data/spec/views/users/edit.js.haml_spec.rb +0 -35
- data/spec/views/users/password.js.haml_spec.rb +0 -36
- data/spec/views/users/update.js.haml_spec.rb +0 -46
- data/spec/views/users/upload_avatar.js.haml_spec.rb +0 -45
- data/vendor/gems/globby-0.1.2/LICENSE.txt +0 -20
- data/vendor/gems/globby-0.1.2/README.md +0 -65
- data/vendor/gems/globby-0.1.2/Rakefile +0 -9
- data/vendor/gems/globby-0.1.2/lib/globby/glob.rb +0 -90
- data/vendor/gems/globby-0.1.2/lib/globby/globject.rb +0 -18
- data/vendor/gems/globby-0.1.2/lib/globby/result.rb +0 -20
- data/vendor/gems/globby-0.1.2/lib/globby.rb +0 -47
- data/vendor/gems/globby-0.1.2/spec/gitignore_spec.rb +0 -109
- data/vendor/gems/globby-0.1.2/spec/globby_spec.rb +0 -93
- data/zeus.json +0 -22
data/spec/lib/errors_spec.rb
DELETED
@@ -1,32 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
# Copyright (c) 2008-2013 Michael Dvorkin and contributors.
|
4
|
-
#
|
5
|
-
# Fat Free CRM is freely distributable under the terms of MIT license.
|
6
|
-
# See MIT-LICENSE file or http://www.opensource.org/licenses/mit-license.php
|
7
|
-
#------------------------------------------------------------------------------
|
8
|
-
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
9
|
-
|
10
|
-
describe 'ActiveModel Validation Errors' do
|
11
|
-
it 'should render explicit error message if it starts with a caret' do
|
12
|
-
class Adam < User
|
13
|
-
validates_presence_of :title, message: '^Missing title'
|
14
|
-
end
|
15
|
-
|
16
|
-
adam = Adam.create(username: 'adam', email: 'adam@example.com', password: 'ouchmyrib')
|
17
|
-
expect(adam.valid?).to eq(false)
|
18
|
-
expect(adam.errors[:title]).to eq(['^Missing title'])
|
19
|
-
expect(adam.errors.full_messages[0]).to eq('Missing title')
|
20
|
-
end
|
21
|
-
|
22
|
-
it 'should exhibit default behavior' do
|
23
|
-
class Eve < User
|
24
|
-
validates_presence_of :title, message: 'missing'
|
25
|
-
end
|
26
|
-
|
27
|
-
eve = Eve.create(username: 'eve', email: 'eve@example.com', password: 'doyoulikeapples')
|
28
|
-
expect(eve.valid?).to eq(false)
|
29
|
-
expect(eve.errors[:title]).to eq(['missing'])
|
30
|
-
expect(eve.errors.full_messages[0]).to eq('Title missing')
|
31
|
-
end
|
32
|
-
end
|
data/spec/lib/fields_spec.rb
DELETED
@@ -1,101 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
# Copyright (c) 2008-2013 Michael Dvorkin and contributors.
|
4
|
-
#
|
5
|
-
# Fat Free CRM is freely distributable under the terms of MIT license.
|
6
|
-
# See MIT-LICENSE file or http://www.opensource.org/licenses/mit-license.php
|
7
|
-
#------------------------------------------------------------------------------
|
8
|
-
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
9
|
-
|
10
|
-
describe 'FatFreeCRM::Fields' do
|
11
|
-
class Foo
|
12
|
-
include FatFreeCRM::Fields
|
13
|
-
include ActiveModel::Validations
|
14
|
-
has_fields
|
15
|
-
end
|
16
|
-
|
17
|
-
class Bar
|
18
|
-
include FatFreeCRM::Fields
|
19
|
-
include ActiveModel::Validations
|
20
|
-
end
|
21
|
-
|
22
|
-
it do
|
23
|
-
expect(Foo.new).to respond_to(:field_groups)
|
24
|
-
end
|
25
|
-
|
26
|
-
it do
|
27
|
-
expect(Foo).to respond_to(:serialize_custom_fields!)
|
28
|
-
end
|
29
|
-
|
30
|
-
it do
|
31
|
-
expect(Foo).to respond_to(:fields)
|
32
|
-
end
|
33
|
-
|
34
|
-
it "calling has_fields should invoke serialize_custom_fields!" do
|
35
|
-
expect(Bar).to receive(:serialize_custom_fields!)
|
36
|
-
Bar.has_fields
|
37
|
-
end
|
38
|
-
|
39
|
-
describe "field_groups" do
|
40
|
-
it "should call FieldGroup" do
|
41
|
-
expect(ActiveRecord::Base.connection).to receive(:data_source_exists?).with('field_groups').and_return(true)
|
42
|
-
dummy_scope = double
|
43
|
-
expect(dummy_scope).to receive(:order).with(:position)
|
44
|
-
expect(FieldGroup).to receive(:where).and_return(dummy_scope)
|
45
|
-
Foo.new.field_groups
|
46
|
-
end
|
47
|
-
|
48
|
-
it "should not call FieldGroup if table doesn't exist (migrations not yet run)" do
|
49
|
-
expect(ActiveRecord::Base.connection).to receive(:data_source_exists?).with('field_groups').and_return(false)
|
50
|
-
expect(Foo.new.field_groups).to eq([])
|
51
|
-
end
|
52
|
-
end
|
53
|
-
|
54
|
-
describe "fields" do
|
55
|
-
before(:each) do
|
56
|
-
@f1 = double(Field)
|
57
|
-
@f2 = double(Field)
|
58
|
-
@f3 = double(Field)
|
59
|
-
@field_groups = [double(FieldGroup, fields: [@f1, @f2]), double(FieldGroup, fields: [@f3])]
|
60
|
-
end
|
61
|
-
|
62
|
-
it "should convert field_groups into a flattened list of fields" do
|
63
|
-
expect(Foo).to receive(:field_groups).and_return(@field_groups)
|
64
|
-
expect(Foo.fields).to eq([@f1, @f2, @f3])
|
65
|
-
end
|
66
|
-
end
|
67
|
-
|
68
|
-
describe "serialize_custom_fields!" do
|
69
|
-
before(:each) do
|
70
|
-
@f1 = double(Field, as: 'check_boxes', name: 'field1')
|
71
|
-
@f2 = double(Field, as: 'date', name: 'field2')
|
72
|
-
end
|
73
|
-
|
74
|
-
it "should serialize checkbox fields as Array" do
|
75
|
-
allow(Foo).to receive(:serialized_attributes).and_return(field1: @f1, field2: @f2)
|
76
|
-
expect(Foo).to receive(:fields).and_return([@f1, @f2])
|
77
|
-
expect(Foo).to receive(:serialize).with(:field1, Array)
|
78
|
-
Foo.serialize_custom_fields!
|
79
|
-
end
|
80
|
-
end
|
81
|
-
|
82
|
-
it "should validate custom fields" do
|
83
|
-
foo = Foo.new
|
84
|
-
expect(foo).to receive(:custom_fields_validator)
|
85
|
-
expect(foo).to be_valid
|
86
|
-
end
|
87
|
-
|
88
|
-
describe "custom_fields_validator" do
|
89
|
-
before(:each) do
|
90
|
-
@f1 = double(Field)
|
91
|
-
@field_groups = [double(FieldGroup, fields: [@f1])]
|
92
|
-
end
|
93
|
-
|
94
|
-
it "should call custom_validator on each custom field" do
|
95
|
-
foo = Foo.new
|
96
|
-
expect(@f1).to receive(:custom_validator).with(foo)
|
97
|
-
expect(foo).to receive(:field_groups).and_return(@field_groups)
|
98
|
-
expect(foo).to be_valid
|
99
|
-
end
|
100
|
-
end
|
101
|
-
end
|
@@ -1,169 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
# Copyright (c) 2008-2013 Michael Dvorkin and contributors.
|
4
|
-
#
|
5
|
-
# Fat Free CRM is freely distributable under the terms of MIT license.
|
6
|
-
# See MIT-LICENSE file or http://www.opensource.org/licenses/mit-license.php
|
7
|
-
#------------------------------------------------------------------------------
|
8
|
-
require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
|
9
|
-
require File.dirname(__FILE__) + '/sample_emails/dropbox'
|
10
|
-
|
11
|
-
require "fat_free_crm/mail_processor/base"
|
12
|
-
|
13
|
-
describe FatFreeCRM::MailProcessor::Base do
|
14
|
-
include MockIMAP
|
15
|
-
|
16
|
-
before do
|
17
|
-
@mock_address = "base-mail-processor@example.com"
|
18
|
-
end
|
19
|
-
|
20
|
-
before(:each) do
|
21
|
-
@crawler = FatFreeCRM::MailProcessor::Base.new
|
22
|
-
# MailProcessor::Base doesn't load any settings by default
|
23
|
-
@crawler.instance_variable_set "@settings",
|
24
|
-
server: "example.com",
|
25
|
-
port: "123",
|
26
|
-
ssl: true,
|
27
|
-
address: "test@example.com",
|
28
|
-
user: "test@example.com",
|
29
|
-
password: "123"
|
30
|
-
end
|
31
|
-
|
32
|
-
#------------------------------------------------------------------------------
|
33
|
-
describe "Connecting to the IMAP server" do
|
34
|
-
it "should connect to the IMAP server and login as user, and select folder" do
|
35
|
-
mock_imap
|
36
|
-
expect(@imap).to receive(:login).once.with(@settings[:user], @settings[:password])
|
37
|
-
expect(@imap).to receive(:select).once.with(@settings[:scan_folder])
|
38
|
-
@crawler.send(:connect!)
|
39
|
-
end
|
40
|
-
|
41
|
-
it "should connect to the IMAP server, login as user, but not select folder when requested so" do
|
42
|
-
mock_imap
|
43
|
-
expect(@imap).to receive(:login).once.with(@settings[:user], @settings[:password])
|
44
|
-
expect(@imap).not_to receive(:select).with(@settings[:scan_folder])
|
45
|
-
@crawler.send(:connect!, setup: true)
|
46
|
-
end
|
47
|
-
|
48
|
-
it "should raise the error if connection fails" do
|
49
|
-
expect(Net::IMAP).to receive(:new).and_raise(SocketError) # No mocks this time! :-)
|
50
|
-
expect(@crawler.send(:connect!)).to eq(nil)
|
51
|
-
end
|
52
|
-
end
|
53
|
-
|
54
|
-
#------------------------------------------------------------------------------
|
55
|
-
describe "Disconnecting from the IMAP server" do
|
56
|
-
it "should logout and diconnect" do
|
57
|
-
mock_connect
|
58
|
-
mock_disconnect
|
59
|
-
expect(@imap).to receive(:logout).once
|
60
|
-
expect(@imap).to receive(:disconnect).once
|
61
|
-
|
62
|
-
@crawler.send(:connect!)
|
63
|
-
@crawler.send(:disconnect!)
|
64
|
-
end
|
65
|
-
end
|
66
|
-
|
67
|
-
#------------------------------------------------------------------------------
|
68
|
-
describe "Discarding a message" do
|
69
|
-
before(:each) do
|
70
|
-
mock_connect
|
71
|
-
@uid = double
|
72
|
-
@crawler.send(:connect!)
|
73
|
-
end
|
74
|
-
|
75
|
-
it "should copy message to invalid folder if it's set and flag the message as deleted" do
|
76
|
-
@settings[:move_invalid_to_folder] = "invalid"
|
77
|
-
expect(@imap).to receive(:uid_copy).once.with(@uid, @settings[:move_invalid_to_folder])
|
78
|
-
expect(@imap).to receive(:uid_store).once.with(@uid, "+FLAGS", [:Deleted])
|
79
|
-
@crawler.send(:discard, @uid)
|
80
|
-
end
|
81
|
-
|
82
|
-
it "should not copy message to invalid folder if it's not set and flag the message as deleted" do
|
83
|
-
@settings[:move_invalid_to_folder] = nil
|
84
|
-
expect(@imap).not_to receive(:uid_copy)
|
85
|
-
expect(@imap).to receive(:uid_store).once.with(@uid, "+FLAGS", [:Deleted])
|
86
|
-
@crawler.send(:discard, @uid)
|
87
|
-
end
|
88
|
-
end
|
89
|
-
|
90
|
-
#------------------------------------------------------------------------------
|
91
|
-
describe "Archiving a message" do
|
92
|
-
before(:each) do
|
93
|
-
mock_connect
|
94
|
-
@uid = double
|
95
|
-
@crawler.send(:connect!)
|
96
|
-
end
|
97
|
-
|
98
|
-
it "should copy message to archive folder if it's set and flag the message as seen" do
|
99
|
-
@settings[:move_to_folder] = "processed"
|
100
|
-
expect(@imap).to receive(:uid_copy).once.with(@uid, @settings[:move_to_folder])
|
101
|
-
expect(@imap).to receive(:uid_store).once.with(@uid, "+FLAGS", [:Seen])
|
102
|
-
@crawler.send(:archive, @uid)
|
103
|
-
end
|
104
|
-
|
105
|
-
it "should not copy message to archive folder if it's not set and flag the message as seen" do
|
106
|
-
@settings[:move_to_folder] = nil
|
107
|
-
expect(@imap).not_to receive(:uid_copy)
|
108
|
-
expect(@imap).to receive(:uid_store).once.with(@uid, "+FLAGS", [:Seen])
|
109
|
-
@crawler.send(:archive, @uid)
|
110
|
-
end
|
111
|
-
end
|
112
|
-
|
113
|
-
#------------------------------------------------------------------------------
|
114
|
-
describe "Validating email" do
|
115
|
-
before(:each) do
|
116
|
-
@email = double
|
117
|
-
end
|
118
|
-
|
119
|
-
it "should be valid email if its contents type is text/plain" do
|
120
|
-
allow(@email).to receive(:content_type).and_return("text/plain")
|
121
|
-
expect(@crawler.send(:is_valid?, @email)).to eq(true)
|
122
|
-
end
|
123
|
-
|
124
|
-
it "should be invalid email if its contents type is not text/plain" do
|
125
|
-
allow(@email).to receive(:content_type).and_return("text/html")
|
126
|
-
expect(@crawler.send(:is_valid?, @email)).to eq(false)
|
127
|
-
end
|
128
|
-
end
|
129
|
-
|
130
|
-
#------------------------------------------------------------------------------
|
131
|
-
describe "Finding email sender among users" do
|
132
|
-
before(:each) do
|
133
|
-
@from = ["Aaron@Example.Com", "Ben@Example.com"]
|
134
|
-
@email = double
|
135
|
-
allow(@email).to receive(:from).and_return(@from)
|
136
|
-
end
|
137
|
-
|
138
|
-
it "should find non-suspended user that matches From: field" do
|
139
|
-
@user = create(:user, email: @from.first, suspended_at: nil)
|
140
|
-
expect(@crawler.send(:sent_from_known_user?, @email)).to eq(true)
|
141
|
-
expect(@crawler.instance_variable_get("@sender")).to eq(@user)
|
142
|
-
end
|
143
|
-
|
144
|
-
it "should not find user if his email doesn't match From: field" do
|
145
|
-
create(:user, email: "nobody@example.com")
|
146
|
-
expect(@crawler.send(:sent_from_known_user?, @email)).to eq(false)
|
147
|
-
expect(@crawler.instance_variable_get("@sender")).to eq(nil)
|
148
|
-
end
|
149
|
-
|
150
|
-
it "should not find user if his email matches From: field but is suspended" do
|
151
|
-
create(:user, email: @from.first, suspended_at: Time.now)
|
152
|
-
expect(@crawler.send(:sent_from_known_user?, @email)).to eq(false)
|
153
|
-
expect(@crawler.instance_variable_get("@sender")).to eq(nil)
|
154
|
-
end
|
155
|
-
|
156
|
-
#------------------------------------------------------------------------------
|
157
|
-
describe "Extracting plain text body" do
|
158
|
-
it "should extract text from multipart text/plain" do
|
159
|
-
text = @crawler.send(:plain_text_body, Mail.new(DROPBOX_EMAILS[:plain]))
|
160
|
-
expect(text).to be_present
|
161
|
-
end
|
162
|
-
|
163
|
-
it "should extract text and strip tags from multipart text/html" do
|
164
|
-
text = @crawler.send(:plain_text_body, Mail.new(DROPBOX_EMAILS[:multipart]))
|
165
|
-
expect(text).to eql('Hello,')
|
166
|
-
end
|
167
|
-
end
|
168
|
-
end
|
169
|
-
end
|
@@ -1,70 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
# Copyright (c) 2008-2013 Michael Dvorkin and contributors.
|
4
|
-
#
|
5
|
-
# Fat Free CRM is freely distributable under the terms of MIT license.
|
6
|
-
# See MIT-LICENSE file or http://www.opensource.org/licenses/mit-license.php
|
7
|
-
#------------------------------------------------------------------------------
|
8
|
-
require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
|
9
|
-
|
10
|
-
require "fat_free_crm/mail_processor/comment_replies"
|
11
|
-
|
12
|
-
describe FatFreeCRM::MailProcessor::CommentReplies do
|
13
|
-
include MockIMAP
|
14
|
-
|
15
|
-
before do
|
16
|
-
@mock_address = "crm-comment@example.com"
|
17
|
-
end
|
18
|
-
|
19
|
-
before(:each) do
|
20
|
-
@crawler = FatFreeCRM::MailProcessor::CommentReplies.new
|
21
|
-
end
|
22
|
-
|
23
|
-
#------------------------------------------------------------------------------
|
24
|
-
describe "Processing new emails" do
|
25
|
-
before do
|
26
|
-
create(:user, email: "aaron@example.com")
|
27
|
-
end
|
28
|
-
|
29
|
-
before(:each) do
|
30
|
-
mock_connect
|
31
|
-
mock_disconnect
|
32
|
-
end
|
33
|
-
|
34
|
-
it "should attach a new comment to a contact" do
|
35
|
-
@contact = create(:contact)
|
36
|
-
comment_reply = "This is a new comment reply via email"
|
37
|
-
|
38
|
-
mail = Mail.new from: "Aaron Assembler <aaron@example.com>",
|
39
|
-
to: "FFCRM Comments <crm-commment@example.com>",
|
40
|
-
subject: "[contact:#{@contact.id}] Test Contact",
|
41
|
-
body: comment_reply
|
42
|
-
mock_message mail.to_s
|
43
|
-
|
44
|
-
expect(@crawler).to receive(:archive).once
|
45
|
-
expect(@crawler).not_to receive(:with_recipients)
|
46
|
-
@crawler.run
|
47
|
-
|
48
|
-
expect(@contact.comments.size).to eq(1)
|
49
|
-
expect(@contact.comments.first.comment).to eq(comment_reply)
|
50
|
-
end
|
51
|
-
|
52
|
-
it "should attach a new comment to an opportunity, using the 'op' shortcut in subject" do
|
53
|
-
@opportunity = create(:opportunity)
|
54
|
-
comment_reply = "This is a new comment reply via email"
|
55
|
-
|
56
|
-
mail = Mail.new from: "Aaron Assembler <aaron@example.com>",
|
57
|
-
to: "FFCRM Comments <crm-commment@example.com>",
|
58
|
-
subject: "[op:#{@opportunity.id}] Test Opportunity",
|
59
|
-
body: comment_reply
|
60
|
-
mock_message mail.to_s
|
61
|
-
|
62
|
-
expect(@crawler).to receive(:archive).once
|
63
|
-
expect(@crawler).not_to receive(:with_recipients)
|
64
|
-
@crawler.run
|
65
|
-
|
66
|
-
expect(@opportunity.comments.size).to eq(1)
|
67
|
-
expect(@opportunity.comments.first.comment).to eq(comment_reply)
|
68
|
-
end
|
69
|
-
end
|
70
|
-
end
|
@@ -1,306 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
# Copyright (c) 2008-2013 Michael Dvorkin and contributors.
|
4
|
-
#
|
5
|
-
# Fat Free CRM is freely distributable under the terms of MIT license.
|
6
|
-
# See MIT-LICENSE file or http://www.opensource.org/licenses/mit-license.php
|
7
|
-
#------------------------------------------------------------------------------
|
8
|
-
require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
|
9
|
-
require File.dirname(__FILE__) + '/sample_emails/dropbox'
|
10
|
-
|
11
|
-
require "fat_free_crm/mail_processor/dropbox"
|
12
|
-
|
13
|
-
describe FatFreeCRM::MailProcessor::Dropbox do
|
14
|
-
include MockIMAP
|
15
|
-
|
16
|
-
before(:each) do
|
17
|
-
@mock_address = "dropbox@example.com"
|
18
|
-
@crawler = FatFreeCRM::MailProcessor::Dropbox.new
|
19
|
-
end
|
20
|
-
|
21
|
-
#------------------------------------------------------------------------------
|
22
|
-
describe "Running the crawler" do
|
23
|
-
before(:each) do
|
24
|
-
mock_connect
|
25
|
-
mock_disconnect
|
26
|
-
mock_message(DROPBOX_EMAILS[:plain])
|
27
|
-
end
|
28
|
-
|
29
|
-
it "should discard a message if it's invalid" do
|
30
|
-
expect(@crawler).to receive(:is_valid?).once.and_return(false)
|
31
|
-
create(:user, email: "aaron@example.com")
|
32
|
-
expect(@crawler).not_to receive(:archive)
|
33
|
-
expect(@crawler).to receive(:discard).once
|
34
|
-
@crawler.run
|
35
|
-
end
|
36
|
-
|
37
|
-
it "should discard a message if it can't find the user" do
|
38
|
-
expect(@crawler).to receive(:is_valid?).once.and_return(true)
|
39
|
-
expect(@crawler).not_to receive(:archive)
|
40
|
-
expect(@crawler).to receive(:discard).once
|
41
|
-
@crawler.run
|
42
|
-
end
|
43
|
-
|
44
|
-
it "should process a message if it finds the user" do
|
45
|
-
create(:user, email: "aaron@example.com")
|
46
|
-
expect(@crawler).to receive(:archive).once
|
47
|
-
expect(@crawler).not_to receive(:discard)
|
48
|
-
@crawler.run
|
49
|
-
end
|
50
|
-
end
|
51
|
-
|
52
|
-
#------------------------------------------------------------------------------
|
53
|
-
describe "Pipeline: processing keywords on the first line" do
|
54
|
-
before(:each) do
|
55
|
-
mock_connect
|
56
|
-
mock_disconnect
|
57
|
-
create(:user, email: "aaron@example.com")
|
58
|
-
end
|
59
|
-
|
60
|
-
it "should find the named asset and attach the email message" do
|
61
|
-
mock_message(DROPBOX_EMAILS[:first_line])
|
62
|
-
@campaign = create(:campaign, name: "Got milk!?")
|
63
|
-
expect(@crawler).to receive(:archive).once
|
64
|
-
expect(@crawler).not_to receive(:with_recipients)
|
65
|
-
@crawler.run
|
66
|
-
|
67
|
-
expect(@campaign.emails.size).to eq(1)
|
68
|
-
expect(@campaign.emails.first.mediator).to eq(@campaign)
|
69
|
-
end
|
70
|
-
|
71
|
-
it "should create the named asset and attach the email message" do
|
72
|
-
mock_message(DROPBOX_EMAILS[:first_line])
|
73
|
-
expect(@crawler).to receive(:archive).once
|
74
|
-
expect(@crawler).not_to receive(:with_recipients)
|
75
|
-
@crawler.run
|
76
|
-
|
77
|
-
@campaign = Campaign.find_by(name: 'Got milk')
|
78
|
-
expect(@campaign).to be_instance_of(Campaign)
|
79
|
-
expect(@campaign.emails.size).to eq(1)
|
80
|
-
expect(@campaign.emails.first.mediator).to eq(@campaign)
|
81
|
-
end
|
82
|
-
|
83
|
-
it "should find the lead and attach the email message" do
|
84
|
-
mock_message(DROPBOX_EMAILS[:first_line_lead])
|
85
|
-
@lead = create(:lead, first_name: "Cindy", last_name: "Cluster")
|
86
|
-
expect(@crawler).to receive(:archive).once
|
87
|
-
expect(@crawler).not_to receive(:with_recipients)
|
88
|
-
@crawler.run
|
89
|
-
|
90
|
-
expect(@lead.emails.size).to eq(1)
|
91
|
-
expect(@lead.emails.first.mediator).to eq(@lead)
|
92
|
-
end
|
93
|
-
|
94
|
-
it "should create the lead and attach the email message" do
|
95
|
-
mock_message(DROPBOX_EMAILS[:first_line_lead])
|
96
|
-
expect(@crawler).to receive(:archive).once
|
97
|
-
expect(@crawler).not_to receive(:with_recipients)
|
98
|
-
@crawler.run
|
99
|
-
|
100
|
-
@lead = Lead.find_by(first_name: 'Cindy', last_name: 'Cluster')
|
101
|
-
expect(@lead).to be_instance_of(Lead)
|
102
|
-
expect(@lead.status).to eq("contacted")
|
103
|
-
expect(@lead.emails.size).to eq(1)
|
104
|
-
expect(@lead.emails.first.mediator).to eq(@lead)
|
105
|
-
end
|
106
|
-
|
107
|
-
it "should find the contact and attach the email message" do
|
108
|
-
mock_message(DROPBOX_EMAILS[:first_line_contact])
|
109
|
-
@contact = create(:contact, first_name: "Cindy", last_name: "Cluster")
|
110
|
-
expect(@crawler).to receive(:archive).once
|
111
|
-
expect(@crawler).not_to receive(:with_recipients)
|
112
|
-
@crawler.run
|
113
|
-
|
114
|
-
expect(@contact.emails.size).to eq(1)
|
115
|
-
expect(@contact.emails.first.mediator).to eq(@contact)
|
116
|
-
end
|
117
|
-
|
118
|
-
it "should create the contact and attach the email message" do
|
119
|
-
mock_message(DROPBOX_EMAILS[:first_line_contact])
|
120
|
-
expect(@crawler).to receive(:archive).once
|
121
|
-
expect(@crawler).not_to receive(:with_recipients)
|
122
|
-
@crawler.run
|
123
|
-
|
124
|
-
@contact = Contact.find_by(first_name: 'Cindy', last_name: 'Cluster')
|
125
|
-
expect(@contact).to be_instance_of(Contact)
|
126
|
-
expect(@contact.emails.size).to eq(1)
|
127
|
-
expect(@contact.emails.first.mediator).to eq(@contact)
|
128
|
-
end
|
129
|
-
|
130
|
-
it "should move on if first line has no keyword" do
|
131
|
-
mock_message(DROPBOX_EMAILS[:plain])
|
132
|
-
expect(@crawler).to receive(:with_recipients).twice
|
133
|
-
expect(@crawler).to receive(:with_forwarded_recipient).twice
|
134
|
-
@crawler.run
|
135
|
-
end
|
136
|
-
end
|
137
|
-
|
138
|
-
#------------------------------------------------------------------------------
|
139
|
-
describe "Pipeline: processing recipients (To: recipient, Bcc: dropbox)" do
|
140
|
-
before(:each) do
|
141
|
-
mock_connect
|
142
|
-
mock_disconnect
|
143
|
-
mock_message(DROPBOX_EMAILS[:plain])
|
144
|
-
create(:user, email: "aaron@example.com")
|
145
|
-
end
|
146
|
-
|
147
|
-
it "should find the asset and attach the email message" do
|
148
|
-
@lead = create(:lead, email: "ben@example.com", access: "Public")
|
149
|
-
expect(@crawler).to receive(:archive).once
|
150
|
-
expect(@crawler).not_to receive(:with_forwarded_recipient)
|
151
|
-
@crawler.run
|
152
|
-
|
153
|
-
expect(@lead.emails.size).to eq(1)
|
154
|
-
expect(@lead.emails.first.mediator).to eq(@lead)
|
155
|
-
end
|
156
|
-
|
157
|
-
it "should create the asset and attach the email message" do
|
158
|
-
expect(@crawler).to receive(:archive).once
|
159
|
-
expect { @crawler.run }.to change(Contact, :count).by(1)
|
160
|
-
|
161
|
-
@contact = Contact.last
|
162
|
-
expect(@contact.emails.size).to eq(1)
|
163
|
-
expect(@contact.emails.first.mediator).to eq(@contact)
|
164
|
-
end
|
165
|
-
end
|
166
|
-
|
167
|
-
#------------------------------------------------------------------------------
|
168
|
-
describe "Pipeline: processing forwarded recipient (To: dropbox)" do
|
169
|
-
before(:each) do
|
170
|
-
mock_connect
|
171
|
-
mock_disconnect
|
172
|
-
create(:user, email: "aaron@example.com")
|
173
|
-
mock_message(DROPBOX_EMAILS[:forwarded])
|
174
|
-
end
|
175
|
-
|
176
|
-
it "should find the asset and attach the email message" do
|
177
|
-
@lead = create(:lead, email: "ben@example.com", access: "Public")
|
178
|
-
expect(@crawler).to receive(:archive).once
|
179
|
-
@crawler.run
|
180
|
-
|
181
|
-
expect(@lead.emails.size).to eq(1)
|
182
|
-
expect(@lead.emails.first.mediator).to eq(@lead)
|
183
|
-
end
|
184
|
-
|
185
|
-
it "should touch the asset" do
|
186
|
-
now = Time.zone.now
|
187
|
-
timezone = ActiveRecord::Base.default_timezone
|
188
|
-
begin
|
189
|
-
ActiveRecord::Base.default_timezone = :utc
|
190
|
-
@lead = create(:lead, email: "ben@example.com", access: "Public", updated_at: 5.day.ago)
|
191
|
-
|
192
|
-
@crawler.run
|
193
|
-
expect(@lead.reload.updated_at.to_i).to be >= now.to_i
|
194
|
-
ensure
|
195
|
-
ActiveRecord::Base.default_timezone = timezone
|
196
|
-
end
|
197
|
-
end
|
198
|
-
|
199
|
-
it "should change lead's status (:new => :contacted)" do
|
200
|
-
@lead = create(:lead, email: "ben@example.com", access: "Public", status: "new")
|
201
|
-
|
202
|
-
@crawler.run
|
203
|
-
expect(@lead.reload.status).to eq("contacted")
|
204
|
-
end
|
205
|
-
|
206
|
-
it "should move on if forwarded recipient did not match" do
|
207
|
-
expect(@crawler).to receive(:with_forwarded_recipient).twice
|
208
|
-
@crawler.run
|
209
|
-
end
|
210
|
-
end
|
211
|
-
|
212
|
-
#------------------------------------------------------------------------------
|
213
|
-
describe "Pipeline: processing forwarded recipient from email sent to dropbox alias address" do
|
214
|
-
before(:each) do
|
215
|
-
@mock_address = "dropbox-alias-address@example.com"
|
216
|
-
mock_connect
|
217
|
-
mock_disconnect
|
218
|
-
|
219
|
-
@settings = @crawler.instance_variable_get("@settings")
|
220
|
-
@settings[:address_aliases] = ["dropbox@example.com"]
|
221
|
-
|
222
|
-
create(:user, email: "aaron@example.com")
|
223
|
-
mock_message(DROPBOX_EMAILS[:forwarded])
|
224
|
-
end
|
225
|
-
|
226
|
-
it "should not match the dropbox email address if routed to an alias" do
|
227
|
-
@lead = create(:lead, email: "ben@example.com", access: "Public")
|
228
|
-
@lead_dropbox = create(:lead, email: "dropbox@example.com", access: "Public")
|
229
|
-
|
230
|
-
expect(@crawler).to receive(:archive).once
|
231
|
-
@crawler.run
|
232
|
-
|
233
|
-
expect(@lead_dropbox.emails.size).to eq(0)
|
234
|
-
expect(@lead.emails.size).to eq(1)
|
235
|
-
end
|
236
|
-
end
|
237
|
-
|
238
|
-
#------------------------------------------------------------------------------
|
239
|
-
describe "Pipeline: creating recipient if s/he was not found" do
|
240
|
-
before(:each) do
|
241
|
-
mock_connect
|
242
|
-
mock_disconnect
|
243
|
-
create(:user, email: "aaron@example.com")
|
244
|
-
end
|
245
|
-
|
246
|
-
it "should create a contact from the email recipient (To: recipient, Bcc: dropbox)" do
|
247
|
-
mock_message(DROPBOX_EMAILS[:plain])
|
248
|
-
expect(@crawler).to receive(:archive).once
|
249
|
-
@crawler.run
|
250
|
-
|
251
|
-
@contact = Contact.first
|
252
|
-
expect(@contact.email).to eq("ben@example.com")
|
253
|
-
expect(@contact.emails.size).to eq(1)
|
254
|
-
expect(@contact.emails.first.mediator).to eq(@contact)
|
255
|
-
end
|
256
|
-
|
257
|
-
it "should create a contact from the forwarded email (To: dropbox)" do
|
258
|
-
mock_message(DROPBOX_EMAILS[:forwarded])
|
259
|
-
expect(@crawler).to receive(:archive).once
|
260
|
-
@crawler.run
|
261
|
-
|
262
|
-
@contact = Contact.first
|
263
|
-
expect(@contact.email).to eq("ben@example.com")
|
264
|
-
expect(@contact.emails.size).to eq(1)
|
265
|
-
expect(@contact.emails.first.mediator).to eq(@contact)
|
266
|
-
end
|
267
|
-
end
|
268
|
-
|
269
|
-
#------------------------------------------------------------------------------
|
270
|
-
describe "Extracting body" do
|
271
|
-
before do
|
272
|
-
@dropbox = FatFreeCRM::MailProcessor::Dropbox.new
|
273
|
-
end
|
274
|
-
|
275
|
-
it "should extract text from multipart text/plain" do
|
276
|
-
text = @dropbox.send(:plain_text_body, Mail.new(DROPBOX_EMAILS[:plain]))
|
277
|
-
expect(text).to be_present
|
278
|
-
end
|
279
|
-
|
280
|
-
it "should extract text and strip tags from multipart text/html" do
|
281
|
-
text = @dropbox.send(:plain_text_body, Mail.new(DROPBOX_EMAILS[:html]))
|
282
|
-
expect(text).to be_present
|
283
|
-
expect(text).not_to match(%r{</?[^>]*>})
|
284
|
-
end
|
285
|
-
end
|
286
|
-
|
287
|
-
#------------------------------------------------------------------------------
|
288
|
-
describe "Default values" do
|
289
|
-
describe "'access'" do
|
290
|
-
it "should be 'Private' if default setting is 'Private'" do
|
291
|
-
allow(Setting).to receive(:default_access).and_return('Private')
|
292
|
-
expect(@crawler.send(:default_access)).to eq("Private")
|
293
|
-
end
|
294
|
-
|
295
|
-
it "should be 'Public' if default setting is 'Public'" do
|
296
|
-
allow(Setting).to receive(:default_access).and_return('Public')
|
297
|
-
expect(@crawler.send(:default_access)).to eq("Public")
|
298
|
-
end
|
299
|
-
|
300
|
-
it "should be 'Private' if default setting is 'Shared'" do
|
301
|
-
allow(Setting).to receive(:default_access).and_return('Shared')
|
302
|
-
expect(@crawler.send(:default_access)).to eq("Private")
|
303
|
-
end
|
304
|
-
end
|
305
|
-
end
|
306
|
-
end
|