fat_free_crm 0.17.3 → 0.19.2
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of fat_free_crm might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/.rubocop.yml +1 -1
- data/.rubocop_todo.yml +71 -148
- data/.travis.yml +35 -14
- data/CHANGELOG.md +92 -6
- data/CONTRIBUTORS.md +96 -53
- data/Dockerfile +45 -14
- data/Gemfile +23 -13
- data/Gemfile.lock +256 -248
- data/Procfile +1 -1
- data/README.md +9 -6
- data/Rakefile +1 -1
- data/app/assets/javascripts/crm.js.coffee +3 -3
- data/app/assets/javascripts/crm_select2.js.coffee +15 -14
- data/app/assets/stylesheets/common.scss +1 -1
- data/app/controllers/admin/application_controller.rb +1 -1
- data/app/controllers/admin/field_groups_controller.rb +9 -4
- data/app/controllers/admin/fields_controller.rb +4 -4
- data/app/controllers/admin/groups_controller.rb +1 -1
- data/app/controllers/admin/tags_controller.rb +2 -4
- data/app/controllers/admin/users_controller.rb +5 -8
- data/app/controllers/application_controller.rb +22 -45
- data/app/controllers/comments_controller.rb +16 -11
- data/{config/initializers/authlogic.rb → app/controllers/confirmations_controller.rb} +4 -2
- data/app/controllers/emails_controller.rb +0 -2
- data/app/controllers/entities/accounts_controller.rb +1 -3
- data/app/controllers/entities/campaigns_controller.rb +8 -5
- data/app/controllers/entities/contacts_controller.rb +4 -24
- data/app/controllers/entities/leads_controller.rb +16 -12
- data/app/controllers/entities/opportunities_controller.rb +17 -16
- data/app/controllers/entities_controller.rb +31 -12
- data/app/controllers/home_controller.rb +2 -4
- data/app/controllers/lists_controller.rb +5 -1
- data/app/controllers/passwords_controller.rb +3 -59
- data/{spec/features/support/maintain_sessions.rb → app/controllers/registrations_controller.rb} +12 -5
- data/{lib/development_tasks/gem.rake → app/controllers/sessions_controller.rb} +6 -6
- data/app/controllers/tasks_controller.rb +22 -17
- data/app/controllers/users_controller.rb +8 -29
- data/app/helpers/accounts_helper.rb +1 -1
- data/app/helpers/admin/users_helper.rb +1 -1
- data/app/helpers/application_helper.rb +28 -33
- data/app/helpers/campaigns_helper.rb +1 -1
- data/app/helpers/contacts_helper.rb +1 -3
- data/app/helpers/leads_helper.rb +1 -1
- data/app/helpers/opportunities_helper.rb +48 -3
- data/app/helpers/tasks_helper.rb +1 -1
- data/app/helpers/users_helper.rb +1 -3
- data/{config/initializers/paper_trail.rb → app/mailers/devise_mailer.rb} +5 -1
- data/app/mailers/user_mailer.rb +0 -9
- data/app/models/entities/account.rb +10 -10
- data/app/models/entities/campaign.rb +4 -6
- data/app/models/entities/contact.rb +24 -12
- data/app/models/entities/lead.rb +7 -14
- data/app/models/entities/opportunity.rb +10 -11
- data/app/models/fields/custom_field.rb +1 -0
- data/app/models/fields/custom_field_date_pair.rb +2 -0
- data/app/models/fields/field.rb +1 -3
- data/app/models/list.rb +1 -1
- data/app/models/observers/entity_observer.rb +3 -7
- data/app/models/observers/lead_observer.rb +2 -4
- data/app/models/observers/opportunity_observer.rb +5 -7
- data/app/models/observers/task_observer.rb +1 -1
- data/app/models/polymorphic/email.rb +2 -2
- data/app/models/polymorphic/task.rb +13 -9
- data/app/models/polymorphic/version.rb +3 -2
- data/app/models/setting.rb +2 -0
- data/app/models/users/ability.rb +3 -4
- data/app/models/users/permission.rb +3 -3
- data/app/models/users/preference.rb +2 -1
- data/app/models/users/user.rb +67 -42
- data/app/views/accounts/_top_section.html.haml +1 -1
- data/app/views/accounts/edit.js.haml +1 -1
- data/app/views/accounts/update.js.haml +2 -2
- data/app/views/admin/users/_user.html.haml +4 -4
- data/app/views/campaigns/_metrics.html.haml +3 -3
- data/app/views/contacts/_index_brief.html.haml +1 -1
- data/app/views/contacts/_index_full.html.haml +1 -1
- data/app/views/contacts/_index_long.html.haml +1 -1
- data/app/views/devise/confirmations/new.html.haml +9 -0
- data/app/views/devise/mailer/confirmation_instructions.html.haml +4 -0
- data/app/views/devise/mailer/password_change.html.haml +3 -0
- data/app/views/devise/mailer/reset_password_instructions.html.haml +6 -0
- data/app/views/devise/passwords/edit.html.haml +18 -0
- data/app/views/devise/passwords/new.html.haml +10 -0
- data/app/views/devise/registrations/new.html.haml +21 -0
- data/app/views/devise/sessions/new.html.haml +32 -0
- data/app/views/home/_opportunity.html.haml +4 -19
- data/app/views/layouts/_about.html.haml +5 -5
- data/app/views/layouts/_header.html.haml +3 -3
- data/app/views/layouts/admin/_header.html.haml +1 -1
- data/app/views/opportunities/_index_long.html.haml +1 -24
- data/app/views/opportunities/_sidebar_show.html.haml +3 -3
- data/app/views/opportunities/_top_section.html.haml +1 -1
- data/app/views/shared/_address.html.haml +5 -5
- data/app/views/shared/_empty.html.haml +1 -1
- data/app/views/shared/_paginate_with_per_page.html.haml +1 -0
- data/app/views/users/_avatar.html.haml +1 -1
- data/bin/bundle +1 -1
- data/bin/rails +1 -1
- data/bin/setup +38 -0
- data/bin/update +33 -0
- data/bin/yarn +13 -0
- data/config/application.rb +8 -6
- data/config/boot.rb +1 -1
- data/config/brakeman.ignore +2 -2
- data/config/database.postgres.docker.yml +5 -5
- data/config/environment.rb +1 -1
- data/config/environments/development.rb +1 -0
- data/config/environments/test.rb +7 -0
- data/config/initializers/action_mailer.rb +1 -3
- data/config/initializers/application_controller_renderer.rb +9 -0
- data/config/initializers/assets.rb +6 -11
- data/config/initializers/backtrace_silencers.rb +0 -6
- data/config/initializers/content_security_policy.rb +26 -0
- data/config/initializers/cookies_serializer.rb +3 -6
- data/config/initializers/devise.rb +289 -0
- data/config/initializers/filter_parameter_logging.rb +0 -5
- data/config/initializers/gravatar.rb +0 -1
- data/config/initializers/inflections.rb +0 -6
- data/config/initializers/mime_types.rb +1 -9
- data/config/initializers/new_framework_defaults_5_2.rb +40 -0
- data/config/initializers/relative_url_root.rb +1 -3
- data/config/initializers/session_store.rb +1 -3
- data/config/initializers/wrap_parameters.rb +4 -9
- data/config/locales/fat_free_crm.en-GB.yml +5 -5
- data/config/locales/fat_free_crm.en-US.yml +5 -5
- data/config/locales/fat_free_crm.fr.yml +1 -1
- data/config/locales/fat_free_crm.ru.yml +1 -0
- data/config/routes.rb +20 -9
- data/db/demo/users.yml +62 -81
- data/db/migrate/20100928030620_remove_uuid.rb +1 -2
- data/db/migrate/20120316045804_activities_to_versions.rb +1 -0
- data/db/migrate/20120510025219_add_not_null_constraints_for_timestamp_columns.rb +1 -0
- data/db/migrate/20180107082701_authlogic_to_devise.rb +58 -0
- data/db/schema.rb +48 -46
- data/docker-compose.yml +10 -0
- data/fat_free_crm.gemspec +12 -14
- data/lib/development_tasks/license.rake +2 -2
- data/lib/fat_free_crm/callback.rb +2 -2
- data/lib/fat_free_crm/comment_extensions.rb +2 -4
- data/lib/fat_free_crm/core_ext/string.rb +1 -1
- data/lib/fat_free_crm/engine.rb +2 -2
- data/lib/fat_free_crm/errors.rb +1 -1
- data/lib/fat_free_crm/export_csv.rb +1 -0
- data/lib/fat_free_crm/exportable.rb +1 -1
- data/lib/fat_free_crm/fields.rb +2 -2
- data/lib/fat_free_crm/gem_dependencies.rb +1 -1
- data/lib/fat_free_crm/gem_ext/simple_form/action_view_extensions/form_helper.rb +1 -3
- data/lib/fat_free_crm/i18n.rb +2 -2
- data/lib/fat_free_crm/mail_processor/base.rb +4 -10
- data/lib/fat_free_crm/mail_processor/dropbox.rb +5 -15
- data/lib/fat_free_crm/permissions.rb +7 -18
- data/lib/fat_free_crm/sortable.rb +1 -1
- data/lib/fat_free_crm/tabs.rb +2 -2
- data/lib/fat_free_crm/version.rb +2 -2
- data/lib/gravatar_image_tag.rb +7 -8
- data/lib/missing_translation_detector.rb +1 -0
- data/lib/tasks/ffcrm/missing_translations.rake +1 -0
- data/lib/tasks/ffcrm/setup.rake +13 -4
- data/lib/tasks/ffcrm/update_data.rake +2 -2
- data/script/rails +2 -2
- data/spec/controllers/admin/users_controller_spec.rb +25 -81
- data/spec/controllers/comments_controller_spec.rb +19 -19
- data/spec/controllers/emails_controller_spec.rb +2 -2
- data/spec/controllers/entities/accounts_controller_spec.rb +56 -56
- data/spec/controllers/entities/campaigns_controller_spec.rb +66 -66
- data/spec/controllers/entities/contacts_controller_spec.rb +69 -68
- data/spec/controllers/entities/leads_controller_spec.rb +126 -126
- data/spec/controllers/entities/opportunities_controller_spec.rb +101 -101
- data/spec/controllers/entities_controller_spec.rb +5 -0
- data/spec/controllers/home_controller_spec.rb +30 -30
- data/spec/controllers/tasks_controller_spec.rb +42 -40
- data/spec/controllers/users_controller_spec.rb +43 -113
- data/spec/factories/account_factories.rb +13 -13
- data/spec/factories/campaign_factories.rb +8 -8
- data/spec/factories/contact_factories.rb +18 -18
- data/spec/factories/field_factories.rb +11 -10
- data/spec/factories/lead_factories.rb +13 -13
- data/spec/factories/list_factories.rb +3 -3
- data/spec/factories/opportunity_factories.rb +9 -9
- data/spec/factories/sequences.rb +1 -1
- data/spec/factories/setting_factories.rb +5 -5
- data/spec/factories/shared_factories.rb +25 -23
- data/spec/factories/subscription_factories.rb +1 -1
- data/spec/factories/tag_factories.rb +1 -1
- data/spec/factories/task_factories.rb +11 -11
- data/spec/factories/user_factories.rb +27 -30
- data/spec/features/accounts_spec.rb +17 -4
- data/spec/features/admin/groups_spec.rb +2 -2
- data/spec/features/admin/users_spec.rb +4 -2
- data/spec/features/campaigns_spec.rb +5 -5
- data/spec/features/contacts_spec.rb +11 -5
- data/spec/features/dashboard_spec.rb +8 -8
- data/spec/features/devise/sign_in_spec.rb +58 -0
- data/spec/features/devise/sign_up_spec.rb +36 -0
- data/spec/features/leads_spec.rb +5 -5
- data/spec/features/opportunities_overview_spec.rb +16 -16
- data/spec/features/opportunities_spec.rb +35 -9
- data/spec/features/support/autocomlete_helper.rb +17 -0
- data/spec/features/support/browser.rb +5 -9
- data/spec/features/tasks_spec.rb +5 -5
- data/spec/helpers/admin/field_groups_helper_spec.rb +1 -1
- data/spec/helpers/application_helper_spec.rb +1 -1
- data/spec/helpers/tasks_helper_spec.rb +1 -1
- data/spec/helpers/users_helper_spec.rb +7 -7
- data/spec/lib/comment_extensions_spec.rb +11 -5
- data/spec/lib/errors_spec.rb +2 -2
- data/spec/lib/mail_processor/base_spec.rb +3 -3
- data/spec/lib/mail_processor/comment_replies_spec.rb +3 -3
- data/spec/lib/mail_processor/dropbox_spec.rb +17 -17
- data/spec/lib/mail_processor/sample_emails/dropbox.rb +8 -8
- data/spec/lib/permissions_spec.rb +15 -28
- data/spec/mailers/devise_mailer_spec.rb +35 -0
- data/spec/mailers/user_mailer_spec.rb +6 -32
- data/spec/models/entities/account_spec.rb +58 -32
- data/spec/models/entities/campaign_spec.rb +18 -25
- data/spec/models/entities/contact_spec.rb +113 -21
- data/spec/models/entities/lead_spec.rb +9 -11
- data/spec/models/entities/opportunity_spec.rb +45 -45
- data/spec/models/fields/custom_field_date_pair_spec.rb +4 -2
- data/spec/models/fields/custom_field_spec.rb +21 -19
- data/spec/models/list_spec.rb +2 -2
- data/spec/models/observers/entity_observer_spec.rb +7 -7
- data/spec/models/polymorphic/address_spec.rb +1 -1
- data/spec/models/polymorphic/avatar_spec.rb +5 -5
- data/spec/models/polymorphic/comment_spec.rb +5 -5
- data/spec/models/polymorphic/task_spec.rb +65 -58
- data/spec/models/polymorphic/version_spec.rb +31 -31
- data/spec/models/setting_spec.rb +2 -2
- data/spec/models/users/preference_spec.rb +6 -6
- data/spec/models/users/user_spec.rb +46 -50
- data/spec/routing/users_routing_spec.rb +30 -8
- data/spec/shared/controllers.rb +3 -9
- data/spec/shared/models.rb +22 -22
- data/spec/spec_helper.rb +12 -4
- data/spec/support/assert_select.rb +1 -0
- data/spec/support/devise_helpers.rb +28 -0
- data/spec/{features/support/helpers.rb → support/feature_helpers.rb} +11 -11
- data/spec/support/macros.rb +7 -4
- data/spec/views/accounts/_edit.haml_spec.rb +1 -1
- data/spec/views/accounts/create.js.haml_spec.rb +3 -3
- data/spec/views/accounts/destroy.js.haml_spec.rb +1 -1
- data/spec/views/accounts/edit.js.haml_spec.rb +2 -2
- data/spec/views/accounts/index.haml_spec.rb +2 -2
- data/spec/views/accounts/index.js.haml_spec.rb +1 -1
- data/spec/views/accounts/show.haml_spec.rb +4 -4
- data/spec/views/accounts/update.js.haml_spec.rb +1 -1
- data/spec/views/admin/field_groups/create.js.haml_spec.rb +1 -1
- data/spec/views/admin/field_groups/destroy.js.haml_spec.rb +1 -1
- data/spec/views/admin/field_groups/edit.js.haml_spec.rb +1 -1
- data/spec/views/admin/field_groups/new.js.haml_spec.rb +1 -1
- data/spec/views/admin/field_groups/update.js.haml_spec.rb +1 -1
- data/spec/views/admin/users/create.js.haml_spec.rb +2 -2
- data/spec/views/admin/users/destroy.js.haml_spec.rb +2 -2
- data/spec/views/admin/users/edit.js.haml_spec.rb +2 -2
- data/spec/views/admin/users/index.haml_spec.rb +1 -1
- data/spec/views/admin/users/index.js.haml_spec.rb +2 -2
- data/spec/views/admin/users/reactivate.js.haml_spec.rb +1 -1
- data/spec/views/admin/users/suspend.js.haml_spec.rb +1 -1
- data/spec/views/admin/users/update.js.haml_spec.rb +1 -1
- data/spec/views/application/auto_complete.haml_spec.rb +3 -3
- data/spec/views/campaigns/_edit.haml_spec.rb +1 -1
- data/spec/views/campaigns/create.js.haml_spec.rb +4 -4
- data/spec/views/campaigns/destroy.js.haml_spec.rb +1 -1
- data/spec/views/campaigns/edit.js.haml_spec.rb +4 -4
- data/spec/views/campaigns/index.haml_spec.rb +1 -1
- data/spec/views/campaigns/index.js.haml_spec.rb +2 -2
- data/spec/views/campaigns/show.haml_spec.rb +4 -4
- data/spec/views/campaigns/update.js.haml_spec.rb +2 -2
- data/spec/views/contacts/_edit.haml_spec.rb +7 -7
- data/spec/views/contacts/_new.haml_spec.rb +1 -1
- data/spec/views/contacts/create.js.haml_spec.rb +5 -5
- data/spec/views/contacts/destroy.js.haml_spec.rb +1 -1
- data/spec/views/contacts/edit.js.haml_spec.rb +4 -4
- data/spec/views/contacts/index.haml_spec.rb +1 -1
- data/spec/views/contacts/index.js.html_spec.rb +2 -2
- data/spec/views/contacts/new.js.haml_spec.rb +1 -1
- data/spec/views/contacts/show.haml_spec.rb +3 -3
- data/spec/views/contacts/update.js.haml_spec.rb +5 -5
- data/spec/views/home/index.haml_spec.rb +1 -1
- data/spec/views/home/index.js.haml_spec.rb +1 -1
- data/spec/views/home/options.js.haml_spec.rb +2 -2
- data/spec/views/leads/_convert.haml_spec.rb +3 -3
- data/spec/views/leads/_edit.haml_spec.rb +2 -2
- data/spec/views/leads/_new.haml_spec.rb +2 -2
- data/spec/views/leads/_sidebar_show.haml_spec.rb +5 -5
- data/spec/views/leads/convert.js.haml_spec.rb +4 -4
- data/spec/views/leads/create.js.haml_spec.rb +5 -5
- data/spec/views/leads/destroy.js.haml_spec.rb +2 -2
- data/spec/views/leads/edit.js.haml_spec.rb +4 -4
- data/spec/views/leads/index.haml_spec.rb +1 -1
- data/spec/views/leads/index.js.haml_spec.rb +1 -1
- data/spec/views/leads/new.js.haml_spec.rb +1 -1
- data/spec/views/leads/promote.js.haml_spec.rb +7 -7
- data/spec/views/leads/reject.js.haml_spec.rb +2 -2
- data/spec/views/leads/show.haml_spec.rb +2 -2
- data/spec/views/leads/update.js.haml_spec.rb +4 -4
- data/spec/views/opportunities/_edit.haml_spec.rb +7 -7
- data/spec/views/opportunities/_new.haml_spec.rb +2 -2
- data/spec/views/opportunities/create.js.haml_spec.rb +6 -6
- data/spec/views/opportunities/destroy.js.haml_spec.rb +3 -3
- data/spec/views/opportunities/edit.js.haml_spec.rb +3 -3
- data/spec/views/opportunities/index.haml_spec.rb +1 -1
- data/spec/views/opportunities/index.js.haml_spec.rb +1 -1
- data/spec/views/opportunities/new.js.haml_spec.rb +1 -1
- data/spec/views/opportunities/show.haml_spec.rb +3 -3
- data/spec/views/opportunities/update.js.haml_spec.rb +5 -5
- data/spec/views/tasks/_edit.haml_spec.rb +1 -1
- data/spec/views/tasks/complete.js.haml_spec.rb +4 -4
- data/spec/views/tasks/create.js.haml_spec.rb +6 -6
- data/spec/views/tasks/destroy.js.haml_spec.rb +2 -2
- data/spec/views/tasks/index.haml_spec.rb +4 -4
- data/spec/views/tasks/new.js.haml_spec.rb +1 -1
- data/spec/views/tasks/uncomplete.js.haml_spec.rb +2 -2
- data/spec/views/tasks/update.js.haml_spec.rb +18 -18
- data/spec/views/users/upload_avatar.js.haml_spec.rb +2 -2
- metadata +49 -71
- data/app/controllers/authentications_controller.rb +0 -53
- data/app/models/users/authentication.rb +0 -56
- data/app/views/authentications/new.html.haml +0 -19
- data/app/views/passwords/edit.html.haml +0 -15
- data/app/views/passwords/new.html.haml +0 -10
- data/app/views/user_mailer/password_reset_instructions.html.haml +0 -6
- data/app/views/users/new.html.haml +0 -19
- data/spec/controllers/authentications_controller_spec.rb +0 -150
- data/spec/controllers/passwords_controller_spec.rb +0 -32
- data/spec/models/users/authentication_spec.rb +0 -19
- data/spec/support/auth_macros.rb +0 -49
- data/spec/views/authentications/new.haml_spec.rb +0 -31
@@ -25,17 +25,17 @@ require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
|
|
25
25
|
|
26
26
|
describe Comment do
|
27
27
|
it "should create a new instance given valid attributes" do
|
28
|
-
Comment.create!(comment: "Hello", user:
|
28
|
+
Comment.create!(comment: "Hello", user: create(:user), commentable: create(:lead))
|
29
29
|
end
|
30
30
|
|
31
31
|
it "should subscribe users mentioned in the comment to the entity, and notify them via email" do
|
32
32
|
expected_users = [
|
33
|
-
|
34
|
-
|
33
|
+
create(:user, username: "test_user"),
|
34
|
+
create(:user, username: "another_user")
|
35
35
|
]
|
36
|
-
entity =
|
36
|
+
entity = create(:lead)
|
37
37
|
Comment.create!(comment: "Hey @test_user, take a look at this. Also show @another_user",
|
38
|
-
user:
|
38
|
+
user: create(:user),
|
39
39
|
commentable: entity)
|
40
40
|
|
41
41
|
expected_users.each do |user|
|
@@ -32,11 +32,9 @@
|
|
32
32
|
require 'spec_helper'
|
33
33
|
|
34
34
|
describe Task do
|
35
|
-
let(:current_user) { FactoryGirl.create(:user) }
|
36
|
-
|
37
35
|
describe "Task/Create" do
|
38
36
|
it "should create a new task instance given valid attributes" do
|
39
|
-
task =
|
37
|
+
task = create(:task)
|
40
38
|
expect(task).to be_valid
|
41
39
|
expect(task.errors).to be_empty
|
42
40
|
end
|
@@ -47,14 +45,14 @@ describe Task do
|
|
47
45
|
end
|
48
46
|
|
49
47
|
it "should create a task with due date selected from dropdown within #{offset ? 'different' : 'current'} timezone" do
|
50
|
-
task =
|
48
|
+
task = create(:task, due_at: Time.now.end_of_week, bucket: "due_this_week")
|
51
49
|
expect(task.errors).to be_empty
|
52
50
|
expect(task.bucket).to eq("due_this_week")
|
53
51
|
expect(task.due_at.change(usec: 0)).to eq(Time.zone.now.end_of_week.change(usec: 0))
|
54
52
|
end
|
55
53
|
|
56
54
|
it "should create a task with due date selected from the calendar within #{offset ? 'different' : 'current'} timezone" do
|
57
|
-
task =
|
55
|
+
task = create(:task, bucket: "specific_time", calendar: "2020-03-20")
|
58
56
|
expect(task.errors).to be_empty
|
59
57
|
expect(task.bucket).to eq("specific_time")
|
60
58
|
expect(task.due_at.to_i).to eq(Time.parse("2020-03-20").to_i)
|
@@ -64,23 +62,23 @@ describe Task do
|
|
64
62
|
|
65
63
|
describe "Task/Update" do
|
66
64
|
it "should update task name" do
|
67
|
-
task =
|
65
|
+
task = create(:task, name: "Hello")
|
68
66
|
task.update_attributes(name: "World")
|
69
67
|
expect(task.errors).to be_empty
|
70
68
|
expect(task.name).to eq("World")
|
71
69
|
end
|
72
70
|
|
73
71
|
it "should update task category" do
|
74
|
-
task =
|
72
|
+
task = create(:task, category: "call")
|
75
73
|
task.update_attributes(category: "email")
|
76
74
|
expect(task.errors).to be_empty
|
77
75
|
expect(task.category).to eq("email")
|
78
76
|
end
|
79
77
|
|
80
78
|
it "should reassign the task to another person" do
|
81
|
-
him =
|
82
|
-
her =
|
83
|
-
task =
|
79
|
+
him = create(:user)
|
80
|
+
her = create(:user)
|
81
|
+
task = create(:task, assigned_to: him.id)
|
84
82
|
task.update_attributes(assigned_to: her.id)
|
85
83
|
expect(task.errors).to be_empty
|
86
84
|
expect(task.assigned_to).to eq(her.id)
|
@@ -88,8 +86,8 @@ describe Task do
|
|
88
86
|
end
|
89
87
|
|
90
88
|
it "should reassign the task from another person to myself" do
|
91
|
-
him =
|
92
|
-
task =
|
89
|
+
him = create(:user)
|
90
|
+
task = create(:task, assigned_to: him.id)
|
93
91
|
task.update_attributes(assigned_to: "")
|
94
92
|
expect(task.errors).to be_empty
|
95
93
|
expect(task.assigned_to).to eq(nil)
|
@@ -102,7 +100,7 @@ describe Task do
|
|
102
100
|
end
|
103
101
|
|
104
102
|
it "should update due date based on selected bucket within #{offset ? 'different' : 'current'} timezone" do
|
105
|
-
task =
|
103
|
+
task = create(:task, due_at: Time.now.midnight.tomorrow, bucket: "due_tomorrow")
|
106
104
|
task.update_attributes(bucket: "due_this_week")
|
107
105
|
expect(task.errors).to be_empty
|
108
106
|
expect(task.bucket).to eq("due_this_week")
|
@@ -110,7 +108,7 @@ describe Task do
|
|
110
108
|
end
|
111
109
|
|
112
110
|
it "should update due date if specific calendar date selected within #{offset ? 'different' : 'current'} timezone" do
|
113
|
-
task =
|
111
|
+
task = create(:task, due_at: Time.now.midnight.tomorrow, bucket: "due_tomorrow")
|
114
112
|
task.update_attributes(bucket: "specific_time", calendar: "2020-03-20")
|
115
113
|
expect(task.errors).to be_empty
|
116
114
|
expect(task.bucket).to eq("specific_time")
|
@@ -120,45 +118,48 @@ describe Task do
|
|
120
118
|
end
|
121
119
|
|
122
120
|
describe "Task/Complete" do
|
123
|
-
it "should
|
124
|
-
task =
|
125
|
-
task.update_attributes(completed_at: Time.now, completed_by:
|
121
|
+
it "should complete a task that is overdue" do
|
122
|
+
task = create(:task, due_at: 2.days.ago, bucket: "overdue")
|
123
|
+
task.update_attributes(completed_at: Time.now, completed_by: task.user.id)
|
124
|
+
|
126
125
|
expect(task.errors).to be_empty
|
127
126
|
expect(task.completed_at).not_to eq(nil)
|
128
|
-
expect(task.completor).to eq(
|
127
|
+
expect(task.completor).to eq(task.user)
|
129
128
|
end
|
130
129
|
|
131
130
|
it "should complete a task due sometime in the future" do
|
132
|
-
task =
|
133
|
-
task.update_attributes(completed_at: Time.now, completed_by:
|
131
|
+
task = create(:task, due_at: Time.now.midnight.tomorrow, bucket: "due_tomorrow")
|
132
|
+
task.update_attributes(completed_at: Time.now, completed_by: task.user.id)
|
133
|
+
|
134
134
|
expect(task.errors).to be_empty
|
135
135
|
expect(task.completed_at).not_to eq(nil)
|
136
|
-
expect(task.completor).to eq(
|
136
|
+
expect(task.completor).to eq(task.user)
|
137
137
|
end
|
138
138
|
|
139
139
|
it "should complete a task that is due on specific date in the future" do
|
140
|
-
task =
|
140
|
+
task = create(:task, calendar: "10/10/2022 12:00 AM", bucket: "specific_time")
|
141
141
|
task.calendar = nil # Calendar is not saved in the database; we need it only to set the :due_at.
|
142
|
-
task.update_attributes(completed_at: Time.now, completed_by:
|
142
|
+
task.update_attributes(completed_at: Time.now, completed_by: task.user.id)
|
143
143
|
expect(task.errors).to be_empty
|
144
144
|
expect(task.completed_at).not_to eq(nil)
|
145
|
-
expect(task.completor).to eq(
|
145
|
+
expect(task.completor).to eq(task.user)
|
146
146
|
end
|
147
147
|
|
148
148
|
it "should complete a task that is due on specific date in the past" do
|
149
|
-
task =
|
149
|
+
task = create(:task, calendar: "10/10/1992 12:00 AM", bucket: "specific_time")
|
150
150
|
task.calendar = nil # Calendar is not saved in the database; we need it only to set the :due_at.
|
151
|
-
task.update_attributes(completed_at: Time.now, completed_by:
|
151
|
+
task.update_attributes(completed_at: Time.now, completed_by: task.user.id)
|
152
152
|
expect(task.errors).to be_empty
|
153
153
|
expect(task.completed_at).not_to eq(nil)
|
154
|
-
expect(task.completor).to eq(
|
154
|
+
expect(task.completor).to eq(task.user)
|
155
155
|
end
|
156
156
|
|
157
157
|
it "completion should preserve original due date" do
|
158
158
|
due_at = Time.now - 42.days
|
159
|
-
task =
|
160
|
-
|
161
|
-
task.update_attributes(completed_at: Time.now, completed_by:
|
159
|
+
task = create(:task, due_at: due_at, bucket: "specific_time",
|
160
|
+
calendar: due_at.strftime('%Y-%m-%d %H:%M'))
|
161
|
+
task.update_attributes(completed_at: Time.now, completed_by: task.user.id, calendar: '')
|
162
|
+
|
162
163
|
expect(task.completed?).to eq(true)
|
163
164
|
expect(task.due_at).to eq(due_at.utc.strftime('%Y-%m-%d %H:%M'))
|
164
165
|
end
|
@@ -166,64 +167,70 @@ describe Task do
|
|
166
167
|
|
167
168
|
# named_scope :my, lambda { |user| { :conditions => [ "(user_id = ? AND assigned_to IS NULL) OR assigned_to = ?", user.id, user.id ], :include => :assignee } }
|
168
169
|
describe "task.my?" do
|
170
|
+
let(:current_user) { create(:user) }
|
171
|
+
|
169
172
|
it "should match a task created by the user" do
|
170
|
-
task =
|
173
|
+
task = create(:task, user: current_user, assignee: nil)
|
171
174
|
expect(task.my?(current_user)).to eq(true)
|
172
175
|
end
|
173
176
|
|
174
177
|
it "should match a task assigned to the user" do
|
175
|
-
task =
|
178
|
+
task = create(:task, user: create(:user), assignee: current_user)
|
176
179
|
expect(task.my?(current_user)).to eq(true)
|
177
180
|
end
|
178
181
|
|
179
182
|
it "should Not match a task not created by the user" do
|
180
|
-
task =
|
183
|
+
task = create(:task, user: create(:user))
|
181
184
|
expect(task.my?(current_user)).to eq(false)
|
182
185
|
end
|
183
186
|
|
184
187
|
it "should Not match a task created by the user but assigned to somebody else" do
|
185
|
-
task =
|
188
|
+
task = create(:task, user: current_user, assignee: create(:user))
|
186
189
|
expect(task.my?(current_user)).to eq(false)
|
187
190
|
end
|
188
191
|
end
|
189
192
|
|
190
193
|
# named_scope :assigned_by, lambda { |user| { :conditions => [ "user_id = ? AND assigned_to IS NOT NULL AND assigned_to != ?", user.id, user.id ], :include => :assignee } }
|
191
194
|
describe "task.assigned_by?" do
|
195
|
+
let(:current_user) { create(:user) }
|
196
|
+
|
192
197
|
it "should match a task assigned by the user to somebody else" do
|
193
|
-
task =
|
198
|
+
task = create(:task, user: current_user, assignee: create(:user))
|
194
199
|
expect(task.assigned_by?(current_user)).to eq(true)
|
195
200
|
end
|
196
201
|
|
197
202
|
it "should Not match a task not created by the user" do
|
198
|
-
task =
|
203
|
+
task = create(:task, user: create(:user))
|
199
204
|
expect(task.assigned_by?(current_user)).to eq(false)
|
200
205
|
end
|
201
206
|
|
202
207
|
it "should Not match a task not assigned to anybody" do
|
203
|
-
task =
|
208
|
+
task = create(:task, assignee: nil)
|
204
209
|
expect(task.assigned_by?(current_user)).to eq(false)
|
205
210
|
end
|
206
211
|
|
207
212
|
it "should Not match a task assigned to the user" do
|
208
|
-
task =
|
213
|
+
task = create(:task, assignee: current_user)
|
209
214
|
expect(task.assigned_by?(current_user)).to eq(false)
|
210
215
|
end
|
211
216
|
end
|
212
217
|
|
213
218
|
# named_scope :tracked_by, lambda { |user| { :conditions => [ "user_id = ? OR assigned_to = ?", user.id, user.id ], :include => :assignee } }
|
214
219
|
describe "task.tracked_by?" do
|
220
|
+
let(:current_user) { create(:user) }
|
221
|
+
|
215
222
|
it "should match a task created by the user" do
|
216
|
-
task =
|
223
|
+
task = create(:task, user: current_user)
|
217
224
|
expect(task.tracked_by?(current_user)).to eq(true)
|
218
225
|
end
|
219
226
|
|
220
227
|
it "should match a task assigned to the user" do
|
221
|
-
task =
|
228
|
+
task = create(:task, assignee: current_user)
|
222
229
|
expect(task.tracked_by?(current_user)).to eq(true)
|
223
230
|
end
|
224
231
|
|
225
232
|
it "should Not match a task that is neither created nor assigned to the user" do
|
226
|
-
task =
|
233
|
+
task = create(:task, user: create(:user), assignee: create(:user))
|
227
234
|
expect(task.tracked_by?(current_user)).to eq(false)
|
228
235
|
end
|
229
236
|
end
|
@@ -310,24 +317,24 @@ describe Task do
|
|
310
317
|
|
311
318
|
describe "Exportable" do
|
312
319
|
describe "unassigned tasks" do
|
313
|
-
let(:task1) {
|
314
|
-
let(:task2) {
|
320
|
+
let(:task1) { build(:task, user: create(:user), assignee: nil) }
|
321
|
+
let(:task2) { build(:task, user: create(:user, first_name: nil, last_name: nil), assignee: nil) }
|
315
322
|
it_should_behave_like("exportable") do
|
316
323
|
let(:exported) { [task1, task2] }
|
317
324
|
end
|
318
325
|
end
|
319
326
|
|
320
327
|
describe "assigned tasks" do
|
321
|
-
let(:task1) {
|
322
|
-
let(:task2) {
|
328
|
+
let(:task1) { build(:task, user: create(:user), assignee: create(:user)) }
|
329
|
+
let(:task2) { build(:task, user: create(:user, first_name: nil, last_name: nil), assignee: create(:user, first_name: nil, last_name: nil)) }
|
323
330
|
it_should_behave_like("exportable") do
|
324
331
|
let(:exported) { [task1, task2] }
|
325
332
|
end
|
326
333
|
end
|
327
334
|
|
328
335
|
describe "completed tasks" do
|
329
|
-
let(:task1) {
|
330
|
-
let(:task2) {
|
336
|
+
let(:task1) { build(:task, user: create(:user), completor: create(:user), completed_at: 1.day.ago) }
|
337
|
+
let(:task2) { build(:task, user: create(:user, first_name: nil, last_name: nil), completor: create(:user, first_name: nil, last_name: nil), completed_at: 1.day.ago) }
|
331
338
|
it_should_behave_like("exportable") do
|
332
339
|
let(:exported) { [task1, task2] }
|
333
340
|
end
|
@@ -345,13 +352,13 @@ describe Task do
|
|
345
352
|
describe "scopes" do
|
346
353
|
context "visible_on_dashboard" do
|
347
354
|
before :each do
|
348
|
-
@user =
|
349
|
-
@t1 =
|
350
|
-
@t2 =
|
351
|
-
@t3 =
|
352
|
-
@t4 =
|
353
|
-
@t5 =
|
354
|
-
@t6 =
|
355
|
+
@user = create(:user)
|
356
|
+
@t1 = create(:task, user: @user)
|
357
|
+
@t2 = create(:task, user: @user, assignee: create(:user))
|
358
|
+
@t3 = create(:task, user: create(:user), assignee: @user)
|
359
|
+
@t4 = create(:task, user: create(:user), assignee: create(:user))
|
360
|
+
@t5 = create(:task, user: create(:user), assignee: @user)
|
361
|
+
@t6 = create(:completed_task, assignee: @user)
|
355
362
|
end
|
356
363
|
|
357
364
|
it "should show tasks which have been created by the user and are unassigned" do
|
@@ -377,10 +384,10 @@ describe Task do
|
|
377
384
|
|
378
385
|
context "by_due_at" do
|
379
386
|
it "should show tasks ordered by due_at" do
|
380
|
-
t1 =
|
381
|
-
t2 =
|
382
|
-
t3 =
|
383
|
-
t4 =
|
387
|
+
t1 = create(:task, name: 't1', bucket: "due_asap")
|
388
|
+
t2 = create(:task, calendar: 5.days.from_now.strftime("%Y-%m-%d %H:%M"), bucket: "specific_time")
|
389
|
+
t3 = create(:task, name: 't3', bucket: "due_next_week")
|
390
|
+
t4 = create(:task, calendar: 20.days.from_now.strftime("%Y-%m-%d %H:%M"), bucket: "specific_time")
|
384
391
|
expect(Task.by_due_at).to eq([t1, t2, t3, t4])
|
385
392
|
end
|
386
393
|
end
|
@@ -23,20 +23,20 @@
|
|
23
23
|
require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
|
24
24
|
|
25
25
|
describe Version, versioning: true do
|
26
|
-
let(:current_user) {
|
27
|
-
before { PaperTrail.whodunnit = current_user.id.to_s }
|
26
|
+
let(:current_user) { create(:user) }
|
27
|
+
before { PaperTrail.request.whodunnit = current_user.id.to_s }
|
28
28
|
|
29
29
|
it "should create a new instance given valid attributes" do
|
30
|
-
|
30
|
+
create(:version, whodunnit: PaperTrail.request.whodunnit, item: create(:lead))
|
31
31
|
end
|
32
32
|
|
33
33
|
describe "with multiple version records" do
|
34
34
|
before do
|
35
|
-
@lead =
|
35
|
+
@lead = create(:lead)
|
36
36
|
|
37
37
|
%w[create destroy update view].each do |event|
|
38
|
-
|
39
|
-
|
38
|
+
create(:version, event: event, item: @lead, whodunnit: PaperTrail.request.whodunnit)
|
39
|
+
create(:version, event: event, item: @lead, whodunnit: "1")
|
40
40
|
end
|
41
41
|
end
|
42
42
|
|
@@ -71,8 +71,8 @@ describe Version, versioning: true do
|
|
71
71
|
%w[account campaign contact lead opportunity task].each do |item|
|
72
72
|
describe "Create, update, and delete (#{item})" do
|
73
73
|
before :each do
|
74
|
-
@item =
|
75
|
-
@conditions = { item_id: @item.id, item_type: @item.class.name, whodunnit: PaperTrail.whodunnit }
|
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
76
|
end
|
77
77
|
|
78
78
|
it "should add a version when creating new #{item}" do
|
@@ -99,9 +99,9 @@ describe Version, versioning: true do
|
|
99
99
|
end
|
100
100
|
|
101
101
|
it "should add a version when commenting on a #{item}" do
|
102
|
-
@comment =
|
102
|
+
@comment = create(:comment, commentable: @item, user: current_user)
|
103
103
|
|
104
|
-
@version = Version.where(related_id: @item.id, related_type: @item.class.name, whodunnit: PaperTrail.whodunnit, event: 'create').first
|
104
|
+
@version = Version.where(related_id: @item.id, related_type: @item.class.name, whodunnit: PaperTrail.request.whodunnit, event: 'create').first
|
105
105
|
expect(@version).not_to eq(nil)
|
106
106
|
end
|
107
107
|
end
|
@@ -109,7 +109,7 @@ describe Version, versioning: true do
|
|
109
109
|
|
110
110
|
describe "Recently viewed items (task)" do
|
111
111
|
before do
|
112
|
-
@task =
|
112
|
+
@task = create(:task)
|
113
113
|
@conditions = { item_id: @task.id, item_type: @task.class.name }
|
114
114
|
end
|
115
115
|
|
@@ -128,8 +128,8 @@ describe Version, versioning: true do
|
|
128
128
|
|
129
129
|
describe "Action refinements for task updates" do
|
130
130
|
before do
|
131
|
-
@task =
|
132
|
-
@conditions = { item_id: @task.id, item_type: @task.class.name, whodunnit: PaperTrail.whodunnit }
|
131
|
+
@task = create(:task, user: current_user)
|
132
|
+
@conditions = { item_id: @task.id, item_type: @task.class.name, whodunnit: PaperTrail.request.whodunnit }
|
133
133
|
end
|
134
134
|
|
135
135
|
it "should create 'completed' task event" do
|
@@ -147,7 +147,7 @@ describe Version, versioning: true do
|
|
147
147
|
end
|
148
148
|
|
149
149
|
it "should create 'rescheduled' task event" do
|
150
|
-
@task.update(bucket: "due_tomorrow") #
|
150
|
+
@task.update(bucket: "due_tomorrow") # FactoryBot creates :due_asap task
|
151
151
|
|
152
152
|
versions = Version.where(@conditions)
|
153
153
|
expect(versions.pluck(:event)).to include('reschedule')
|
@@ -156,8 +156,8 @@ describe Version, versioning: true do
|
|
156
156
|
|
157
157
|
describe "Rejecting a lead" do
|
158
158
|
before do
|
159
|
-
@lead =
|
160
|
-
@conditions = { item_id: @lead.id, item_type: @lead.class.name, whodunnit: PaperTrail.whodunnit }
|
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
161
|
end
|
162
162
|
|
163
163
|
it "should create 'rejected' lead event" do
|
@@ -170,12 +170,12 @@ describe Version, versioning: true do
|
|
170
170
|
|
171
171
|
describe "Permissions" do
|
172
172
|
before do
|
173
|
-
@user =
|
173
|
+
@user = create(:user)
|
174
174
|
Version.delete_all
|
175
175
|
end
|
176
176
|
|
177
177
|
it "should not show the create/update versions if the item is private" do
|
178
|
-
@item =
|
178
|
+
@item = create(:account, user: current_user, access: "Private")
|
179
179
|
@item.update(name: 'New Name')
|
180
180
|
|
181
181
|
versions = Version.where(item_id: @item.id, item_type: @item.class.name)
|
@@ -186,7 +186,7 @@ describe Version, versioning: true do
|
|
186
186
|
end
|
187
187
|
|
188
188
|
it "should not show the destroy version if the item is private" do
|
189
|
-
@item =
|
189
|
+
@item = create(:account, user: current_user, access: "Private")
|
190
190
|
@item.destroy
|
191
191
|
|
192
192
|
versions = Version.where(item_id: @item.id, item_type: @item.class.name)
|
@@ -197,10 +197,10 @@ describe Version, versioning: true do
|
|
197
197
|
end
|
198
198
|
|
199
199
|
it "should not show create/update versions if the item was not shared with the user" do
|
200
|
-
@item =
|
201
|
-
|
202
|
-
|
203
|
-
|
200
|
+
@item = create(:account,
|
201
|
+
user: current_user,
|
202
|
+
access: "Shared",
|
203
|
+
permissions: [build(:permission, user: current_user, asset: @item)])
|
204
204
|
@item.update(name: 'New Name')
|
205
205
|
|
206
206
|
versions = Version.where(item_id: @item.id, item_type: @item.class.name)
|
@@ -211,10 +211,10 @@ describe Version, versioning: true do
|
|
211
211
|
end
|
212
212
|
|
213
213
|
it "should not show the destroy version if the item was not shared with the user" do
|
214
|
-
@item =
|
215
|
-
|
216
|
-
|
217
|
-
|
214
|
+
@item = create(:account,
|
215
|
+
user: current_user,
|
216
|
+
access: "Shared",
|
217
|
+
permissions: [build(:permission, user: current_user, asset: @item)])
|
218
218
|
@item.destroy
|
219
219
|
|
220
220
|
versions = Version.where(item_id: @item.id, item_type: @item.class.name)
|
@@ -225,10 +225,10 @@ describe Version, versioning: true do
|
|
225
225
|
end
|
226
226
|
|
227
227
|
it "should show create/update versions if the item was shared with the user" do
|
228
|
-
@item =
|
229
|
-
|
230
|
-
|
231
|
-
|
228
|
+
@item = create(:account,
|
229
|
+
user: current_user,
|
230
|
+
access: "Shared",
|
231
|
+
permissions: [build(:permission, user: @user, asset: @item)])
|
232
232
|
@item.update(name: 'New Name')
|
233
233
|
|
234
234
|
versions = Version.where(item_id: @item.id, item_type: @item.class.name)
|