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,241 +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: versions
|
11
|
-
#
|
12
|
-
# id :integer not null, primary key
|
13
|
-
# user_id :integer
|
14
|
-
# item_id :integer
|
15
|
-
# item_type :string(255)
|
16
|
-
# event :string(32) default("create")
|
17
|
-
# info :string(255) default("")
|
18
|
-
# private :boolean default(FALSE)
|
19
|
-
# created_at :datetime
|
20
|
-
# updated_at :datetime
|
21
|
-
#
|
22
|
-
|
23
|
-
require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
|
24
|
-
|
25
|
-
describe Version, versioning: true do
|
26
|
-
let(:current_user) { create(:user) }
|
27
|
-
before { PaperTrail.request.whodunnit = current_user.id.to_s }
|
28
|
-
|
29
|
-
it "should create a new instance given valid attributes" do
|
30
|
-
create(:version, whodunnit: PaperTrail.request.whodunnit, item: create(:lead))
|
31
|
-
end
|
32
|
-
|
33
|
-
describe "with multiple version records" do
|
34
|
-
before do
|
35
|
-
@lead = create(:lead)
|
36
|
-
|
37
|
-
%w[create destroy update view].each do |event|
|
38
|
-
create(:version, event: event, item: @lead, whodunnit: PaperTrail.request.whodunnit)
|
39
|
-
create(:version, event: event, item: @lead, whodunnit: "1")
|
40
|
-
end
|
41
|
-
end
|
42
|
-
|
43
|
-
it "should not include view events" do
|
44
|
-
@versions = Version.for(current_user).exclude_events(:view)
|
45
|
-
expect(@versions.pluck(:event).sort).not_to include('view')
|
46
|
-
end
|
47
|
-
|
48
|
-
it "should exclude create, update and destroy events" do
|
49
|
-
@versions = Version.for(current_user).exclude_events(:create, :update, :destroy)
|
50
|
-
expect(@versions.pluck(:event)).not_to include('create')
|
51
|
-
expect(@versions.pluck(:event)).not_to include('update')
|
52
|
-
expect(@versions.pluck(:event)).not_to include('destroy')
|
53
|
-
end
|
54
|
-
|
55
|
-
it "should include only destroy events" do
|
56
|
-
@versions = Version.for(current_user).include_events(:destroy)
|
57
|
-
expect(@versions.pluck(:event).uniq).to eq(['destroy'])
|
58
|
-
end
|
59
|
-
|
60
|
-
it "should include create and update events" do
|
61
|
-
@versions = Version.for(current_user).include_events(:create, :update)
|
62
|
-
expect(@versions.pluck(:event).uniq.sort).to eq(%w[create update])
|
63
|
-
end
|
64
|
-
|
65
|
-
it "should select all versions for a given user" do
|
66
|
-
@versions = Version.for(current_user)
|
67
|
-
expect(@versions.map(&:whodunnit).uniq).to eq([current_user.id.to_s])
|
68
|
-
end
|
69
|
-
end
|
70
|
-
|
71
|
-
%w[account campaign contact lead opportunity task].each do |item|
|
72
|
-
describe "Create, update, and delete (#{item})" do
|
73
|
-
before :each do
|
74
|
-
@item = create(item.to_sym, user: current_user)
|
75
|
-
@conditions = { item_id: @item.id, item_type: @item.class.name, whodunnit: PaperTrail.request.whodunnit }
|
76
|
-
end
|
77
|
-
|
78
|
-
it "should add a version when creating new #{item}" do
|
79
|
-
@version = Version.where(@conditions.merge(event: 'create')).first
|
80
|
-
expect(@version).not_to eq(nil)
|
81
|
-
end
|
82
|
-
|
83
|
-
it "should add a version when updating existing #{item}" do
|
84
|
-
if @item.respond_to?(:full_name)
|
85
|
-
@item.update(first_name: "Billy", last_name: "Bones")
|
86
|
-
else
|
87
|
-
@item.update(name: "Billy Bones")
|
88
|
-
end
|
89
|
-
@version = Version.where(@conditions.merge(event: 'update')).first
|
90
|
-
|
91
|
-
expect(@version).not_to eq(nil)
|
92
|
-
end
|
93
|
-
|
94
|
-
it "should add a version when deleting #{item}" do
|
95
|
-
@item.destroy
|
96
|
-
@version = Version.where(@conditions.merge(event: 'destroy')).first
|
97
|
-
|
98
|
-
expect(@version).not_to eq(nil)
|
99
|
-
end
|
100
|
-
|
101
|
-
it "should add a version when commenting on a #{item}" do
|
102
|
-
@comment = create(:comment, commentable: @item, user: current_user)
|
103
|
-
|
104
|
-
@version = Version.where(related_id: @item.id, related_type: @item.class.name, whodunnit: PaperTrail.request.whodunnit, event: 'create').first
|
105
|
-
expect(@version).not_to eq(nil)
|
106
|
-
end
|
107
|
-
end
|
108
|
-
end
|
109
|
-
|
110
|
-
describe "Recently viewed items (task)" do
|
111
|
-
before do
|
112
|
-
@task = create(:task)
|
113
|
-
@conditions = { item_id: @task.id, item_type: @task.class.name }
|
114
|
-
end
|
115
|
-
|
116
|
-
it "creating a new task should not add it to recently viewed items list" do
|
117
|
-
versions = Version.where(@conditions)
|
118
|
-
expect(versions.pluck(:event)).to include('create') # but not view
|
119
|
-
end
|
120
|
-
|
121
|
-
it "updating a new task should not add it to recently viewed items list" do
|
122
|
-
@task.update(name: 'New Name')
|
123
|
-
|
124
|
-
versions = Version.where(@conditions)
|
125
|
-
expect(versions.pluck(:event).sort).to eq(%w[create update]) # but not view
|
126
|
-
end
|
127
|
-
end
|
128
|
-
|
129
|
-
describe "Action refinements for task updates" do
|
130
|
-
before do
|
131
|
-
@task = create(:task, user: current_user)
|
132
|
-
@conditions = { item_id: @task.id, item_type: @task.class.name, whodunnit: PaperTrail.request.whodunnit }
|
133
|
-
end
|
134
|
-
|
135
|
-
it "should create 'completed' task event" do
|
136
|
-
@task.update(completed_at: 1.second.ago)
|
137
|
-
|
138
|
-
versions = Version.where(@conditions)
|
139
|
-
expect(versions.pluck(:event)).to include('complete')
|
140
|
-
end
|
141
|
-
|
142
|
-
it "should create 'reassigned' task event" do
|
143
|
-
@task.update(assigned_to: current_user.id + 1)
|
144
|
-
|
145
|
-
versions = Version.where(@conditions)
|
146
|
-
expect(versions.pluck(:event)).to include('reassign')
|
147
|
-
end
|
148
|
-
|
149
|
-
it "should create 'rescheduled' task event" do
|
150
|
-
@task.update(bucket: "due_tomorrow") # FactoryBot creates :due_asap task
|
151
|
-
|
152
|
-
versions = Version.where(@conditions)
|
153
|
-
expect(versions.pluck(:event)).to include('reschedule')
|
154
|
-
end
|
155
|
-
end
|
156
|
-
|
157
|
-
describe "Rejecting a lead" do
|
158
|
-
before do
|
159
|
-
@lead = create(:lead, user: current_user, status: "new")
|
160
|
-
@conditions = { item_id: @lead.id, item_type: @lead.class.name, whodunnit: PaperTrail.request.whodunnit }
|
161
|
-
end
|
162
|
-
|
163
|
-
it "should create 'rejected' lead event" do
|
164
|
-
@lead.update(status: "rejected")
|
165
|
-
|
166
|
-
versions = Version.where(@conditions)
|
167
|
-
expect(versions.pluck(:event)).to include('reject')
|
168
|
-
end
|
169
|
-
end
|
170
|
-
|
171
|
-
describe "Permissions" do
|
172
|
-
before do
|
173
|
-
@user = create(:user)
|
174
|
-
Version.delete_all
|
175
|
-
end
|
176
|
-
|
177
|
-
it "should not show the create/update versions if the item is private" do
|
178
|
-
@item = create(:account, user: current_user, access: "Private")
|
179
|
-
@item.update(name: 'New Name')
|
180
|
-
|
181
|
-
versions = Version.where(item_id: @item.id, item_type: @item.class.name)
|
182
|
-
expect(versions.pluck(:event).sort).to eq(%w[create update])
|
183
|
-
|
184
|
-
visible_versions = Version.visible_to(@user)
|
185
|
-
expect(visible_versions).to eq([])
|
186
|
-
end
|
187
|
-
|
188
|
-
it "should not show the destroy version if the item is private" do
|
189
|
-
@item = create(:account, user: current_user, access: "Private")
|
190
|
-
@item.destroy
|
191
|
-
|
192
|
-
versions = Version.where(item_id: @item.id, item_type: @item.class.name)
|
193
|
-
expect(versions.pluck(:event).sort).to eq(%w[create destroy])
|
194
|
-
|
195
|
-
visible_versions = Version.visible_to(@user)
|
196
|
-
expect(visible_versions).to eq([])
|
197
|
-
end
|
198
|
-
|
199
|
-
it "should not show create/update versions if the item was not shared with the user" do
|
200
|
-
@item = create(:account,
|
201
|
-
user: current_user,
|
202
|
-
access: "Shared",
|
203
|
-
permissions: [build(:permission, user: current_user, asset: @item)])
|
204
|
-
@item.update(name: 'New Name')
|
205
|
-
|
206
|
-
versions = Version.where(item_id: @item.id, item_type: @item.class.name)
|
207
|
-
expect(versions.pluck(:event).sort).to eq(%w[create update])
|
208
|
-
|
209
|
-
visible_versions = Version.visible_to(@user)
|
210
|
-
expect(visible_versions).to eq([])
|
211
|
-
end
|
212
|
-
|
213
|
-
it "should not show the destroy version if the item was not shared with the user" do
|
214
|
-
@item = create(:account,
|
215
|
-
user: current_user,
|
216
|
-
access: "Shared",
|
217
|
-
permissions: [build(:permission, user: current_user, asset: @item)])
|
218
|
-
@item.destroy
|
219
|
-
|
220
|
-
versions = Version.where(item_id: @item.id, item_type: @item.class.name)
|
221
|
-
expect(versions.pluck(:event).sort).to eq(%w[create destroy])
|
222
|
-
|
223
|
-
visible_versions = Version.visible_to(@user)
|
224
|
-
expect(visible_versions).to eq([])
|
225
|
-
end
|
226
|
-
|
227
|
-
it "should show create/update versions if the item was shared with the user" do
|
228
|
-
@item = create(:account,
|
229
|
-
user: current_user,
|
230
|
-
access: "Shared",
|
231
|
-
permissions: [build(:permission, user: @user, asset: @item)])
|
232
|
-
@item.update(name: 'New Name')
|
233
|
-
|
234
|
-
versions = Version.where(item_id: @item.id, item_type: @item.class.name)
|
235
|
-
expect(versions.pluck(:event).sort).to eq(%w[create update])
|
236
|
-
|
237
|
-
visible_versions = Version.visible_to(@user)
|
238
|
-
expect(visible_versions.map(&:event).sort).to eq(%w[create update])
|
239
|
-
end
|
240
|
-
end
|
241
|
-
end
|
data/spec/models/setting_spec.rb
DELETED
@@ -1,77 +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: settings
|
11
|
-
#
|
12
|
-
# id :integer not null, primary key
|
13
|
-
# name :string(32) default(""), not null
|
14
|
-
# value :text
|
15
|
-
# created_at :datetime
|
16
|
-
# updated_at :datetime
|
17
|
-
#
|
18
|
-
|
19
|
-
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
20
|
-
|
21
|
-
describe Setting do
|
22
|
-
it "should create a new instance given valid attributes" do
|
23
|
-
Setting.create!(name: "name", value: "value")
|
24
|
-
end
|
25
|
-
|
26
|
-
it "should find existing setting by its name using [] or method notations, and cache settings" do
|
27
|
-
@setting = create(:setting, name: "thingymabob", value: "magoody")
|
28
|
-
expect(Setting.cache.key?("thingymabob")).to eq(false)
|
29
|
-
expect(Setting[:thingymabob]).to eq("magoody")
|
30
|
-
expect(Setting.cache.key?("thingymabob")).to eq(true)
|
31
|
-
expect(Setting.thingymabob).to eq("magoody")
|
32
|
-
end
|
33
|
-
|
34
|
-
it "should use value from YAML if setting is missing from database" do
|
35
|
-
@setting = create(:setting, name: "magoody", value: nil)
|
36
|
-
Setting.yaml_settings[:magoody] = "thingymabob"
|
37
|
-
expect(Setting[:magoody]).to eq("thingymabob")
|
38
|
-
expect(Setting.magoody).to eq("thingymabob")
|
39
|
-
end
|
40
|
-
|
41
|
-
it "should save a new value of a setting using []= or method notation" do
|
42
|
-
Setting[:hello] = "world"
|
43
|
-
expect(Setting[:hello]).to eq("world")
|
44
|
-
expect(Setting.hello).to eq("world")
|
45
|
-
|
46
|
-
Setting.world = "hello"
|
47
|
-
expect(Setting.world).to eq("hello")
|
48
|
-
expect(Setting[:world]).to eq("hello")
|
49
|
-
end
|
50
|
-
|
51
|
-
it "should handle false and nil values correctly" do
|
52
|
-
Setting[:hello] = false
|
53
|
-
expect(Setting[:hello]).to eq(false)
|
54
|
-
expect(Setting.hello).to eq(false)
|
55
|
-
end
|
56
|
-
|
57
|
-
describe "#dig" do
|
58
|
-
it "should dig into nested hashes" do
|
59
|
-
Setting[:hello] = { foo: { bar: 3 } }
|
60
|
-
expect(Setting.dig(:hello, :foo, :bar)).to eq(3)
|
61
|
-
end
|
62
|
-
|
63
|
-
it "should dig into nested arrays" do
|
64
|
-
Setting[:hello] = [1, [2, 3]]
|
65
|
-
expect(Setting.dig(:hello, 1, 1)).to eq(3)
|
66
|
-
end
|
67
|
-
|
68
|
-
it "should return nil if nil" do
|
69
|
-
expect(Setting.dig(:foo, :bar)).to eq(nil)
|
70
|
-
end
|
71
|
-
|
72
|
-
it "should return nil if nil" do
|
73
|
-
Setting[:hello] = "world"
|
74
|
-
expect { Setting.dig(:hello, :foo) }.to raise_error(TypeError)
|
75
|
-
end
|
76
|
-
end
|
77
|
-
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 'spec_helper'
|
9
|
-
require 'cancan/matchers'
|
10
|
-
|
11
|
-
def all_actions
|
12
|
-
%i[index show create update destroy manage]
|
13
|
-
end
|
14
|
-
|
15
|
-
describe "User abilities" do
|
16
|
-
subject(:ability) { Ability.new(user) }
|
17
|
-
let(:subject_user) { build :user }
|
18
|
-
|
19
|
-
context "when site manager, I" do
|
20
|
-
let(:user) { build :user, admin: true }
|
21
|
-
all_actions.each do |do_action|
|
22
|
-
it { is_expected.to be_able_to(do_action, subject_user) }
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
context "when myself, I" do
|
27
|
-
let(:user) { build :user }
|
28
|
-
let(:subject_user) { user }
|
29
|
-
all_actions.each do |do_action|
|
30
|
-
it { is_expected.to be_able_to(do_action, subject_user) }
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
context "when another user, I" do
|
35
|
-
let(:user) { create :user }
|
36
|
-
let(:can) { [] }
|
37
|
-
let(:cannot) { %i[show create update index destroy manage] }
|
38
|
-
it do
|
39
|
-
can.each do |do_action|
|
40
|
-
is_expected.to be_able_to(do_action, subject_user)
|
41
|
-
end
|
42
|
-
end
|
43
|
-
it do
|
44
|
-
cannot.each do |do_action|
|
45
|
-
is_expected.not_to be_able_to(do_action, subject_user)
|
46
|
-
end
|
47
|
-
end
|
48
|
-
end
|
49
|
-
|
50
|
-
context "when anonymous user, I" do
|
51
|
-
let(:user) { nil }
|
52
|
-
let(:can) { [] }
|
53
|
-
let(:cannot) { %i[show create update index destroy manage] }
|
54
|
-
it do
|
55
|
-
can.each do |do_action|
|
56
|
-
is_expected.to be_able_to(do_action, subject_user)
|
57
|
-
end
|
58
|
-
end
|
59
|
-
it do
|
60
|
-
cannot.each do |do_action|
|
61
|
-
is_expected.not_to be_able_to(do_action, subject_user)
|
62
|
-
end
|
63
|
-
end
|
64
|
-
|
65
|
-
it "and signup enabled" do
|
66
|
-
allow(User).to receive(:can_signup?).and_return(true)
|
67
|
-
is_expected.to be_able_to(:create, User)
|
68
|
-
end
|
69
|
-
end
|
70
|
-
end
|
@@ -1,11 +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 Group do
|
11
|
-
end
|
@@ -1,58 +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: permissions
|
11
|
-
#
|
12
|
-
# id :integer not null, primary key
|
13
|
-
# user_id :integer
|
14
|
-
# asset_id :integer
|
15
|
-
# asset_type :string(255)
|
16
|
-
# created_at :datetime
|
17
|
-
# updated_at :datetime
|
18
|
-
#
|
19
|
-
|
20
|
-
require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
|
21
|
-
|
22
|
-
describe Permission do
|
23
|
-
before(:each) do
|
24
|
-
@valid_attributes = {
|
25
|
-
user: mock_model(User),
|
26
|
-
asset: mock_model(Account)
|
27
|
-
}
|
28
|
-
end
|
29
|
-
|
30
|
-
it "should create a new instance given valid attributes" do
|
31
|
-
Permission.create!(@valid_attributes)
|
32
|
-
end
|
33
|
-
|
34
|
-
it "should validate with group_ids" do
|
35
|
-
p = Permission.new group_id: 1
|
36
|
-
expect(p).to be_valid
|
37
|
-
end
|
38
|
-
|
39
|
-
it "should validate with user_ids" do
|
40
|
-
p = Permission.new user_id: 2
|
41
|
-
expect(p).to be_valid
|
42
|
-
end
|
43
|
-
|
44
|
-
it "should validate not allow group_ids or user_ids to be blank" do
|
45
|
-
p = Permission.new
|
46
|
-
expect(p).not_to be_valid
|
47
|
-
expect(p.errors['user_id']).to eq(["can't be blank"])
|
48
|
-
expect(p.errors['group_id']).to eq(["can't be blank"])
|
49
|
-
end
|
50
|
-
|
51
|
-
it 'should not allow duplicate records with (user_id, group_id, asset_type, asset_ids) the same' do
|
52
|
-
permission1 = Permission.create(user_id: 1, group_id: 1, asset_id: 1, asset_type: 'UserWithPermission')
|
53
|
-
permission2 = Permission.new(user_id: 1, group_id: 1, asset_id: 1, asset_type: 'UserWithPermission')
|
54
|
-
|
55
|
-
expect(permission1).to be_valid
|
56
|
-
expect(permission2).not_to be_valid
|
57
|
-
end
|
58
|
-
end
|
@@ -1,71 +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: preferences
|
11
|
-
#
|
12
|
-
# id :integer not null, primary key
|
13
|
-
# user_id :integer
|
14
|
-
# name :string(32) default(""), not null
|
15
|
-
# value :text
|
16
|
-
# created_at :datetime
|
17
|
-
# updated_at :datetime
|
18
|
-
#
|
19
|
-
|
20
|
-
require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
|
21
|
-
|
22
|
-
describe Preference do
|
23
|
-
before(:each) do
|
24
|
-
@user = create(:user)
|
25
|
-
@magoody = Base64.encode64("magoody".to_json)
|
26
|
-
end
|
27
|
-
|
28
|
-
it "should create a new instance given valid attributes" do
|
29
|
-
Preference.create!(user: @user, name: "name", value: "value")
|
30
|
-
end
|
31
|
-
|
32
|
-
describe "get user preference" do
|
33
|
-
it "should find and decode existing user preference by its name" do
|
34
|
-
@preference = create(:preference, user: @user, name: "thingymabob", value: @magoody)
|
35
|
-
expect(@user.preference[:thingymabob]).to eq("magoody")
|
36
|
-
expect(@user.preference["thingymabob"]).to eq("magoody")
|
37
|
-
end
|
38
|
-
|
39
|
-
it "should return nil if user preference doesn't exist" do
|
40
|
-
expect(@user.preference[:cool]).to eq(nil)
|
41
|
-
end
|
42
|
-
|
43
|
-
it "should return correct user_id" do
|
44
|
-
@preference = create(:preference, user: @user, name: "thingymabob", value: @magoody)
|
45
|
-
expect(@user.preference[:user_id]).to eq(@user.id)
|
46
|
-
end
|
47
|
-
|
48
|
-
it "should disregard other user's preference with the same name" do
|
49
|
-
@preference = create(:preference, user: create(:user), name: "thingymabob", value: @magoody)
|
50
|
-
expect(@user.preference[:thingymabob]).to eq(nil)
|
51
|
-
end
|
52
|
-
|
53
|
-
it "should not fail is user is nil" do
|
54
|
-
@preference = create(:preference, user: nil, name: "thingymabob", value: @magoody)
|
55
|
-
expect(@preference[:thingymabob]).to eq(nil)
|
56
|
-
end
|
57
|
-
end
|
58
|
-
|
59
|
-
describe "set user preference" do
|
60
|
-
it "should create new user preference" do
|
61
|
-
@user.preference[:hello] = "magoody"
|
62
|
-
expect(@user.reload.preference[:hello]).to eq("magoody")
|
63
|
-
end
|
64
|
-
|
65
|
-
it "should update existing user preference" do
|
66
|
-
@preference = create(:preference, user: @user, name: "thingymabob", value: @magoody)
|
67
|
-
@user.preference[:thingymabob] = "thingy"
|
68
|
-
expect(@user.reload.preference[:thingymabob]).to eq("thingy")
|
69
|
-
end
|
70
|
-
end
|
71
|
-
end
|