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,517 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
# Copyright (c) 2008-2013 Michael Dvorkin and contributors.
|
4
|
-
#
|
5
|
-
# Fat Free CRM is freely distributable under the terms of MIT license.
|
6
|
-
# See MIT-LICENSE file or http://www.opensource.org/licenses/mit-license.php
|
7
|
-
#------------------------------------------------------------------------------
|
8
|
-
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
9
|
-
|
10
|
-
describe TasksController do
|
11
|
-
def update_sidebar
|
12
|
-
@task_total = { key: :value, pairs: :etc }
|
13
|
-
allow(Task).to receive(:totals).and_return(@task_total)
|
14
|
-
end
|
15
|
-
|
16
|
-
def produce_tasks(user, view)
|
17
|
-
settings = (view != "completed" ? Setting.task_bucket : Setting.task_completed)
|
18
|
-
|
19
|
-
settings.each_with_object({}) do |due, hash|
|
20
|
-
hash[due] ||= []
|
21
|
-
if Date.tomorrow == Date.today.end_of_week && due == :due_tomorrow
|
22
|
-
due = :due_this_week
|
23
|
-
hash[due] ||= []
|
24
|
-
end
|
25
|
-
hash[due] << case view
|
26
|
-
when "pending"
|
27
|
-
create(:task, user: user, bucket: due.to_s, name: 'Example task')
|
28
|
-
when "assigned"
|
29
|
-
create(:task, user: user, bucket: due.to_s, assigned_to: 1)
|
30
|
-
when "completed"
|
31
|
-
completed_at = case due
|
32
|
-
when :completed_today
|
33
|
-
Date.yesterday + 1.day
|
34
|
-
when :completed_yesterday
|
35
|
-
Date.yesterday
|
36
|
-
when :completed_last_week
|
37
|
-
Date.today.beginning_of_week - 7.days
|
38
|
-
when :completed_this_month
|
39
|
-
Date.today.beginning_of_month
|
40
|
-
when :completed_last_month
|
41
|
-
Date.today.beginning_of_month - 1.day
|
42
|
-
end
|
43
|
-
create(:task, user: user, bucket: due.to_s, completed_at: completed_at)
|
44
|
-
end
|
45
|
-
hash
|
46
|
-
end
|
47
|
-
end
|
48
|
-
|
49
|
-
before(:each) do
|
50
|
-
login
|
51
|
-
set_current_tab(:tasks)
|
52
|
-
end
|
53
|
-
|
54
|
-
# GET /tasks
|
55
|
-
# GET /tasks.xml
|
56
|
-
#----------------------------------------------------------------------------
|
57
|
-
describe "responding to GET index" do
|
58
|
-
before do
|
59
|
-
update_sidebar
|
60
|
-
@timezone = Time.zone
|
61
|
-
Time.zone = 'UTC'
|
62
|
-
end
|
63
|
-
|
64
|
-
after do
|
65
|
-
Time.zone = @timezone
|
66
|
-
end
|
67
|
-
|
68
|
-
TASK_STATUSES.each do |view|
|
69
|
-
it "should expose all tasks as @tasks and render [index] template for #{view} view" do
|
70
|
-
@tasks = produce_tasks(current_user, view)
|
71
|
-
|
72
|
-
get :index, params: { view: view }
|
73
|
-
|
74
|
-
expect(assigns[:tasks].keys.map(&:to_sym) - @tasks.keys).to eq([])
|
75
|
-
expect(assigns[:tasks].values.flatten - @tasks.values.flatten).to eq([])
|
76
|
-
expect(assigns[:task_total].symbolize_keys).to eq(@task_total)
|
77
|
-
expect(response).to render_template("tasks/index")
|
78
|
-
end
|
79
|
-
|
80
|
-
it "should render all tasks as JSON for #{view} view" do
|
81
|
-
@tasks = produce_tasks(current_user, view)
|
82
|
-
get :index, params: { view: view, format: :json }
|
83
|
-
|
84
|
-
expect(assigns[:tasks].keys.map(&:to_sym) - @tasks.keys).to eq([])
|
85
|
-
expect(assigns[:tasks].values.flatten - @tasks.values.flatten).to eq([])
|
86
|
-
|
87
|
-
# TODO: This used to return "task" => {...} mappings, now just returns mappings
|
88
|
-
hash = ActiveSupport::JSON.decode(response.body)
|
89
|
-
hash.each_key do |key|
|
90
|
-
hash[key].each do |data|
|
91
|
-
task = Task.new(data)
|
92
|
-
expect(task).to be_instance_of(Task)
|
93
|
-
puts task.errors.inspect unless task.valid?
|
94
|
-
expect(task.valid?).to eq(true)
|
95
|
-
end
|
96
|
-
end
|
97
|
-
end
|
98
|
-
|
99
|
-
it "should render all tasks as xml for #{view} view" do
|
100
|
-
@tasks = produce_tasks(current_user, view)
|
101
|
-
get :index, params: { view: view, format: :xml }
|
102
|
-
|
103
|
-
expect(assigns[:tasks].keys.map(&:to_sym) - @tasks.keys).to eq([])
|
104
|
-
expect(assigns[:tasks].values.flatten - @tasks.values.flatten).to eq([])
|
105
|
-
hash = Hash.from_xml(response.body)
|
106
|
-
hash["hash"].each_key do |key|
|
107
|
-
hash["hash"][key].each do |attr|
|
108
|
-
task = Task.new(attr)
|
109
|
-
expect(task).to be_instance_of(Task)
|
110
|
-
expect(task.valid?).to eq(true)
|
111
|
-
end
|
112
|
-
end
|
113
|
-
end
|
114
|
-
end
|
115
|
-
end
|
116
|
-
|
117
|
-
# GET /tasks/1
|
118
|
-
# GET /tasks/1.xml
|
119
|
-
#----------------------------------------------------------------------------
|
120
|
-
describe "responding to GET show" do
|
121
|
-
TASK_STATUSES.each do |view|
|
122
|
-
it "should render the requested task as JSON for #{view} view" do
|
123
|
-
allow(Task).to receive_message_chain(:tracked_by, :find).and_return(task = double("Task"))
|
124
|
-
expect(task).to receive(:to_json).and_return("generated JSON")
|
125
|
-
|
126
|
-
request.env["HTTP_ACCEPT"] = "application/json"
|
127
|
-
get :show, params: { id: 42, view: "pending" }
|
128
|
-
expect(response.body).to eq("generated JSON")
|
129
|
-
end
|
130
|
-
|
131
|
-
it "should render the requested task as xml for #{view} view" do
|
132
|
-
allow(Task).to receive_message_chain(:tracked_by, :find).and_return(task = double("Task"))
|
133
|
-
expect(task).to receive(:to_xml).and_return("generated XML")
|
134
|
-
|
135
|
-
request.env["HTTP_ACCEPT"] = "application/xml"
|
136
|
-
get :show, params: { id: 42, view: "pending" }
|
137
|
-
expect(response.body).to eq("generated XML")
|
138
|
-
end
|
139
|
-
end
|
140
|
-
end
|
141
|
-
|
142
|
-
# GET /tasks/new
|
143
|
-
# GET /tasks/new.xml AJAX
|
144
|
-
#----------------------------------------------------------------------------
|
145
|
-
describe "responding to GET new" do
|
146
|
-
it "should expose a new task as @task and render [new] template" do
|
147
|
-
account = create(:account, user: current_user)
|
148
|
-
@task = build(:task, user: current_user, asset: account)
|
149
|
-
allow(Task).to receive(:new).and_return(@task)
|
150
|
-
@bucket = Setting.unroll(:task_bucket)[1..-1] << ["On Specific Date...", :specific_time]
|
151
|
-
@category = Setting.unroll(:task_category)
|
152
|
-
|
153
|
-
get :new, xhr: true
|
154
|
-
expect(assigns[:task]).to eq(@task)
|
155
|
-
expect(assigns[:bucket]).to eq(@bucket)
|
156
|
-
expect(assigns[:category]).to eq(@category)
|
157
|
-
expect(response).to render_template("tasks/new")
|
158
|
-
end
|
159
|
-
|
160
|
-
it "should find related asset when necessary" do
|
161
|
-
@asset = create(:account, id: 42)
|
162
|
-
|
163
|
-
get :new, params: { related: "account_42" }, xhr: true
|
164
|
-
expect(assigns[:asset]).to eq(@asset)
|
165
|
-
expect(response).to render_template("tasks/new")
|
166
|
-
end
|
167
|
-
|
168
|
-
describe "(when creating related task)" do
|
169
|
-
it "should redirect to parent asset's index page with the message if parent asset got deleted" do
|
170
|
-
@account = create(:account)
|
171
|
-
@account.destroy
|
172
|
-
|
173
|
-
get :new, params: { related: "account_#{@account.id}" }, xhr: true
|
174
|
-
expect(flash[:warning]).not_to eq(nil)
|
175
|
-
expect(response.body).to eq('window.location.href = "/accounts";')
|
176
|
-
end
|
177
|
-
|
178
|
-
it "should redirect to parent asset's index page with the message if parent asset got protected" do
|
179
|
-
@account = create(:account, access: "Private")
|
180
|
-
|
181
|
-
get :new, params: { related: "account_#{@account.id}" }, xhr: true
|
182
|
-
expect(flash[:warning]).not_to eq(nil)
|
183
|
-
expect(response.body).to eq('window.location.href = "/accounts";')
|
184
|
-
end
|
185
|
-
end
|
186
|
-
end
|
187
|
-
|
188
|
-
# GET /tasks/1/edit AJAX
|
189
|
-
#----------------------------------------------------------------------------
|
190
|
-
describe "responding to GET edit" do
|
191
|
-
it "should expose the requested task as @task and render [edit] template" do
|
192
|
-
@asset = create(:account, user: current_user)
|
193
|
-
@task = create(:task, user: current_user, asset: @asset)
|
194
|
-
@bucket = Setting.unroll(:task_bucket)[1..-1] << ["On Specific Date...", :specific_time]
|
195
|
-
@category = Setting.unroll(:task_category)
|
196
|
-
|
197
|
-
get :edit, params: { id: @task.id }, xhr: true
|
198
|
-
expect(assigns[:task]).to eq(@task)
|
199
|
-
expect(assigns[:bucket]).to eq(@bucket)
|
200
|
-
expect(assigns[:category]).to eq(@category)
|
201
|
-
expect(assigns[:asset]).to eq(@asset)
|
202
|
-
expect(response).to render_template("tasks/edit")
|
203
|
-
end
|
204
|
-
|
205
|
-
it "should find previously open task when necessary" do
|
206
|
-
@task = create(:task, user: current_user)
|
207
|
-
@previous = create(:task, id: 999, user: current_user)
|
208
|
-
|
209
|
-
get :edit, params: { id: @task.id, previous: 999 }, xhr: true
|
210
|
-
expect(assigns[:task]).to eq(@task)
|
211
|
-
expect(assigns[:previous]).to eq(@previous)
|
212
|
-
expect(response).to render_template("tasks/edit")
|
213
|
-
end
|
214
|
-
|
215
|
-
describe "(task got deleted or reassigned)" do
|
216
|
-
it "should reload current page with the flash message if the task got deleted" do
|
217
|
-
@task = create(:task, user: create(:user), assignee: current_user)
|
218
|
-
@task.destroy
|
219
|
-
|
220
|
-
get :edit, params: { id: @task.id }, xhr: true
|
221
|
-
expect(flash[:warning]).not_to eq(nil)
|
222
|
-
expect(response.body).to eq("window.location.reload();")
|
223
|
-
end
|
224
|
-
|
225
|
-
it "should reload current page with the flash message if the task got reassigned" do
|
226
|
-
@task = create(:task, user: create(:user), assignee: create(:user))
|
227
|
-
|
228
|
-
get :edit, params: { id: @task.id }, xhr: true
|
229
|
-
expect(flash[:warning]).not_to eq(nil)
|
230
|
-
expect(response.body).to eq("window.location.reload();")
|
231
|
-
end
|
232
|
-
end
|
233
|
-
|
234
|
-
describe "(previous task got deleted or reassigned)" do
|
235
|
-
before(:each) do
|
236
|
-
@task = create(:task, user: current_user)
|
237
|
-
@previous = create(:task, user: create(:user), assignee: current_user)
|
238
|
-
end
|
239
|
-
|
240
|
-
it "should notify the view if previous task got deleted" do
|
241
|
-
@previous.destroy
|
242
|
-
|
243
|
-
get :edit, params: { id: @task.id, previous: @previous.id }, xhr: true
|
244
|
-
expect(flash[:warning]).to eq(nil) # no warning, just silently remove the div
|
245
|
-
expect(assigns[:previous]).to eq(@previous.id)
|
246
|
-
expect(response).to render_template("tasks/edit")
|
247
|
-
end
|
248
|
-
|
249
|
-
it "should notify the view if previous task got reassigned" do
|
250
|
-
@previous.update_attribute(:assignee, create(:user))
|
251
|
-
|
252
|
-
get :edit, params: { id: @task.id, previous: @previous.id }, xhr: true
|
253
|
-
expect(flash[:warning]).to eq(nil)
|
254
|
-
expect(assigns[:previous]).to eq(@previous.id)
|
255
|
-
expect(response).to render_template("tasks/edit")
|
256
|
-
end
|
257
|
-
end
|
258
|
-
end
|
259
|
-
|
260
|
-
# POST /tasks
|
261
|
-
# POST /tasks.xml AJAX
|
262
|
-
#----------------------------------------------------------------------------
|
263
|
-
describe "responding to POST create" do
|
264
|
-
describe "with valid params" do
|
265
|
-
it "should expose a newly created task as @task and render [create] template" do
|
266
|
-
@task = build(:task, user: current_user)
|
267
|
-
allow(Task).to receive(:new).and_return(@task)
|
268
|
-
|
269
|
-
post :create, params: { task: { name: "Hello world" } }, xhr: true
|
270
|
-
expect(assigns(:task)).to eq(@task)
|
271
|
-
expect(assigns(:view)).to eq("pending")
|
272
|
-
expect(assigns[:task_total]).to eq(nil)
|
273
|
-
expect(response).to render_template("tasks/create")
|
274
|
-
end
|
275
|
-
|
276
|
-
["", "?view=pending", "?view=assigned", "?view=completed"].each do |view|
|
277
|
-
it "should update tasks sidebar when [create] is being called from [/tasks#{view}] page" do
|
278
|
-
@task = build(:task, user: current_user)
|
279
|
-
allow(Task).to receive(:new).and_return(@task)
|
280
|
-
|
281
|
-
request.env["HTTP_REFERER"] = "http://localhost/tasks#{view}"
|
282
|
-
post :create, params: { task: { name: "Hello world" } }, xhr: true
|
283
|
-
expect(assigns[:task_total]).to be_an_instance_of(HashWithIndifferentAccess)
|
284
|
-
end
|
285
|
-
end
|
286
|
-
end
|
287
|
-
|
288
|
-
describe "with invalid params" do
|
289
|
-
it "should expose a newly created but unsaved task as @lead and still render [create] template" do
|
290
|
-
@task = build(:task, name: nil, user: current_user)
|
291
|
-
allow(Task).to receive(:new).and_return(@task)
|
292
|
-
|
293
|
-
post :create, params: { task: {} }, xhr: true
|
294
|
-
expect(assigns(:task)).to eq(@task)
|
295
|
-
expect(assigns(:view)).to eq("pending")
|
296
|
-
expect(assigns[:task_total]).to eq(nil)
|
297
|
-
expect(response).to render_template("tasks/create")
|
298
|
-
end
|
299
|
-
end
|
300
|
-
end
|
301
|
-
|
302
|
-
# PUT /tasks/1
|
303
|
-
# PUT /tasks/1.xml AJAX
|
304
|
-
#----------------------------------------------------------------------------
|
305
|
-
describe "responding to PUT update" do
|
306
|
-
describe "with valid params" do
|
307
|
-
it "should update the requested task, expose it as @task, and render [update] template" do
|
308
|
-
@task = create(:task, name: "Hi", user: current_user)
|
309
|
-
|
310
|
-
put :update, params: { id: @task.id, task: { name: "Hello" } }, xhr: true
|
311
|
-
expect(@task.reload.name).to eq("Hello")
|
312
|
-
expect(assigns(:task)).to eq(@task)
|
313
|
-
expect(assigns(:view)).to eq("pending")
|
314
|
-
expect(assigns[:task_total]).to eq(nil)
|
315
|
-
expect(response).to render_template("tasks/update")
|
316
|
-
end
|
317
|
-
|
318
|
-
["", "?view=pending", "?view=assigned", "?view=completed"].each do |view|
|
319
|
-
it "should update tasks sidebar when [update] is being called from [/tasks#{view}] page" do
|
320
|
-
@task = create(:task, name: "Hi", user: current_user)
|
321
|
-
|
322
|
-
request.env["HTTP_REFERER"] = "http://localhost/tasks#{view}"
|
323
|
-
put :update, params: { id: @task.id, task: { name: "Hello" } }, xhr: true
|
324
|
-
expect(assigns[:task_total]).to be_an_instance_of(HashWithIndifferentAccess)
|
325
|
-
end
|
326
|
-
end
|
327
|
-
end
|
328
|
-
|
329
|
-
describe "with invalid params" do
|
330
|
-
it "should not update the task, but still expose it as @task and render [update] template" do
|
331
|
-
@task = create(:task, name: "Hi", user: current_user)
|
332
|
-
|
333
|
-
put :update, params: { id: @task.id, task: { name: nil } }, xhr: true
|
334
|
-
expect(@task.reload.name).to eq("Hi")
|
335
|
-
expect(assigns(:task)).to eq(@task)
|
336
|
-
expect(assigns(:view)).to eq("pending")
|
337
|
-
expect(assigns[:task_total]).to eq(nil)
|
338
|
-
expect(response).to render_template("tasks/update")
|
339
|
-
end
|
340
|
-
end
|
341
|
-
|
342
|
-
describe "task got deleted or reassigned" do
|
343
|
-
it "should reload current page with the flash message if the task got deleted" do
|
344
|
-
@task = create(:task, user: create(:user), assignee: current_user)
|
345
|
-
@task.destroy
|
346
|
-
|
347
|
-
put :update, params: { id: @task.id, task: { name: "Hello" } }, xhr: true
|
348
|
-
expect(flash[:warning]).not_to eq(nil)
|
349
|
-
expect(response.body).to eq("window.location.reload();")
|
350
|
-
end
|
351
|
-
|
352
|
-
it "should reload current page with the flash message if the task got reassigned" do
|
353
|
-
@task = create(:task, user: create(:user), assignee: create(:user))
|
354
|
-
|
355
|
-
put :update, params: { id: @task.id, task: { name: "Hello" } }, xhr: true
|
356
|
-
expect(flash[:warning]).not_to eq(nil)
|
357
|
-
expect(response.body).to eq("window.location.reload();")
|
358
|
-
end
|
359
|
-
end
|
360
|
-
end
|
361
|
-
|
362
|
-
# DELETE /tasks/1
|
363
|
-
# DELETE /tasks/1.xml AJAX
|
364
|
-
#----------------------------------------------------------------------------
|
365
|
-
describe "responding to DELETE destroy" do
|
366
|
-
it "should destroy the requested task and render [destroy] template" do
|
367
|
-
@task = create(:task, user: current_user)
|
368
|
-
|
369
|
-
delete :destroy, params: { id: @task.id, bucket: "due_asap" }, xhr: true
|
370
|
-
expect(assigns(:task)).to eq(@task)
|
371
|
-
expect(assigns(:view)).to eq("pending")
|
372
|
-
expect(assigns[:task_total]).to eq(nil)
|
373
|
-
expect(response).to render_template("tasks/destroy")
|
374
|
-
end
|
375
|
-
|
376
|
-
["", "?view=pending", "?view=assigned", "?view=completed"].each do |view|
|
377
|
-
it "should update sidebar when [destroy] is being called from [/tasks#{view}]" do
|
378
|
-
@task = create(:task, user: current_user)
|
379
|
-
|
380
|
-
request.env["HTTP_REFERER"] = "http://localhost/tasks#{view}"
|
381
|
-
delete :destroy, params: { id: @task.id, bucket: "due_asap" }, xhr: true
|
382
|
-
expect(assigns[:task_total]).to be_an_instance_of(HashWithIndifferentAccess)
|
383
|
-
end
|
384
|
-
end
|
385
|
-
|
386
|
-
it "should not update sidebar when [destroy] is being called from asset page" do
|
387
|
-
@task = create(:task, user: current_user)
|
388
|
-
|
389
|
-
delete :destroy, params: { id: @task.id }, xhr: true
|
390
|
-
expect(assigns[:task_total]).to eq(nil)
|
391
|
-
end
|
392
|
-
|
393
|
-
describe "task got deleted or reassigned" do
|
394
|
-
it "should reload current page with the flash message if the task got deleted" do
|
395
|
-
@task = create(:task, user: create(:user), assignee: current_user)
|
396
|
-
@task.destroy
|
397
|
-
|
398
|
-
delete :destroy, params: { id: @task.id }, xhr: true
|
399
|
-
expect(flash[:warning]).not_to eq(nil)
|
400
|
-
expect(response.body).to eq("window.location.reload();")
|
401
|
-
end
|
402
|
-
|
403
|
-
it "should reload current page with the flash message if the task got reassigned" do
|
404
|
-
@task = create(:task, user: create(:user), assignee: create(:user))
|
405
|
-
|
406
|
-
delete :destroy, params: { id: @task.id }, xhr: true
|
407
|
-
expect(flash[:warning]).not_to eq(nil)
|
408
|
-
expect(response.body).to eq("window.location.reload();")
|
409
|
-
end
|
410
|
-
end
|
411
|
-
end
|
412
|
-
|
413
|
-
# PUT /tasks/1/complete
|
414
|
-
# PUT /leads/1/complete.xml AJAX
|
415
|
-
#----------------------------------------------------------------------------
|
416
|
-
describe "responding to PUT complete" do
|
417
|
-
it "should change task status, expose task as @task, and render [complete] template" do
|
418
|
-
@task = create(:task, completed_at: nil, user: current_user)
|
419
|
-
|
420
|
-
put :complete, params: { id: @task.id }, xhr: true
|
421
|
-
expect(@task.reload.completed_at).not_to eq(nil)
|
422
|
-
expect(assigns[:task]).to eq(@task)
|
423
|
-
expect(assigns[:task_total]).to eq(nil)
|
424
|
-
expect(response).to render_template("tasks/complete")
|
425
|
-
end
|
426
|
-
|
427
|
-
it "should change task status, expose task as @task, and render [complete] template where task.bucket = 'specific_time'" do
|
428
|
-
@task = create(:task, completed_at: nil, user: current_user, bucket: "specific_time", calendar: "01/01/2010 1:00 AM")
|
429
|
-
|
430
|
-
put :complete, params: { id: @task.id }, xhr: true
|
431
|
-
expect(@task.reload.completed_at).not_to eq(nil)
|
432
|
-
expect(assigns[:task]).to eq(@task)
|
433
|
-
expect(assigns[:task_total]).to eq(nil)
|
434
|
-
expect(response).to render_template("tasks/complete")
|
435
|
-
end
|
436
|
-
|
437
|
-
it "should change update tasks sidebar if bucket is not empty" do
|
438
|
-
@task = create(:task, completed_at: nil, user: current_user)
|
439
|
-
|
440
|
-
put :complete, params: { id: @task.id, bucket: "due_asap" }, xhr: true
|
441
|
-
expect(assigns[:task_total]).to be_an_instance_of(HashWithIndifferentAccess)
|
442
|
-
end
|
443
|
-
|
444
|
-
describe "task got deleted or reassigned" do
|
445
|
-
it "should reload current page with the flash message if the task got deleted" do
|
446
|
-
@task = create(:task, user: create(:user), assignee: current_user)
|
447
|
-
@task.destroy
|
448
|
-
|
449
|
-
put :complete, params: { id: @task.id }, xhr: true
|
450
|
-
expect(flash[:warning]).not_to eq(nil)
|
451
|
-
expect(response.body).to eq("window.location.reload();")
|
452
|
-
end
|
453
|
-
|
454
|
-
it "should reload current page with the flash message if the task got reassigned" do
|
455
|
-
@task = create(:task, user: create(:user), assignee: create(:user))
|
456
|
-
|
457
|
-
put :complete, params: { id: @task.id }, xhr: true
|
458
|
-
expect(flash[:warning]).not_to eq(nil)
|
459
|
-
expect(response.body).to eq("window.location.reload();")
|
460
|
-
end
|
461
|
-
end
|
462
|
-
end
|
463
|
-
|
464
|
-
# PUT /tasks/1/complete
|
465
|
-
# PUT /leads/1/complete.xml AJAX
|
466
|
-
#----------------------------------------------------------------------------
|
467
|
-
describe "responding to PUT uncomplete" do
|
468
|
-
it "should change task status, expose task as @task, and render template" do
|
469
|
-
@task = create(:task, completed_at: Time.now, user: current_user)
|
470
|
-
|
471
|
-
put :uncomplete, params: { id: @task.id }, xhr: true
|
472
|
-
expect(@task.reload.completed_at).to eq(nil)
|
473
|
-
expect(assigns[:task]).to eq(@task)
|
474
|
-
expect(assigns[:task_total]).not_to eq(nil)
|
475
|
-
expect(response).to render_template("tasks/uncomplete")
|
476
|
-
end
|
477
|
-
|
478
|
-
describe "task got deleted" do
|
479
|
-
it "should reload current page with the flash message if the task got deleted" do
|
480
|
-
@task = create(:task, user: create(:user), assignee: current_user, completed_at: Time.now)
|
481
|
-
@task.destroy
|
482
|
-
|
483
|
-
put :uncomplete, params: { id: @task.id }, xhr: true
|
484
|
-
expect(flash[:warning]).not_to eq(nil)
|
485
|
-
expect(response.body).to eq("window.location.reload();")
|
486
|
-
end
|
487
|
-
end
|
488
|
-
end
|
489
|
-
|
490
|
-
# Ajax request to filter out a list of tasks. AJAX
|
491
|
-
#----------------------------------------------------------------------------
|
492
|
-
describe "responding to GET filter" do
|
493
|
-
TASK_STATUSES.each do |view|
|
494
|
-
it "should remove a filter from session and render [filter] template for #{view} view" do
|
495
|
-
name = "filter_by_task_#{view}"
|
496
|
-
session[name] = "due_asap,due_today,due_tomorrow"
|
497
|
-
|
498
|
-
get :filter, params: { filter: "due_asap", view: view }, xhr: true
|
499
|
-
expect(session[name]).not_to include("due_asap")
|
500
|
-
expect(session[name]).to include("due_today")
|
501
|
-
expect(session[name]).to include("due_tomorrow")
|
502
|
-
expect(response).to render_template("tasks/filter")
|
503
|
-
end
|
504
|
-
|
505
|
-
it "should add a filter from session and render [filter] template for #{view} view" do
|
506
|
-
name = "filter_by_task_#{view}"
|
507
|
-
session[name] = "due_today,due_tomorrow"
|
508
|
-
|
509
|
-
get :filter, params: { checked: "true", filter: "due_asap", view: view }, xhr: true
|
510
|
-
expect(session[name]).to include("due_asap")
|
511
|
-
expect(session[name]).to include("due_today")
|
512
|
-
expect(session[name]).to include("due_tomorrow")
|
513
|
-
expect(response).to render_template("tasks/filter")
|
514
|
-
end
|
515
|
-
end
|
516
|
-
end
|
517
|
-
end
|