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
@@ -1,299 +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
|
-
# == Schema Information
|
9
|
-
#
|
10
|
-
# Table name: opportunities
|
11
|
-
#
|
12
|
-
# id :integer not null, primary key
|
13
|
-
# user_id :integer
|
14
|
-
# campaign_id :integer
|
15
|
-
# assigned_to :integer
|
16
|
-
# name :string(64) default(""), not null
|
17
|
-
# access :string(8) default("Public")
|
18
|
-
# source :string(32)
|
19
|
-
# stage :string(32)
|
20
|
-
# probability :integer
|
21
|
-
# amount :decimal(12, 2)
|
22
|
-
# discount :decimal(12, 2)
|
23
|
-
# closes_on :date
|
24
|
-
# deleted_at :datetime
|
25
|
-
# created_at :datetime
|
26
|
-
# updated_at :datetime
|
27
|
-
# background_info :string(255)
|
28
|
-
#
|
29
|
-
|
30
|
-
require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
|
31
|
-
|
32
|
-
describe Opportunity do
|
33
|
-
it "should create a new instance given valid attributes" do
|
34
|
-
Opportunity.create!(name: "Opportunity", stage: 'analysis')
|
35
|
-
end
|
36
|
-
|
37
|
-
it "should be possible to create opportunity with the same name" do
|
38
|
-
create(:opportunity, name: "Hello")
|
39
|
-
expect { create(:opportunity, name: "Hello") }.to_not raise_error
|
40
|
-
end
|
41
|
-
|
42
|
-
it "have a default stage" do
|
43
|
-
expect(Setting).to receive(:[]).with(:opportunity_default_stage).and_return('default')
|
44
|
-
expect(Opportunity.default_stage).to eql('default')
|
45
|
-
end
|
46
|
-
|
47
|
-
it "have a fallback default stage" do
|
48
|
-
expect(Opportunity.default_stage).to eql('prospecting')
|
49
|
-
end
|
50
|
-
|
51
|
-
describe "Update existing opportunity" do
|
52
|
-
before(:each) do
|
53
|
-
@account = create(:account)
|
54
|
-
@opportunity = create(:opportunity, account: @account)
|
55
|
-
end
|
56
|
-
|
57
|
-
it "should create new account if requested so" do
|
58
|
-
expect do
|
59
|
-
@opportunity.update_with_account_and_permissions(
|
60
|
-
account: { name: "New account" },
|
61
|
-
opportunity: { name: "Hello" }
|
62
|
-
)
|
63
|
-
end.to change(Account, :count).by(1)
|
64
|
-
expect(Account.last.name).to eq("New account")
|
65
|
-
expect(@opportunity.name.gsub(/#\d+ /, '')).to eq("Hello")
|
66
|
-
end
|
67
|
-
|
68
|
-
it "should update the account another account was selected" do
|
69
|
-
@another_account = create(:account)
|
70
|
-
expect do
|
71
|
-
@opportunity.update_with_account_and_permissions(
|
72
|
-
account: { id: @another_account.id },
|
73
|
-
opportunity: { name: "Hello" }
|
74
|
-
)
|
75
|
-
end.not_to change(Account, :count)
|
76
|
-
expect(@opportunity.account).to eq(@another_account)
|
77
|
-
expect(@opportunity.name.gsub(/#\d+ /, '')).to eq("Hello")
|
78
|
-
end
|
79
|
-
|
80
|
-
it "should drop existing Account if [create new account] is blank" do
|
81
|
-
expect do
|
82
|
-
@opportunity.update_with_account_and_permissions(
|
83
|
-
account: { name: "" },
|
84
|
-
opportunity: { name: "Hello" }
|
85
|
-
)
|
86
|
-
end.not_to change(Account, :count)
|
87
|
-
expect(@opportunity.account).to be_nil
|
88
|
-
expect(@opportunity.name.gsub(/#\d+ /, '')).to eq("Hello")
|
89
|
-
end
|
90
|
-
|
91
|
-
it "should drop existing Account if [-- None --] is selected from list of accounts" do
|
92
|
-
expect do
|
93
|
-
@opportunity.update_with_account_and_permissions(
|
94
|
-
account: { id: "" },
|
95
|
-
opportunity: { name: "Hello" }
|
96
|
-
)
|
97
|
-
end.not_to change(Account, :count)
|
98
|
-
expect(@opportunity.account).to be_nil
|
99
|
-
expect(@opportunity.name.gsub(/#\d+ /, '')).to eq("Hello")
|
100
|
-
end
|
101
|
-
|
102
|
-
it "should change account if entered name of another account was found" do
|
103
|
-
@another_account = create(:account, name: "Another name")
|
104
|
-
expect do
|
105
|
-
@opportunity.update_with_account_and_permissions(
|
106
|
-
account: { name: "Another name" },
|
107
|
-
opportunity: { name: "Hello" }
|
108
|
-
)
|
109
|
-
end.not_to change(Account, :count)
|
110
|
-
expect(@opportunity.account).to eq(@another_account)
|
111
|
-
expect(@opportunity.name.gsub(/#\d+ /, '')).to eq("Hello")
|
112
|
-
end
|
113
|
-
|
114
|
-
it "should set the probability to 0% if opportunity has been lost" do
|
115
|
-
opportunity = create(:opportunity, stage: "prospecting", probability: 25)
|
116
|
-
opportunity.update(stage: 'lost')
|
117
|
-
opportunity.reload
|
118
|
-
expect(opportunity.probability).to eq(0)
|
119
|
-
end
|
120
|
-
|
121
|
-
it "should set the probablility to 100% if opportunity has been won" do
|
122
|
-
opportunity = create(:opportunity, stage: "prospecting", probability: 65)
|
123
|
-
opportunity.update(stage: 'won')
|
124
|
-
opportunity.reload
|
125
|
-
expect(opportunity.probability).to eq(100)
|
126
|
-
end
|
127
|
-
end
|
128
|
-
|
129
|
-
describe "Scopes" do
|
130
|
-
it "should find non-closed opportunities" do
|
131
|
-
Opportunity.delete_all
|
132
|
-
@opportunities = [
|
133
|
-
create(:opportunity, stage: "prospecting", amount: 1),
|
134
|
-
create(:opportunity, stage: "analysis", amount: 1),
|
135
|
-
create(:opportunity, stage: "won", amount: 2),
|
136
|
-
create(:opportunity, stage: "won", amount: 2),
|
137
|
-
create(:opportunity, stage: "lost", amount: 3),
|
138
|
-
create(:opportunity, stage: "lost", amount: 3)
|
139
|
-
]
|
140
|
-
expect(Opportunity.pipeline.sum(:amount)).to eq(2)
|
141
|
-
expect(Opportunity.won.sum(:amount)).to eq(4)
|
142
|
-
expect(Opportunity.lost.sum(:amount)).to eq(6)
|
143
|
-
expect(Opportunity.sum(:amount)).to eq(12)
|
144
|
-
end
|
145
|
-
|
146
|
-
context "unassigned" do
|
147
|
-
let(:unassigned_opportunity) { create(:opportunity, assignee: nil) }
|
148
|
-
let(:assigned_opportunity) { create(:opportunity, assignee: create(:user)) }
|
149
|
-
|
150
|
-
it "includes unassigned opportunities" do
|
151
|
-
expect(Opportunity.unassigned).to include(unassigned_opportunity)
|
152
|
-
end
|
153
|
-
|
154
|
-
it "does not include opportunities assigned to a user" do
|
155
|
-
expect(Opportunity.unassigned).not_to include(assigned_opportunity)
|
156
|
-
end
|
157
|
-
end
|
158
|
-
end
|
159
|
-
|
160
|
-
describe "Attach" do
|
161
|
-
before do
|
162
|
-
@opportunity = create(:opportunity)
|
163
|
-
end
|
164
|
-
|
165
|
-
it "should return nil when attaching existing asset" do
|
166
|
-
@task = create(:task, asset: @opportunity)
|
167
|
-
@contact = create(:contact)
|
168
|
-
@opportunity.contacts << @contact
|
169
|
-
|
170
|
-
expect(@opportunity.attach!(@task)).to eq(nil)
|
171
|
-
expect(@opportunity.attach!(@contact)).to eq(nil)
|
172
|
-
end
|
173
|
-
|
174
|
-
it "should return non-empty list of attachments when attaching new asset" do
|
175
|
-
@task = create(:task)
|
176
|
-
@contact = create(:contact)
|
177
|
-
|
178
|
-
expect(@opportunity.attach!(@task)).to eq([@task])
|
179
|
-
expect(@opportunity.attach!(@contact)).to eq([@contact])
|
180
|
-
end
|
181
|
-
end
|
182
|
-
|
183
|
-
describe "Discard" do
|
184
|
-
before do
|
185
|
-
@opportunity = create(:opportunity)
|
186
|
-
end
|
187
|
-
|
188
|
-
it "should discard a task" do
|
189
|
-
@task = create(:task, asset: @opportunity)
|
190
|
-
expect(@opportunity.tasks.count).to eq(1)
|
191
|
-
|
192
|
-
@opportunity.discard!(@task)
|
193
|
-
expect(@opportunity.reload.tasks).to eq([])
|
194
|
-
expect(@opportunity.tasks.count).to eq(0)
|
195
|
-
end
|
196
|
-
|
197
|
-
it "should discard an contact" do
|
198
|
-
@contact = create(:contact)
|
199
|
-
@opportunity.contacts << @contact
|
200
|
-
expect(@opportunity.contacts.count).to eq(1)
|
201
|
-
|
202
|
-
@opportunity.discard!(@contact)
|
203
|
-
expect(@opportunity.contacts).to eq([])
|
204
|
-
expect(@opportunity.contacts.count).to eq(0)
|
205
|
-
end
|
206
|
-
end
|
207
|
-
|
208
|
-
describe "Exportable" do
|
209
|
-
describe "assigned opportunity" do
|
210
|
-
let(:opportunity1) { build(:opportunity, user: create(:user), assignee: create(:user)) }
|
211
|
-
let(:opportunity2) { build(:opportunity, user: create(:user, first_name: nil, last_name: nil), assignee: create(:user, first_name: nil, last_name: nil)) }
|
212
|
-
it_should_behave_like("exportable") do
|
213
|
-
let(:exported) { [opportunity1, opportunity2] }
|
214
|
-
end
|
215
|
-
end
|
216
|
-
|
217
|
-
describe "unassigned opportunity" do
|
218
|
-
let(:opportunity1) { build(:opportunity, user: create(:user), assignee: nil) }
|
219
|
-
let(:opportunity2) { build(:opportunity, user: create(:user, first_name: nil, last_name: nil), assignee: nil) }
|
220
|
-
it_should_behave_like("exportable") do
|
221
|
-
let(:exported) { [opportunity1, opportunity2] }
|
222
|
-
end
|
223
|
-
end
|
224
|
-
end
|
225
|
-
|
226
|
-
describe "permissions" do
|
227
|
-
it_should_behave_like Ability, Opportunity
|
228
|
-
end
|
229
|
-
|
230
|
-
describe "scopes" do
|
231
|
-
context "visible_on_dashboard" do
|
232
|
-
before :each do
|
233
|
-
@user = create(:user)
|
234
|
-
@o1 = create(:opportunity_in_pipeline, user: @user, stage: 'prospecting')
|
235
|
-
@o2 = create(:opportunity_in_pipeline, user: @user, assignee: create(:user), stage: 'prospecting')
|
236
|
-
@o3 = create(:opportunity_in_pipeline, user: create(:user), assignee: @user, stage: 'prospecting')
|
237
|
-
@o4 = create(:opportunity_in_pipeline, user: create(:user), assignee: create(:user), stage: 'prospecting')
|
238
|
-
@o5 = create(:opportunity_in_pipeline, user: create(:user), assignee: @user, stage: 'prospecting')
|
239
|
-
@o6 = create(:opportunity, assignee: @user, stage: 'won')
|
240
|
-
@o7 = create(:opportunity, assignee: @user, stage: 'lost')
|
241
|
-
end
|
242
|
-
|
243
|
-
it "should show opportunities which have been created by the user and are unassigned" do
|
244
|
-
expect(Opportunity.visible_on_dashboard(@user)).to include(@o1)
|
245
|
-
end
|
246
|
-
|
247
|
-
it "should show opportunities which are assigned to the user" do
|
248
|
-
expect(Opportunity.visible_on_dashboard(@user)).to include(@o3, @o5)
|
249
|
-
end
|
250
|
-
|
251
|
-
it "should not show opportunities which are not assigned to the user" do
|
252
|
-
expect(Opportunity.visible_on_dashboard(@user)).not_to include(@o4)
|
253
|
-
end
|
254
|
-
|
255
|
-
it "should not show opportunities which are created by the user but assigned" do
|
256
|
-
expect(Opportunity.visible_on_dashboard(@user)).not_to include(@o2)
|
257
|
-
end
|
258
|
-
|
259
|
-
it "does not include won or lost opportunities" do
|
260
|
-
expect(Opportunity.visible_on_dashboard(@user)).not_to include(@o6)
|
261
|
-
expect(Opportunity.visible_on_dashboard(@user)).not_to include(@o7)
|
262
|
-
end
|
263
|
-
end
|
264
|
-
|
265
|
-
context "by_closes_on" do
|
266
|
-
let(:o1) { create(:opportunity, closes_on: 3.days.from_now) }
|
267
|
-
let(:o2) { create(:opportunity, closes_on: 7.days.from_now) }
|
268
|
-
let(:o3) { create(:opportunity, closes_on: 5.days.from_now) }
|
269
|
-
|
270
|
-
it "should show opportunities ordered by closes on" do
|
271
|
-
expect(Opportunity.by_closes_on).to eq([o1, o3, o2])
|
272
|
-
end
|
273
|
-
end
|
274
|
-
|
275
|
-
context "by_amount" do
|
276
|
-
let(:o1) { create(:opportunity, amount: 50_000) }
|
277
|
-
let(:o2) { create(:opportunity, amount: 10_000) }
|
278
|
-
let(:o3) { create(:opportunity, amount: 750_000) }
|
279
|
-
|
280
|
-
it "should show opportunities ordered by amount" do
|
281
|
-
expect(Opportunity.by_amount).to eq([o3, o1, o2])
|
282
|
-
end
|
283
|
-
end
|
284
|
-
|
285
|
-
context "not lost" do
|
286
|
-
let(:o1) { create(:opportunity, stage: 'won') }
|
287
|
-
let(:o2) { create(:opportunity, stage: 'lost') }
|
288
|
-
let(:o3) { create(:opportunity, stage: 'analysis') }
|
289
|
-
|
290
|
-
it "should show opportunities which are not lost" do
|
291
|
-
expect(Opportunity.not_lost).to include(o1, o3)
|
292
|
-
end
|
293
|
-
|
294
|
-
it "should not show opportunities which are lost" do
|
295
|
-
expect(Opportunity.not_lost).not_to include(o2)
|
296
|
-
end
|
297
|
-
end
|
298
|
-
end
|
299
|
-
end
|
@@ -1,92 +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 'spec_helper'
|
9
|
-
|
10
|
-
describe CustomFieldDatePair do
|
11
|
-
describe "render_value" do
|
12
|
-
before(:each) do
|
13
|
-
@from = CustomFieldDatePair.new(name: 'cf_event_from')
|
14
|
-
@to = CustomFieldDatePair.new(name: 'cf_event_to')
|
15
|
-
allow(@from).to receive(:paired_with).and_return(@to)
|
16
|
-
@today = Date.today
|
17
|
-
@today_str = @today.strftime(I18n.t("date.formats.mmddyy"))
|
18
|
-
end
|
19
|
-
|
20
|
-
it "should be from..." do
|
21
|
-
foo = double(cf_event_from: @today, cf_event_to: nil)
|
22
|
-
expect(@from.render_value(foo)).to eq("From #{@today_str}")
|
23
|
-
end
|
24
|
-
|
25
|
-
it "should be until..." do
|
26
|
-
foo = double(cf_event_from: nil, cf_event_to: @today)
|
27
|
-
expect(@from.render_value(foo)).to eq("Until #{@today_str}")
|
28
|
-
end
|
29
|
-
|
30
|
-
it "should be from ... to" do
|
31
|
-
foo = double(cf_event_from: @today, cf_event_to: @today)
|
32
|
-
expect(@from.render_value(foo)).to eq("From #{@today_str} to #{@today_str}")
|
33
|
-
end
|
34
|
-
|
35
|
-
it "should be empty string" do
|
36
|
-
foo = double(cf_event_from: nil, cf_event_to: nil)
|
37
|
-
expect(@from.render_value(foo)).to eq("")
|
38
|
-
end
|
39
|
-
end
|
40
|
-
|
41
|
-
describe "custom_validator" do
|
42
|
-
before(:each) do
|
43
|
-
@from = CustomFieldDatePair.new(name: 'cf_event_from')
|
44
|
-
@to = CustomFieldDatePair.new(name: 'cf_event_to', pair_id: 1)
|
45
|
-
allow(CustomFieldPair).to receive(:find).and_return(@from)
|
46
|
-
@today = Date.today
|
47
|
-
@today_str = @today.strftime(I18n.t("date.formats.mmddyy"))
|
48
|
-
end
|
49
|
-
|
50
|
-
it "when from is nil it should be valid" do
|
51
|
-
foo = double(cf_event_from: nil, cf_event_to: @today)
|
52
|
-
expect(foo).not_to receive(:errors)
|
53
|
-
@to.custom_validator(foo)
|
54
|
-
end
|
55
|
-
|
56
|
-
it "when to is nil it should be valid" do
|
57
|
-
foo = double(cf_event_from: @today, cf_event_to: nil)
|
58
|
-
expect(foo).not_to receive(:errors)
|
59
|
-
@to.custom_validator(foo)
|
60
|
-
end
|
61
|
-
|
62
|
-
it "when from <= to it should be valid" do
|
63
|
-
foo = double(cf_event_from: @today, cf_event_to: @today)
|
64
|
-
expect(foo).not_to receive(:errors)
|
65
|
-
@to.custom_validator(foo)
|
66
|
-
end
|
67
|
-
|
68
|
-
it "when from > to it should not be valid" do
|
69
|
-
foo = double(cf_event_from: @today, cf_event_to: @today - 1.day)
|
70
|
-
err = double(:errors)
|
71
|
-
allow(err).to receive(:add)
|
72
|
-
expect(foo).to receive(:errors).and_return(err)
|
73
|
-
@to.custom_validator(foo)
|
74
|
-
end
|
75
|
-
|
76
|
-
it "should ignore validation when called on from" do
|
77
|
-
foo = double(cf_event_from: @today, cf_event_to: @today - 1.day)
|
78
|
-
expect(foo).not_to receive(:errors)
|
79
|
-
expect(CustomFieldPair).not_to receive(:find)
|
80
|
-
@from.custom_validator(foo)
|
81
|
-
end
|
82
|
-
|
83
|
-
it "should call custom field validation on super class" do
|
84
|
-
from = CustomFieldDatePair.new(name: 'cf_event_from', required: true)
|
85
|
-
foo = double(cf_event_from: nil)
|
86
|
-
err = double(:errors)
|
87
|
-
allow(err).to receive(:add)
|
88
|
-
expect(foo).to receive(:errors).and_return(err)
|
89
|
-
from.custom_validator(foo)
|
90
|
-
end
|
91
|
-
end
|
92
|
-
end
|
@@ -1,76 +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 'spec_helper'
|
9
|
-
|
10
|
-
describe CustomFieldPair do
|
11
|
-
class CustomFieldFooPair
|
12
|
-
end
|
13
|
-
|
14
|
-
it "should respond to pair" do
|
15
|
-
expect(CustomFieldPair.new).to respond_to(:pair)
|
16
|
-
end
|
17
|
-
|
18
|
-
describe "create_pair" do
|
19
|
-
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 } }
|
24
|
-
end
|
25
|
-
|
26
|
-
it "should create the pair" do
|
27
|
-
params1 = @field.merge(@pair1)
|
28
|
-
foo1 = double(id: 3, required: true, disabled: 'false')
|
29
|
-
expect(CustomFieldFooPair).to receive(:create).with(params1).and_return(foo1)
|
30
|
-
params2 = @field.merge(@pair2).merge('pair_id' => 3, 'required' => true, 'disabled' => 'false')
|
31
|
-
foo2 = double(id: 5)
|
32
|
-
expect(CustomFieldFooPair).to receive(:create).with(params2).and_return(foo2)
|
33
|
-
|
34
|
-
expect(CustomFieldPair.create_pair(@params)).to eq([foo1, foo2])
|
35
|
-
end
|
36
|
-
end
|
37
|
-
|
38
|
-
describe "update_pair" do
|
39
|
-
before(:each) do
|
40
|
-
@field = { 'as' => 'foopair', 'field_group_id' => 1, 'label' => 'Event' }
|
41
|
-
@pair1 = { 'name' => 'pair1' }
|
42
|
-
@pair2 = { 'name' => 'pair2' }
|
43
|
-
@params = { 'id' => '3', 'field' => @field, 'pair' => { '0' => @pair1, '1' => @pair2 } }
|
44
|
-
end
|
45
|
-
|
46
|
-
it "should update the pair" do
|
47
|
-
foo1 = double(required: true, disabled: 'false')
|
48
|
-
expect(foo1).to receive(:update).with(@field.merge(@pair1))
|
49
|
-
foo2 = double
|
50
|
-
expect(foo2).to receive(:update).with(@field.merge(@pair2).merge('required' => true, 'disabled' => 'false'))
|
51
|
-
expect(foo1).to receive(:paired_with).and_return(foo2)
|
52
|
-
expect(CustomFieldPair).to receive(:find).with('3').and_return(foo1)
|
53
|
-
|
54
|
-
expect(CustomFieldPair.update_pair(@params)).to eq([foo1, foo2])
|
55
|
-
end
|
56
|
-
end
|
57
|
-
|
58
|
-
describe "paired_with" do
|
59
|
-
before(:each) do
|
60
|
-
@field1 = CustomFieldDatePair.new(name: 'cf_event_from')
|
61
|
-
@field2 = CustomFieldDatePair.new(name: 'cf_event_to')
|
62
|
-
end
|
63
|
-
|
64
|
-
it "should return the 2nd field" do
|
65
|
-
expect(@field1).to receive(:pair).and_return(@field2)
|
66
|
-
expect(@field1.paired_with).to eq(@field2)
|
67
|
-
end
|
68
|
-
|
69
|
-
it "should return the 1st field" do
|
70
|
-
expect(@field2).to receive(:pair).and_return(nil)
|
71
|
-
expect(@field2).to receive(:id).and_return(1)
|
72
|
-
expect(CustomFieldPair).to receive(:where).with(pair_id: 1).and_return([@field1])
|
73
|
-
expect(@field2.paired_with).to eq(@field1)
|
74
|
-
end
|
75
|
-
end
|
76
|
-
end
|
@@ -1,129 +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
|
-
# == Schema Information
|
9
|
-
#
|
10
|
-
# Table name: fields
|
11
|
-
#
|
12
|
-
# id :integer not null, primary key
|
13
|
-
# type :string(255)
|
14
|
-
# field_group_id :integer
|
15
|
-
# position :integer
|
16
|
-
# name :string(64)
|
17
|
-
# label :string(128)
|
18
|
-
# hint :string(255)
|
19
|
-
# placeholder :string(255)
|
20
|
-
# as :string(32)
|
21
|
-
# collection :text
|
22
|
-
# disabled :boolean
|
23
|
-
# required :boolean
|
24
|
-
# maxlength :integer
|
25
|
-
# created_at :datetime
|
26
|
-
# updated_at :datetime
|
27
|
-
#
|
28
|
-
|
29
|
-
require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
|
30
|
-
|
31
|
-
describe CustomField do
|
32
|
-
it "should add a column to the database" do
|
33
|
-
expect(CustomField.connection).to receive(:add_column)
|
34
|
-
.with("contacts", "cf_test_field", 'string', {})
|
35
|
-
expect(Contact).to receive(:reset_column_information)
|
36
|
-
expect(Contact).to receive(:serialize_custom_fields!)
|
37
|
-
|
38
|
-
create(:custom_field,
|
39
|
-
as: "string",
|
40
|
-
name: "cf_test_field",
|
41
|
-
label: "Test Field",
|
42
|
-
field_group: create(:field_group, klass_name: "Contact"))
|
43
|
-
end
|
44
|
-
|
45
|
-
it "should generate a unique column name for a custom field" do
|
46
|
-
field_group = build(:field_group, klass_name: "Contact")
|
47
|
-
c = build(:custom_field, label: "Test Field", field_group: field_group)
|
48
|
-
|
49
|
-
columns = []
|
50
|
-
%w[cf_test_field cf_test_field_2 cf_test_field_3 cf_test_field_4].each do |field|
|
51
|
-
expect(c.send(:generate_column_name)).to eq(field)
|
52
|
-
allow(Contact).to receive(:column_names).and_return(columns << field)
|
53
|
-
end
|
54
|
-
end
|
55
|
-
|
56
|
-
it "should evaluate the safety of database transitions" do
|
57
|
-
c = build(:custom_field, as: "string")
|
58
|
-
expect(c.send(:db_transition_safety, c.as, "email")).to eq(:null)
|
59
|
-
expect(c.send(:db_transition_safety, c.as, "text")).to eq(:safe)
|
60
|
-
expect(c.send(:db_transition_safety, c.as, "datetime")).to eq(:unsafe)
|
61
|
-
|
62
|
-
c = build(:custom_field, as: "datetime")
|
63
|
-
expect(c.send(:db_transition_safety, c.as, "date")).to eq(:safe)
|
64
|
-
expect(c.send(:db_transition_safety, c.as, "url")).to eq(:unsafe)
|
65
|
-
end
|
66
|
-
|
67
|
-
it "should return a safe list of types for the 'as' select options" do
|
68
|
-
{ "email" => %w[check_boxes text string email url tel select radio_buttons],
|
69
|
-
"integer" => %w[integer float] }.each do |type, expected_arr|
|
70
|
-
c = build(:custom_field, as: type)
|
71
|
-
opts = c.available_as
|
72
|
-
expect(opts.map(&:first)).to match_array(expected_arr)
|
73
|
-
end
|
74
|
-
end
|
75
|
-
|
76
|
-
it "should change a column's type for safe transitions" do
|
77
|
-
expect(CustomField.connection).to receive(:add_column)
|
78
|
-
.with("contacts", "cf_test_field", 'string', {})
|
79
|
-
expect(CustomField.connection).to receive(:change_column)
|
80
|
-
.with("contacts", "cf_test_field", 'text', {})
|
81
|
-
expect(Contact).to receive(:reset_column_information).twice
|
82
|
-
expect(Contact).to receive(:serialize_custom_fields!).twice
|
83
|
-
|
84
|
-
field_group = create(:field_group, klass_name: "Contact")
|
85
|
-
c = create(:custom_field,
|
86
|
-
label: "Test Field",
|
87
|
-
name: nil,
|
88
|
-
as: "email",
|
89
|
-
field_group: field_group)
|
90
|
-
c.as = "text"
|
91
|
-
c.save
|
92
|
-
end
|
93
|
-
|
94
|
-
describe "in case a new custom field was added by a different instance" do
|
95
|
-
it "should refresh column info and retry on assignment error" do
|
96
|
-
expect(Contact).to receive(:reset_column_information)
|
97
|
-
|
98
|
-
expect { Contact.new cf_unknown_field: 123 }.to raise_error(ActiveRecord::UnknownAttributeError)
|
99
|
-
end
|
100
|
-
|
101
|
-
it "should refresh column info and retry on attribute error" do
|
102
|
-
expect(Contact).to receive(:reset_column_information)
|
103
|
-
expect(Contact).to receive(:serialize_custom_fields!)
|
104
|
-
|
105
|
-
contact = build(:contact)
|
106
|
-
expect(contact.cf_another_new_field).to eq(nil)
|
107
|
-
end
|
108
|
-
end
|
109
|
-
|
110
|
-
describe "validation" do
|
111
|
-
it "should have errors if custom field is required" do
|
112
|
-
event = CustomField.new(name: 'cf_event', required: true)
|
113
|
-
foo = double(cf_event: nil)
|
114
|
-
err = double(:errors)
|
115
|
-
allow(err).to receive(:add)
|
116
|
-
expect(foo).to receive(:errors).and_return(err)
|
117
|
-
event.custom_validator(foo)
|
118
|
-
end
|
119
|
-
|
120
|
-
it "should have errors if custom field is longer than maxlength" do
|
121
|
-
event = CustomField.new(name: 'cf_event', maxlength: 5)
|
122
|
-
foo = double(cf_event: "This is too long")
|
123
|
-
err = double(:errors)
|
124
|
-
allow(err).to receive(:add)
|
125
|
-
expect(foo).to receive(:errors).and_return(err)
|
126
|
-
event.custom_validator(foo)
|
127
|
-
end
|
128
|
-
end
|
129
|
-
end
|
@@ -1,29 +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
|
-
# == Schema Information
|
9
|
-
#
|
10
|
-
# Table name: field_groups
|
11
|
-
#
|
12
|
-
# id :integer not null, primary key
|
13
|
-
# name :string(64)
|
14
|
-
# label :string(128)
|
15
|
-
# position :integer
|
16
|
-
# hint :string(255)
|
17
|
-
# created_at :datetime
|
18
|
-
# updated_at :datetime
|
19
|
-
# tag_id :integer
|
20
|
-
# klass_name :string(32)
|
21
|
-
#
|
22
|
-
|
23
|
-
require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
|
24
|
-
|
25
|
-
describe FieldGroup do
|
26
|
-
it "should have field metadata" do
|
27
|
-
expect(FieldGroup.new).to respond_to(:fields)
|
28
|
-
end
|
29
|
-
end
|
@@ -1,69 +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
|
-
# == Schema Information
|
9
|
-
#
|
10
|
-
# Table name: fields
|
11
|
-
#
|
12
|
-
# id :integer not null, primary key
|
13
|
-
# type :string(255)
|
14
|
-
# field_group_id :integer
|
15
|
-
# position :integer
|
16
|
-
# name :string(64)
|
17
|
-
# label :string(128)
|
18
|
-
# hint :string(255)
|
19
|
-
# placeholder :string(255)
|
20
|
-
# as :string(32)
|
21
|
-
# collection :text
|
22
|
-
# disabled :boolean
|
23
|
-
# required :boolean
|
24
|
-
# minlength :integer
|
25
|
-
# maxlength :integer
|
26
|
-
# created_at :datetime
|
27
|
-
# updated_at :datetime
|
28
|
-
#
|
29
|
-
|
30
|
-
require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
|
31
|
-
|
32
|
-
describe Field do
|
33
|
-
it "should create a new instance given valid attributes" do
|
34
|
-
Field.create!(
|
35
|
-
name: 'skype_address',
|
36
|
-
label: 'Skype address',
|
37
|
-
as: 'string',
|
38
|
-
minlength: 12,
|
39
|
-
maxlength: 220,
|
40
|
-
position: 10
|
41
|
-
)
|
42
|
-
end
|
43
|
-
|
44
|
-
it "should return a list of field types" do
|
45
|
-
expect(Field.field_types['string']).to eq('klass' => 'CustomField', 'type' => 'string')
|
46
|
-
end
|
47
|
-
|
48
|
-
it "should return a hash of input options" do
|
49
|
-
expect(Field.new.input_options).to be_a(Hash)
|
50
|
-
end
|
51
|
-
|
52
|
-
it "should be able to display a empty multi_select value" do
|
53
|
-
field = Field.new(
|
54
|
-
label: "Availability",
|
55
|
-
name: "availability"
|
56
|
-
)
|
57
|
-
object = double('Object')
|
58
|
-
|
59
|
-
# as | value | expected
|
60
|
-
[["check_boxes", [1, 2, 3], "1, 2<br />3"],
|
61
|
-
%w[checkbox 0 no],
|
62
|
-
["checkbox", 1, "yes"],
|
63
|
-
["date", Time.parse('2011-04-19'), Time.parse('2011-04-19').strftime(I18n.t("date.formats.mmddyy"))]].each do |as, value, expected|
|
64
|
-
field.as = as
|
65
|
-
allow(object).to receive(field.name).and_return(value)
|
66
|
-
expect(field.render_value(object)).to eq(expected)
|
67
|
-
end
|
68
|
-
end
|
69
|
-
end
|