fat_free_crm 0.17.3 → 0.18.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/.dockerignore +11 -0
- data/.rubocop.yml +1 -1
- data/.rubocop_todo.yml +30 -8
- data/.travis.yml +14 -9
- data/CHANGELOG.md +43 -7
- data/CONTRIBUTORS.md +95 -53
- data/Gemfile +11 -7
- data/Gemfile.lock +83 -83
- data/README.md +7 -4
- data/app/assets/javascripts/crm.js.coffee +3 -3
- data/app/assets/javascripts/crm_select2.js.coffee +15 -14
- data/app/controllers/admin/field_groups_controller.rb +8 -1
- 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 +1 -1
- data/app/controllers/application_controller.rb +11 -0
- data/app/controllers/authentications_controller.rb +1 -1
- data/app/controllers/comments_controller.rb +15 -7
- data/app/controllers/entities/campaigns_controller.rb +7 -2
- data/app/controllers/entities/leads_controller.rb +9 -2
- data/app/controllers/entities/opportunities_controller.rb +13 -2
- data/app/controllers/entities_controller.rb +10 -5
- data/app/controllers/lists_controller.rb +5 -1
- data/app/controllers/tasks_controller.rb +15 -1
- data/app/helpers/accounts_helper.rb +1 -1
- data/app/helpers/application_helper.rb +2 -2
- data/app/helpers/leads_helper.rb +1 -1
- data/app/helpers/opportunities_helper.rb +56 -3
- data/app/helpers/tags_helper.rb +1 -1
- data/app/models/entities/lead.rb +0 -7
- data/app/models/entities/opportunity.rb +3 -2
- data/app/models/observers/opportunity_observer.rb +4 -4
- data/app/models/users/ability.rb +3 -4
- data/app/views/campaigns/_metrics.html.haml +3 -3
- data/app/views/home/_opportunity.html.haml +4 -19
- 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/db/schema.rb +0 -3
- data/fat_free_crm.gemspec +1 -1
- 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/fields.rb +1 -1
- data/lib/fat_free_crm/permissions.rb +0 -14
- data/lib/fat_free_crm/version.rb +2 -2
- data/lib/tasks/ffcrm/setup.rake +4 -4
- data/spec/controllers/admin/users_controller_spec.rb +27 -27
- data/spec/controllers/authentications_controller_spec.rb +7 -7
- data/spec/controllers/comments_controller_spec.rb +13 -13
- 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 +67 -67
- data/spec/controllers/entities/leads_controller_spec.rb +125 -125
- data/spec/controllers/entities/opportunities_controller_spec.rb +100 -100
- data/spec/controllers/home_controller_spec.rb +26 -26
- data/spec/controllers/passwords_controller_spec.rb +1 -1
- data/spec/controllers/tasks_controller_spec.rb +37 -37
- data/spec/controllers/users_controller_spec.rb +18 -18
- data/spec/factories/account_factories.rb +8 -8
- data/spec/factories/campaign_factories.rb +5 -5
- data/spec/factories/contact_factories.rb +10 -10
- data/spec/factories/field_factories.rb +7 -7
- data/spec/factories/lead_factories.rb +8 -8
- data/spec/factories/list_factories.rb +1 -1
- data/spec/factories/opportunity_factories.rb +6 -6
- data/spec/factories/sequences.rb +1 -1
- data/spec/factories/setting_factories.rb +3 -3
- data/spec/factories/shared_factories.rb +14 -14
- data/spec/factories/subscription_factories.rb +1 -1
- data/spec/factories/tag_factories.rb +1 -1
- data/spec/factories/task_factories.rb +4 -4
- data/spec/factories/user_factories.rb +13 -13
- data/spec/features/accounts_spec.rb +17 -4
- data/spec/features/admin/groups_spec.rb +1 -1
- data/spec/features/admin/users_spec.rb +1 -1
- data/spec/features/campaigns_spec.rb +4 -4
- data/spec/features/contacts_spec.rb +10 -4
- data/spec/features/dashboard_spec.rb +7 -7
- data/spec/features/leads_spec.rb +4 -4
- data/spec/features/opportunities_overview_spec.rb +15 -15
- data/spec/features/opportunities_spec.rb +34 -8
- data/spec/features/support/autocomlete_helper.rb +17 -0
- data/spec/features/support/browser.rb +3 -8
- data/spec/features/support/helpers.rb +1 -1
- data/spec/features/tasks_spec.rb +4 -4
- 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 +3 -3
- data/spec/lib/comment_extensions_spec.rb +1 -1
- 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 +16 -16
- data/spec/lib/permissions_spec.rb +7 -25
- data/spec/mailers/user_mailer_spec.rb +7 -7
- data/spec/models/entities/account_spec.rb +31 -32
- data/spec/models/entities/campaign_spec.rb +18 -25
- data/spec/models/entities/contact_spec.rb +18 -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_spec.rb +17 -17
- data/spec/models/list_spec.rb +2 -2
- data/spec/models/observers/entity_observer_spec.rb +6 -6
- 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 +26 -26
- data/spec/models/setting_spec.rb +2 -2
- data/spec/models/users/preference_spec.rb +6 -6
- data/spec/models/users/user_spec.rb +26 -26
- data/spec/shared/models.rb +22 -22
- data/spec/spec_helper.rb +2 -2
- data/spec/support/auth_macros.rb +1 -1
- data/spec/support/macros.rb +3 -3
- data/spec/views/accounts/_edit.haml_spec.rb +1 -1
- data/spec/views/accounts/create.js.haml_spec.rb +2 -2
- 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 +3 -3
- data/spec/views/campaigns/destroy.js.haml_spec.rb +1 -1
- data/spec/views/campaigns/edit.js.haml_spec.rb +2 -2
- data/spec/views/campaigns/index.haml_spec.rb +1 -1
- data/spec/views/campaigns/index.js.haml_spec.rb +1 -1
- data/spec/views/campaigns/show.haml_spec.rb +4 -4
- data/spec/views/campaigns/update.js.haml_spec.rb +1 -1
- 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 +4 -4
- data/spec/views/contacts/destroy.js.haml_spec.rb +1 -1
- data/spec/views/contacts/edit.js.haml_spec.rb +3 -3
- data/spec/views/contacts/index.haml_spec.rb +1 -1
- data/spec/views/contacts/index.js.html_spec.rb +1 -1
- 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 +2 -2
- 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 +4 -4
- 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 +5 -3
@@ -9,7 +9,7 @@ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
|
9
9
|
|
10
10
|
describe FatFreeCRM::CommentExtensions do
|
11
11
|
describe "add_comment_by_user" do
|
12
|
-
let(:user) {
|
12
|
+
let(:user) { create(:user) }
|
13
13
|
|
14
14
|
before :each do
|
15
15
|
build_model(:commentable_entity) do
|
@@ -136,19 +136,19 @@ describe FatFreeCRM::MailProcessor::Base do
|
|
136
136
|
end
|
137
137
|
|
138
138
|
it "should find non-suspended user that matches From: field" do
|
139
|
-
@user =
|
139
|
+
@user = create(:user, email: @from.first, suspended_at: nil)
|
140
140
|
expect(@crawler.send(:sent_from_known_user?, @email)).to eq(true)
|
141
141
|
expect(@crawler.instance_variable_get("@sender")).to eq(@user)
|
142
142
|
end
|
143
143
|
|
144
144
|
it "should not find user if his email doesn't match From: field" do
|
145
|
-
|
145
|
+
create(:user, email: "nobody@example.com")
|
146
146
|
expect(@crawler.send(:sent_from_known_user?, @email)).to eq(false)
|
147
147
|
expect(@crawler.instance_variable_get("@sender")).to eq(nil)
|
148
148
|
end
|
149
149
|
|
150
150
|
it "should not find user if his email matches From: field but is suspended" do
|
151
|
-
|
151
|
+
create(:user, email: @from.first, suspended_at: Time.now)
|
152
152
|
expect(@crawler.send(:sent_from_known_user?, @email)).to eq(false)
|
153
153
|
expect(@crawler.instance_variable_get("@sender")).to eq(nil)
|
154
154
|
end
|
@@ -23,7 +23,7 @@ describe FatFreeCRM::MailProcessor::CommentReplies do
|
|
23
23
|
#------------------------------------------------------------------------------
|
24
24
|
describe "Processing new emails" do
|
25
25
|
before do
|
26
|
-
|
26
|
+
create(:user, email: "aaron@example.com")
|
27
27
|
end
|
28
28
|
|
29
29
|
before(:each) do
|
@@ -32,7 +32,7 @@ describe FatFreeCRM::MailProcessor::CommentReplies do
|
|
32
32
|
end
|
33
33
|
|
34
34
|
it "should attach a new comment to a contact" do
|
35
|
-
@contact =
|
35
|
+
@contact = create(:contact)
|
36
36
|
comment_reply = "This is a new comment reply via email"
|
37
37
|
|
38
38
|
mail = Mail.new from: "Aaron Assembler <aaron@example.com>",
|
@@ -50,7 +50,7 @@ describe FatFreeCRM::MailProcessor::CommentReplies do
|
|
50
50
|
end
|
51
51
|
|
52
52
|
it "should attach a new comment to an opportunity, using the 'op' shortcut in subject" do
|
53
|
-
@opportunity =
|
53
|
+
@opportunity = create(:opportunity)
|
54
54
|
comment_reply = "This is a new comment reply via email"
|
55
55
|
|
56
56
|
mail = Mail.new from: "Aaron Assembler <aaron@example.com>",
|
@@ -28,7 +28,7 @@ describe FatFreeCRM::MailProcessor::Dropbox do
|
|
28
28
|
|
29
29
|
it "should discard a message if it's invalid" do
|
30
30
|
expect(@crawler).to receive(:is_valid?).once.and_return(false)
|
31
|
-
|
31
|
+
create(:user, email: "aaron@example.com")
|
32
32
|
expect(@crawler).not_to receive(:archive)
|
33
33
|
expect(@crawler).to receive(:discard).once
|
34
34
|
@crawler.run
|
@@ -42,7 +42,7 @@ describe FatFreeCRM::MailProcessor::Dropbox do
|
|
42
42
|
end
|
43
43
|
|
44
44
|
it "should process a message if it finds the user" do
|
45
|
-
|
45
|
+
create(:user, email: "aaron@example.com")
|
46
46
|
expect(@crawler).to receive(:archive).once
|
47
47
|
expect(@crawler).not_to receive(:discard)
|
48
48
|
@crawler.run
|
@@ -54,12 +54,12 @@ describe FatFreeCRM::MailProcessor::Dropbox do
|
|
54
54
|
before(:each) do
|
55
55
|
mock_connect
|
56
56
|
mock_disconnect
|
57
|
-
|
57
|
+
create(:user, email: "aaron@example.com")
|
58
58
|
end
|
59
59
|
|
60
60
|
it "should find the named asset and attach the email message" do
|
61
61
|
mock_message(DROPBOX_EMAILS[:first_line])
|
62
|
-
@campaign =
|
62
|
+
@campaign = create(:campaign, name: "Got milk!?")
|
63
63
|
expect(@crawler).to receive(:archive).once
|
64
64
|
expect(@crawler).not_to receive(:with_recipients)
|
65
65
|
@crawler.run
|
@@ -82,7 +82,7 @@ describe FatFreeCRM::MailProcessor::Dropbox do
|
|
82
82
|
|
83
83
|
it "should find the lead and attach the email message" do
|
84
84
|
mock_message(DROPBOX_EMAILS[:first_line_lead])
|
85
|
-
@lead =
|
85
|
+
@lead = create(:lead, first_name: "Cindy", last_name: "Cluster")
|
86
86
|
expect(@crawler).to receive(:archive).once
|
87
87
|
expect(@crawler).not_to receive(:with_recipients)
|
88
88
|
@crawler.run
|
@@ -106,7 +106,7 @@ describe FatFreeCRM::MailProcessor::Dropbox do
|
|
106
106
|
|
107
107
|
it "should find the contact and attach the email message" do
|
108
108
|
mock_message(DROPBOX_EMAILS[:first_line_contact])
|
109
|
-
@contact =
|
109
|
+
@contact = create(:contact, first_name: "Cindy", last_name: "Cluster")
|
110
110
|
expect(@crawler).to receive(:archive).once
|
111
111
|
expect(@crawler).not_to receive(:with_recipients)
|
112
112
|
@crawler.run
|
@@ -141,11 +141,11 @@ describe FatFreeCRM::MailProcessor::Dropbox do
|
|
141
141
|
mock_connect
|
142
142
|
mock_disconnect
|
143
143
|
mock_message(DROPBOX_EMAILS[:plain])
|
144
|
-
|
144
|
+
create(:user, email: "aaron@example.com")
|
145
145
|
end
|
146
146
|
|
147
147
|
it "should find the asset and attach the email message" do
|
148
|
-
@lead =
|
148
|
+
@lead = create(:lead, email: "ben@example.com", access: "Public")
|
149
149
|
expect(@crawler).to receive(:archive).once
|
150
150
|
expect(@crawler).not_to receive(:with_forwarded_recipient)
|
151
151
|
@crawler.run
|
@@ -169,12 +169,12 @@ describe FatFreeCRM::MailProcessor::Dropbox do
|
|
169
169
|
before(:each) do
|
170
170
|
mock_connect
|
171
171
|
mock_disconnect
|
172
|
-
|
172
|
+
create(:user, email: "aaron@example.com")
|
173
173
|
mock_message(DROPBOX_EMAILS[:forwarded])
|
174
174
|
end
|
175
175
|
|
176
176
|
it "should find the asset and attach the email message" do
|
177
|
-
@lead =
|
177
|
+
@lead = create(:lead, email: "ben@example.com", access: "Public")
|
178
178
|
expect(@crawler).to receive(:archive).once
|
179
179
|
@crawler.run
|
180
180
|
|
@@ -187,7 +187,7 @@ describe FatFreeCRM::MailProcessor::Dropbox do
|
|
187
187
|
timezone = ActiveRecord::Base.default_timezone
|
188
188
|
begin
|
189
189
|
ActiveRecord::Base.default_timezone = :utc
|
190
|
-
@lead =
|
190
|
+
@lead = create(:lead, email: "ben@example.com", access: "Public", updated_at: 5.day.ago)
|
191
191
|
|
192
192
|
@crawler.run
|
193
193
|
expect(@lead.reload.updated_at.to_i).to be >= now.to_i
|
@@ -197,7 +197,7 @@ describe FatFreeCRM::MailProcessor::Dropbox do
|
|
197
197
|
end
|
198
198
|
|
199
199
|
it "should change lead's status (:new => :contacted)" do
|
200
|
-
@lead =
|
200
|
+
@lead = create(:lead, email: "ben@example.com", access: "Public", status: "new")
|
201
201
|
|
202
202
|
@crawler.run
|
203
203
|
expect(@lead.reload.status).to eq("contacted")
|
@@ -219,13 +219,13 @@ describe FatFreeCRM::MailProcessor::Dropbox do
|
|
219
219
|
@settings = @crawler.instance_variable_get("@settings")
|
220
220
|
@settings[:address_aliases] = ["dropbox@example.com"]
|
221
221
|
|
222
|
-
|
222
|
+
create(:user, email: "aaron@example.com")
|
223
223
|
mock_message(DROPBOX_EMAILS[:forwarded])
|
224
224
|
end
|
225
225
|
|
226
226
|
it "should not match the dropbox email address if routed to an alias" do
|
227
|
-
@lead =
|
228
|
-
@lead_dropbox =
|
227
|
+
@lead = create(:lead, email: "ben@example.com", access: "Public")
|
228
|
+
@lead_dropbox = create(:lead, email: "dropbox@example.com", access: "Public")
|
229
229
|
|
230
230
|
expect(@crawler).to receive(:archive).once
|
231
231
|
@crawler.run
|
@@ -240,7 +240,7 @@ describe FatFreeCRM::MailProcessor::Dropbox do
|
|
240
240
|
before(:each) do
|
241
241
|
mock_connect
|
242
242
|
mock_disconnect
|
243
|
-
|
243
|
+
create(:user, email: "aaron@example.com")
|
244
244
|
end
|
245
245
|
|
246
246
|
it "should create a contact from the email recipient (To: recipient, Bcc: dropbox)" do
|
@@ -44,8 +44,8 @@ describe FatFreeCRM::Permissions do
|
|
44
44
|
end
|
45
45
|
|
46
46
|
it "should replace existing permissions" do
|
47
|
-
@entity.permissions <<
|
48
|
-
@entity.permissions <<
|
47
|
+
@entity.permissions << create(:permission, user_id: 1, asset: @entity)
|
48
|
+
@entity.permissions << create(:permission, user_id: 2, asset: @entity)
|
49
49
|
@entity.user_ids = %w[2 3]
|
50
50
|
@entity.save!
|
51
51
|
expect(@entity.permissions.size).to eq(2)
|
@@ -73,8 +73,8 @@ describe FatFreeCRM::Permissions do
|
|
73
73
|
end
|
74
74
|
|
75
75
|
it "should replace existing permissions" do
|
76
|
-
@entity.permissions <<
|
77
|
-
@entity.permissions <<
|
76
|
+
@entity.permissions << build(:permission, group_id: 1, user_id: nil, asset: @entity)
|
77
|
+
@entity.permissions << build(:permission, group_id: 2, user_id: nil, asset: @entity)
|
78
78
|
expect(@entity.permissions.size).to eq(2)
|
79
79
|
@entity.group_ids = ['3']
|
80
80
|
@entity.save!
|
@@ -89,19 +89,19 @@ describe FatFreeCRM::Permissions do
|
|
89
89
|
@entity = UserWithPermission.create
|
90
90
|
end
|
91
91
|
it "should delete all permissions if access is set to Public" do
|
92
|
-
perm =
|
92
|
+
perm = create(:permission, user_id: 1, asset: @entity)
|
93
93
|
expect(perm).to receive(:destroy)
|
94
94
|
expect(Permission).to receive(:where).with(asset_id: @entity.id, asset_type: @entity.class.to_s).and_return([perm])
|
95
95
|
@entity.update_attribute(:access, 'Public')
|
96
96
|
end
|
97
97
|
it "should delete all permissions if access is set to Private" do
|
98
|
-
perm =
|
98
|
+
perm = create(:permission, user_id: 1, asset: @entity)
|
99
99
|
expect(perm).to receive(:destroy)
|
100
100
|
expect(Permission).to receive(:where).with(asset_id: @entity.id, asset_type: @entity.class.to_s).and_return([perm])
|
101
101
|
@entity.update_attribute(:access, 'Private')
|
102
102
|
end
|
103
103
|
it "should not remove permissions if access is set to Shared" do
|
104
|
-
perm =
|
104
|
+
perm = create(:permission, user_id: 1, asset: @entity)
|
105
105
|
expect(perm).not_to receive(:destroy)
|
106
106
|
@entity.permissions << perm
|
107
107
|
expect(Permission).not_to receive(:find_all_by_asset_id)
|
@@ -110,24 +110,6 @@ describe FatFreeCRM::Permissions do
|
|
110
110
|
end
|
111
111
|
end
|
112
112
|
|
113
|
-
describe "save_with_permissions" do
|
114
|
-
it "should raise deprecation warning and call save" do
|
115
|
-
entity = UserWithPermission.new
|
116
|
-
expect(ActiveSupport::Deprecation).to receive(:warn)
|
117
|
-
expect(entity).to receive(:save)
|
118
|
-
entity.save_with_permissions
|
119
|
-
end
|
120
|
-
end
|
121
|
-
|
122
|
-
describe "update_with_permissions" do
|
123
|
-
it "should raise deprecation warning and call update_attributes" do
|
124
|
-
entity = UserWithPermission.new
|
125
|
-
expect(ActiveSupport::Deprecation).to receive(:warn)
|
126
|
-
expect(entity).to receive(:update_attributes).with({})
|
127
|
-
entity.update_with_permissions({})
|
128
|
-
end
|
129
|
-
end
|
130
|
-
|
131
113
|
describe "save_with_model_permissions" do
|
132
114
|
it "should copy permissions from original model" do
|
133
115
|
entity = UserWithPermission.new
|
@@ -9,7 +9,7 @@ require 'spec_helper'
|
|
9
9
|
|
10
10
|
describe UserMailer do
|
11
11
|
describe "password_reset_instructions" do
|
12
|
-
let(:user) {
|
12
|
+
let(:user) { build(:user, email: "forgot_my_password@example.com") }
|
13
13
|
let(:mail) { UserMailer.password_reset_instructions(user) }
|
14
14
|
|
15
15
|
before(:each) do
|
@@ -35,11 +35,11 @@ describe UserMailer do
|
|
35
35
|
end
|
36
36
|
|
37
37
|
describe "assigned_entity_notification" do
|
38
|
-
let(:assigner) {
|
39
|
-
let(:assignee) {
|
38
|
+
let(:assigner) { build(:user, first_name: "Bob", last_name: "Hope") }
|
39
|
+
let(:assignee) { build(:user, email: "assignee@example.com") }
|
40
40
|
|
41
41
|
context "for an account" do
|
42
|
-
let(:account) {
|
42
|
+
let(:account) { build_stubbed(:account, id: 16, name: 'Ghostbusters', user: assigner, assignee: assignee) }
|
43
43
|
let(:mail) { UserMailer.assigned_entity_notification(account, assigner) }
|
44
44
|
|
45
45
|
it "sets fatfree as the sender" do
|
@@ -64,7 +64,7 @@ describe UserMailer do
|
|
64
64
|
end
|
65
65
|
|
66
66
|
context "for a contact" do
|
67
|
-
let(:contact) {
|
67
|
+
let(:contact) { build_stubbed(:contact, id: 56, first_name: 'Harold', last_name: 'Ramis', user: assigner, assignee: assignee) }
|
68
68
|
let(:mail) { UserMailer.assigned_entity_notification(contact, assigner) }
|
69
69
|
|
70
70
|
it "sets fatfree as the sender" do
|
@@ -89,7 +89,7 @@ describe UserMailer do
|
|
89
89
|
end
|
90
90
|
|
91
91
|
context "for a lead" do
|
92
|
-
let(:lead) {
|
92
|
+
let(:lead) { build_stubbed(:lead, id: 42, first_name: 'Bill', last_name: 'Murray', user: assigner, assignee: assignee) }
|
93
93
|
let(:mail) { UserMailer.assigned_entity_notification(lead, assigner) }
|
94
94
|
|
95
95
|
it "sets fatfree as the sender" do
|
@@ -114,7 +114,7 @@ describe UserMailer do
|
|
114
114
|
end
|
115
115
|
|
116
116
|
context "for an opportunity" do
|
117
|
-
let(:opportunity) {
|
117
|
+
let(:opportunity) { create(:opportunity, id: 24, name: 'Big', user: assigner, assignee: assignee) }
|
118
118
|
let(:mail) { UserMailer.assigned_entity_notification(opportunity, assigner) }
|
119
119
|
|
120
120
|
it "sets fatfree as the sender" do
|
@@ -30,22 +30,20 @@
|
|
30
30
|
require 'spec_helper'
|
31
31
|
|
32
32
|
describe Account do
|
33
|
-
let(:current_user) { FactoryGirl.create(:user) }
|
34
|
-
|
35
33
|
it "should create a new instance given valid attributes" do
|
36
|
-
Account.create!(name: "Test Account"
|
34
|
+
Account.create!(name: "Test Account")
|
37
35
|
end
|
38
36
|
|
39
37
|
describe "Attach" do
|
40
38
|
before do
|
41
|
-
@account =
|
39
|
+
@account = create(:account)
|
42
40
|
end
|
43
41
|
|
44
42
|
it "should return nil when attaching existing asset" do
|
45
|
-
@task =
|
46
|
-
@contact =
|
43
|
+
@task = create(:task, asset: @account)
|
44
|
+
@contact = create(:contact)
|
47
45
|
@account.contacts << @contact
|
48
|
-
@opportunity =
|
46
|
+
@opportunity = create(:opportunity)
|
49
47
|
@account.opportunities << @opportunity
|
50
48
|
|
51
49
|
expect(@account.attach!(@task)).to eq(nil)
|
@@ -54,9 +52,9 @@ describe Account do
|
|
54
52
|
end
|
55
53
|
|
56
54
|
it "should return non-empty list of attachments when attaching new asset" do
|
57
|
-
@task =
|
58
|
-
@contact =
|
59
|
-
@opportunity =
|
55
|
+
@task = create(:task)
|
56
|
+
@contact = create(:contact)
|
57
|
+
@opportunity = create(:opportunity)
|
60
58
|
|
61
59
|
expect(@account.attach!(@task)).to eq([@task])
|
62
60
|
expect(@account.attach!(@contact)).to eq([@contact])
|
@@ -66,11 +64,11 @@ describe Account do
|
|
66
64
|
|
67
65
|
describe "Discard" do
|
68
66
|
before do
|
69
|
-
@account =
|
67
|
+
@account = create(:account)
|
70
68
|
end
|
71
69
|
|
72
70
|
it "should discard a task" do
|
73
|
-
@task =
|
71
|
+
@task = create(:task, asset: @account)
|
74
72
|
expect(@account.tasks.count).to eq(1)
|
75
73
|
|
76
74
|
@account.discard!(@task)
|
@@ -79,7 +77,7 @@ describe Account do
|
|
79
77
|
end
|
80
78
|
|
81
79
|
it "should discard a contact" do
|
82
|
-
@contact =
|
80
|
+
@contact = create(:contact)
|
83
81
|
@account.contacts << @contact
|
84
82
|
expect(@account.contacts.count).to eq(1)
|
85
83
|
|
@@ -91,7 +89,7 @@ describe Account do
|
|
91
89
|
# Commented out this test. "super from singleton method that is defined to multiple classes is not supported;"
|
92
90
|
# ------------------------------------------------------
|
93
91
|
# it "should discard an opportunity" do
|
94
|
-
# @opportunity =
|
92
|
+
# @opportunity = create(:opportunity)
|
95
93
|
# @account.opportunities << @opportunity
|
96
94
|
# @account.opportunities.count.should == 1
|
97
95
|
|
@@ -103,16 +101,16 @@ describe Account do
|
|
103
101
|
|
104
102
|
describe "Exportable" do
|
105
103
|
describe "assigned account" do
|
106
|
-
let(:account1) {
|
107
|
-
let(:account2) {
|
104
|
+
let(:account1) { build(:account, assignee: create(:user)) }
|
105
|
+
let(:account2) { build(:account, user: create(:user, first_name: nil, last_name: nil), assignee: create(:user, first_name: nil, last_name: nil)) }
|
108
106
|
it_should_behave_like("exportable") do
|
109
107
|
let(:exported) { [account1, account2] }
|
110
108
|
end
|
111
109
|
end
|
112
110
|
|
113
111
|
describe "unassigned account" do
|
114
|
-
let(:account1) {
|
115
|
-
let(:account2) {
|
112
|
+
let(:account1) { build(:account, assignee: nil) }
|
113
|
+
let(:account2) { build(:account, user: create(:user, first_name: nil, last_name: nil), assignee: nil) }
|
116
114
|
it_should_behave_like("exportable") do
|
117
115
|
let(:exported) { [account1, account2] }
|
118
116
|
end
|
@@ -121,13 +119,13 @@ describe Account do
|
|
121
119
|
|
122
120
|
describe "Before save" do
|
123
121
|
it "create new: should replace empty category string with nil" do
|
124
|
-
account =
|
122
|
+
account = build(:account, category: '')
|
125
123
|
account.save
|
126
124
|
expect(account.category).to eq(nil)
|
127
125
|
end
|
128
126
|
|
129
127
|
it "update existing: should replace empty category string with nil" do
|
130
|
-
account =
|
128
|
+
account = create(:account, category: '')
|
131
129
|
account.save
|
132
130
|
expect(account.category).to eq(nil)
|
133
131
|
end
|
@@ -139,13 +137,14 @@ describe Account do
|
|
139
137
|
|
140
138
|
describe "scopes" do
|
141
139
|
context "visible_on_dashboard" do
|
142
|
-
before
|
143
|
-
@
|
144
|
-
@
|
145
|
-
@
|
146
|
-
@
|
147
|
-
@
|
148
|
-
@
|
140
|
+
before do
|
141
|
+
@another_user = create(:user)
|
142
|
+
@user = create(:user)
|
143
|
+
@a1 = create(:account, user: @user)
|
144
|
+
@a2 = create(:account, user: @user, assignee: @another_user)
|
145
|
+
@a3 = create(:account, assignee: @user)
|
146
|
+
@a4 = create(:account, assignee: @another_user)
|
147
|
+
@a5 = create(:account, assignee: @user)
|
149
148
|
end
|
150
149
|
|
151
150
|
it "should show accounts which have been created by the user and are unassigned" do
|
@@ -167,11 +166,11 @@ describe Account do
|
|
167
166
|
|
168
167
|
context "by_name" do
|
169
168
|
it "should show accounts ordered by name" do
|
170
|
-
@a1 =
|
171
|
-
@a2 =
|
172
|
-
@a3 =
|
173
|
-
@a4 =
|
174
|
-
@a5 =
|
169
|
+
@a1 = create(:account, name: "Account A")
|
170
|
+
@a2 = create(:account, name: "Account Z")
|
171
|
+
@a3 = create(:account, name: "Account J")
|
172
|
+
@a4 = create(:account, name: "Account X")
|
173
|
+
@a5 = create(:account, name: "Account L")
|
175
174
|
|
176
175
|
expect(Account.by_name).to eq([@a1, @a3, @a5, @a4, @a2])
|
177
176
|
end
|
@@ -34,31 +34,25 @@
|
|
34
34
|
require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
|
35
35
|
|
36
36
|
describe Campaign do
|
37
|
-
let(:current_user) { FactoryGirl.create(:user) }
|
38
|
-
|
39
37
|
it "should create a new instance given valid attributes" do
|
40
|
-
Campaign.create!(name: "Campaign"
|
38
|
+
Campaign.create!(name: "Campaign")
|
41
39
|
end
|
42
40
|
|
43
41
|
describe "Attach" do
|
44
42
|
before do
|
45
|
-
@campaign =
|
43
|
+
@campaign = create(:campaign)
|
46
44
|
end
|
47
45
|
|
48
46
|
it "should return nil when attaching existing asset" do
|
49
|
-
@
|
50
|
-
@
|
51
|
-
@
|
52
|
-
|
53
|
-
expect(@campaign.attach!(@task)).to eq(nil)
|
54
|
-
expect(@campaign.attach!(@lead)).to eq(nil)
|
55
|
-
expect(@campaign.attach!(@opportunity)).to eq(nil)
|
47
|
+
expect(@campaign.attach!(create(:task, asset: @campaign))).to eq(nil)
|
48
|
+
expect(@campaign.attach!(create(:lead, campaign: @campaign))).to eq(nil)
|
49
|
+
expect(@campaign.attach!(create(:opportunity, campaign: @campaign))).to eq(nil)
|
56
50
|
end
|
57
51
|
|
58
52
|
it "should return non-empty list of attachments when attaching new asset" do
|
59
|
-
@task =
|
60
|
-
@lead =
|
61
|
-
@opportunity =
|
53
|
+
@task = create(:task)
|
54
|
+
@lead = create(:lead)
|
55
|
+
@opportunity = create(:opportunity)
|
62
56
|
|
63
57
|
expect(@campaign.attach!(@task)).to eq([@task])
|
64
58
|
expect(@campaign.attach!(@lead)).to eq([@lead])
|
@@ -67,15 +61,14 @@ describe Campaign do
|
|
67
61
|
|
68
62
|
it "should increment leads count when attaching a new lead" do
|
69
63
|
@leads_count = @campaign.leads_count
|
70
|
-
@lead = FactoryGirl.create(:lead)
|
71
64
|
|
72
|
-
@campaign.attach!(
|
65
|
+
@campaign.attach!(create(:lead))
|
73
66
|
expect(@campaign.reload.leads_count).to eq(@leads_count + 1)
|
74
67
|
end
|
75
68
|
|
76
69
|
it "should increment opportunities count when attaching new opportunity" do
|
77
70
|
@opportunities_count = @campaign.opportunities_count
|
78
|
-
@opportunity =
|
71
|
+
@opportunity = create(:opportunity)
|
79
72
|
@campaign.attach!(@opportunity)
|
80
73
|
expect(@campaign.reload.opportunities_count).to eq(@opportunities_count + 1)
|
81
74
|
end
|
@@ -83,11 +76,11 @@ describe Campaign do
|
|
83
76
|
|
84
77
|
describe "Detach" do
|
85
78
|
before do
|
86
|
-
@campaign =
|
79
|
+
@campaign = create(:campaign, leads_count: 42, opportunities_count: 42)
|
87
80
|
end
|
88
81
|
|
89
82
|
it "should discard a task" do
|
90
|
-
@task =
|
83
|
+
@task = create(:task, asset: @campaign)
|
91
84
|
expect(@campaign.tasks.count).to eq(1)
|
92
85
|
|
93
86
|
@campaign.discard!(@task)
|
@@ -96,7 +89,7 @@ describe Campaign do
|
|
96
89
|
end
|
97
90
|
|
98
91
|
it "should discard a lead" do
|
99
|
-
@lead =
|
92
|
+
@lead = create(:lead, campaign: @campaign)
|
100
93
|
expect(@campaign.reload.leads_count).to eq(43)
|
101
94
|
|
102
95
|
@campaign.discard!(@lead)
|
@@ -105,7 +98,7 @@ describe Campaign do
|
|
105
98
|
end
|
106
99
|
|
107
100
|
it "should discard an opportunity" do
|
108
|
-
@opportunity =
|
101
|
+
@opportunity = create(:opportunity, campaign: @campaign)
|
109
102
|
expect(@campaign.reload.opportunities_count).to eq(43)
|
110
103
|
|
111
104
|
@campaign.discard!(@opportunity)
|
@@ -116,16 +109,16 @@ describe Campaign do
|
|
116
109
|
|
117
110
|
describe "Exportable" do
|
118
111
|
describe "assigned campaign" do
|
119
|
-
let(:campaign1) {
|
120
|
-
let(:campaign2) {
|
112
|
+
let(:campaign1) { build(:campaign, user: create(:user, first_name: "John", last_name: "Smith"), assignee: create(:user)) }
|
113
|
+
let(:campaign2) { build(:campaign, user: create(:user, first_name: nil, last_name: nil), assignee: create(:user, first_name: nil, last_name: nil)) }
|
121
114
|
it_should_behave_like("exportable") do
|
122
115
|
let(:exported) { [campaign1, campaign2] }
|
123
116
|
end
|
124
117
|
end
|
125
118
|
|
126
119
|
describe "unassigned campaign" do
|
127
|
-
let(:campaign1) {
|
128
|
-
let(:campaign2) {
|
120
|
+
let(:campaign1) { build(:campaign, user: create(:user), assignee: nil) }
|
121
|
+
let(:campaign2) { build(:campaign, user: create(:user, first_name: nil, last_name: nil), assignee: nil) }
|
129
122
|
it_should_behave_like("exportable") do
|
130
123
|
let(:exported) { [campaign1, campaign2] }
|
131
124
|
end
|