fat_free_crm 0.15.0.beta.2 → 0.15.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/.docker/nginx/sites-enabled/ffcrm.conf +8 -0
- data/.gitignore +2 -0
- data/.rubocop.yml +4 -1
- data/.rubocop_todo.yml +190 -89
- data/.travis.yml +10 -3
- data/CHANGELOG.md +27 -0
- data/{CONTRIBUTORS → CONTRIBUTORS.md} +2 -1
- data/Dockerfile +15 -13
- data/Gemfile +7 -4
- data/Gemfile.lock +200 -167
- data/README.md +4 -2
- data/app/assets/javascripts/crm_sortable.js.coffee +5 -0
- data/app/assets/javascripts/timeago.js.coffee +5 -0
- data/app/assets/stylesheets/about.css.scss +5 -0
- data/app/assets/stylesheets/common.scss +2 -1
- data/app/controllers/admin/fields_controller.rb +1 -1
- data/app/controllers/admin/groups_controller.rb +5 -1
- data/app/controllers/admin/tags_controller.rb +1 -1
- data/app/controllers/admin/users_controller.rb +10 -6
- data/app/controllers/application_controller.rb +13 -13
- data/app/controllers/authentications_controller.rb +2 -2
- data/app/controllers/comments_controller.rb +3 -2
- data/app/controllers/entities/contacts_controller.rb +9 -7
- data/app/controllers/entities/opportunities_controller.rb +1 -1
- data/app/controllers/entities_controller.rb +4 -4
- data/app/controllers/home_controller.rb +9 -9
- data/app/controllers/passwords_controller.rb +1 -1
- data/app/controllers/tasks_controller.rb +2 -1
- data/app/controllers/users_controller.rb +4 -2
- data/app/helpers/application_helper.rb +9 -9
- data/app/helpers/javascript_helper.rb +5 -0
- data/app/helpers/opportunities_helper.rb +1 -1
- data/app/helpers/remote_link_pagination_helper.rb +5 -0
- data/app/inputs/date_pair_input.rb +1 -1
- data/app/models/entities/account.rb +2 -2
- data/app/models/entities/account_contact.rb +1 -1
- data/app/models/entities/campaign.rb +3 -3
- data/app/models/entities/contact.rb +3 -3
- data/app/models/entities/lead.rb +2 -2
- data/app/models/entities/opportunity.rb +3 -3
- data/app/models/fields/custom_field.rb +1 -1
- data/app/models/fields/custom_field_pair.rb +2 -2
- data/app/models/fields/field.rb +1 -1
- data/app/models/polymorphic/address.rb +2 -2
- data/app/models/polymorphic/avatar.rb +4 -2
- data/app/models/polymorphic/email.rb +8 -6
- data/app/models/polymorphic/task.rb +3 -1
- data/app/models/polymorphic/version.rb +3 -3
- data/app/models/users/ability.rb +1 -1
- data/app/models/users/permission.rb +2 -0
- data/app/models/users/user.rb +2 -2
- data/app/views/accounts/index.js.haml +1 -1
- data/app/views/admin/fields/_sort_by.html.haml +1 -1
- data/app/views/admin/users/_user.html.haml +1 -1
- data/app/views/campaigns/index.js.haml +1 -1
- data/app/views/contacts/index.js.haml +1 -1
- data/app/views/entities/_basic_search.html.haml +1 -1
- data/app/views/home/_duration_menu.html.haml +1 -1
- data/app/views/home/_events_menu.html.haml +1 -1
- data/app/views/home/_users_menu.html.haml +1 -1
- data/app/views/layouts/application.html.haml +1 -1
- data/app/views/leads/index.js.haml +1 -1
- data/app/views/opportunities/index.js.haml +1 -1
- data/app/views/shared/_naming.html.haml +1 -1
- data/app/views/users/_languages.html.haml +1 -1
- data/config/application.rb +2 -3
- data/config/boot.rb +2 -0
- data/config/deploy.example.rb +1 -1
- data/config/environments/development.rb +2 -0
- data/config/environments/production.rb +1 -1
- data/config/environments/test.rb +2 -2
- data/config/initializers/assets.rb +6 -1
- data/config/initializers/backtrace_silencers.rb +5 -0
- data/config/initializers/constants.rb +1 -1
- data/config/initializers/cookies_serializer.rb +5 -0
- data/config/initializers/custom_field_ransack_translations.rb +5 -0
- data/config/initializers/filter_parameter_logging.rb +5 -0
- data/config/initializers/inflections.rb +5 -0
- data/config/initializers/paper_trail.rb +5 -0
- data/config/initializers/ransack.rb +3 -3
- data/config/initializers/session_store.rb +5 -0
- data/config/initializers/wrap_parameters.rb +5 -0
- data/config/locales/et.yml +207 -0
- data/config/locales/et_fat_free_crm.yml +928 -0
- data/config/locales/pt-BR_ransack.yml +81 -0
- data/config/locales/th.rb +1 -1
- data/config/routes.rb +18 -18
- data/db/migrate/20100928030598_create_sessions.rb +1 -1
- data/db/migrate/20100928030599_create_users.rb +2 -2
- data/db/migrate/20100928030600_create_openid_tables.rb +1 -1
- data/db/migrate/20100928030601_create_accounts.rb +2 -2
- data/db/migrate/20100928030602_create_permissions.rb +1 -1
- data/db/migrate/20100928030603_create_settings.rb +1 -1
- data/db/migrate/20100928030604_create_preferences.rb +2 -2
- data/db/migrate/20100928030605_create_campaigns.rb +2 -2
- data/db/migrate/20100928030606_create_leads.rb +2 -2
- data/db/migrate/20100928030607_create_contacts.rb +2 -2
- data/db/migrate/20100928030608_create_opportunities.rb +2 -2
- data/db/migrate/20100928030609_create_account_contacts.rb +1 -1
- data/db/migrate/20100928030610_create_account_opportunities.rb +1 -1
- data/db/migrate/20100928030611_create_contact_opportunities.rb +1 -1
- data/db/migrate/20100928030612_create_tasks.rb +2 -2
- data/db/migrate/20100928030613_create_comments.rb +1 -1
- data/db/migrate/20100928030614_create_activities.rb +1 -1
- data/db/migrate/20100928030615_create_avatars.rb +1 -1
- data/db/migrate/20100928030616_rename_remember_token.rb +1 -1
- data/db/migrate/20100928030617_drop_openid_tables.rb +1 -1
- data/db/migrate/20100928030618_add_admin_to_users.rb +1 -1
- data/db/migrate/20100928030619_add_suspended_to_users.rb +1 -1
- data/db/migrate/20100928030620_remove_uuid.rb +2 -2
- data/db/migrate/20100928030621_add_email_to_accounts.rb +1 -1
- data/db/migrate/20100928030622_add_background_info_to_models.rb +1 -1
- data/db/migrate/20100928030623_create_addresses.rb +2 -2
- data/db/migrate/20100928030624_add_index_on_permissions.rb +3 -3
- data/db/migrate/20100928030625_create_emails.rb +2 -2
- data/db/migrate/20100928030626_add_state_to_timeline_objects.rb +1 -1
- data/db/migrate/20100928030627_acts_as_taggable_on_migration.rb +2 -2
- data/db/migrate/20101221123456_add_single_access_token_to_users.rb +1 -1
- data/db/migrate/20101221345678_add_rating_and_category_to_accounts.rb +1 -1
- data/db/migrate/20110719082054_add_skype_to_contacts_and_leads.rb +1 -1
- data/db/migrate/20111101083437_create_fields.rb +1 -1
- data/db/migrate/20111101090312_create_field_groups.rb +1 -1
- data/db/migrate/20111116091952_add_field_groups_tag_id.rb +1 -1
- data/db/migrate/20111117041311_change_fields_collection_to_text.rb +1 -1
- data/db/migrate/20111201030535_add_field_groups_klass_name.rb +2 -2
- data/db/migrate/20120121054235_create_lists.rb +1 -1
- data/db/migrate/20120216031616_create_versions.rb +3 -3
- data/db/migrate/20120216042541_is_paranoid_to_paper_trail.rb +1 -1
- data/db/migrate/20120220233724_add_versions_object_changes.rb +1 -1
- data/db/migrate/20120224073107_remove_default_value_and_clear_settings.rb +1 -1
- data/db/migrate/20120309070209_add_versions_related.rb +1 -1
- data/db/migrate/20120314080441_add_subscribed_users_to_entities.rb +2 -2
- data/db/migrate/20120316045804_activities_to_versions.rb +1 -1
- data/db/migrate/20120405080727_change_subscribed_users_to_set.rb +1 -1
- data/db/migrate/20120405080742_change_further_subscribed_users_to_set.rb +2 -2
- data/db/migrate/20120406082136_create_groups.rb +2 -2
- data/db/migrate/20120413034923_add_index_on_versions_item_type.rb +1 -1
- data/db/migrate/20120510025219_add_not_null_constraints_for_timestamp_columns.rb +3 -3
- data/db/migrate/20120528102124_increase_length_of_version_events.rb +1 -1
- data/db/migrate/20120801032706_add_pair_id_to_fields.rb +1 -1
- data/db/migrate/20121003063155_add_settings_to_custom_fields.rb +1 -1
- data/db/migrate/20121221033947_fix_country_mapping.rb +1 -1
- data/db/migrate/20131207033244_add_user_id_to_lists.rb +1 -1
- data/db/migrate/20140916011927_add_created_at_index_on_versions.rb +1 -1
- data/db/migrate/20140916012922_add_indexes_to_model_associations.rb +3 -3
- data/db/migrate/20141126031837_increase_email_to254_chars.rb +1 -1
- data/db/migrate/20141230021159_add_transaction_id_column_to_versions.rb +1 -1
- data/db/migrate/20141230205453_add_missing_unique_indices.acts_as_taggable_on_engine.rb +4 -4
- data/db/migrate/20141230205454_add_taggings_counter_cache_to_tags.acts_as_taggable_on_engine.rb +1 -1
- data/db/migrate/20141230205455_add_missing_taggable_index.acts_as_taggable_on_engine.rb +3 -3
- data/db/migrate/20150123060900_convert_radio_to_radio_buttons.rb +1 -1
- data/db/migrate/20150227123054_remove_last_request_at_from_users.rb +1 -1
- data/db/migrate/20150427131956_create_index_related_type.rb +3 -3
- data/db/migrate/20160511053730_add_account_contacts_index.rb +2 -2
- data/docker-compose.yml +17 -13
- data/fat_free_crm.gemspec +4 -6
- data/lib/development_tasks/license.rake +12 -9
- data/lib/fat_free_crm/callback.rb +4 -4
- data/lib/fat_free_crm/engine.rb +2 -2
- data/lib/fat_free_crm/exportable.rb +2 -2
- data/lib/fat_free_crm/fields.rb +2 -4
- data/lib/fat_free_crm/gem_ext.rb +0 -1
- data/lib/fat_free_crm/gem_ext/rake/task.rb +2 -0
- data/lib/fat_free_crm/mail_processor/base.rb +4 -4
- data/lib/fat_free_crm/mail_processor/dropbox.rb +1 -1
- data/lib/fat_free_crm/permissions.rb +5 -5
- data/lib/fat_free_crm/sortable.rb +1 -1
- data/lib/fat_free_crm/version.rb +1 -1
- data/lib/gravatar_image_tag.rb +1 -0
- data/lib/tasks/ffcrm/demo.rake +2 -2
- data/spec/controllers/admin/users_controller_spec.rb +25 -25
- data/spec/controllers/authentications_controller_spec.rb +9 -9
- data/spec/controllers/comments_controller_spec.rb +15 -15
- data/spec/controllers/emails_controller_spec.rb +2 -2
- data/spec/controllers/entities/accounts_controller_spec.rb +46 -46
- data/spec/controllers/entities/campaigns_controller_spec.rb +46 -46
- data/spec/controllers/entities/contacts_controller_spec.rb +55 -55
- data/spec/controllers/entities/leads_controller_spec.rb +85 -85
- data/spec/controllers/entities/opportunities_controller_spec.rb +74 -74
- data/spec/controllers/home_controller_spec.rb +11 -11
- data/spec/controllers/passwords_controller_spec.rb +2 -2
- data/spec/controllers/tasks_controller_spec.rb +37 -37
- data/spec/controllers/users_controller_spec.rb +31 -31
- data/spec/factories/campaign_factories.rb +1 -1
- data/spec/factories/contact_factories.rb +1 -1
- data/spec/factories/field_factories.rb +1 -1
- data/spec/factories/lead_factories.rb +2 -2
- data/spec/factories/opportunity_factories.rb +3 -3
- data/spec/factories/shared_factories.rb +1 -1
- data/spec/factories/task_factories.rb +1 -1
- data/spec/features/support/browser.rb +9 -1
- data/spec/lib/fields_spec.rb +2 -2
- data/spec/lib/permissions_spec.rb +38 -6
- data/spec/lib/view_factory_spec.rb +2 -2
- data/spec/models/fields/custom_field_spec.rb +3 -3
- data/spec/models/observers/entity_observer_spec.rb +1 -1
- data/spec/models/polymorphic/version_spec.rb +11 -11
- data/spec/models/users/abilities/user_ability_spec.rb +8 -3
- data/spec/models/users/permission_spec.rb +8 -0
- data/spec/models/users/user_spec.rb +1 -1
- data/spec/shared/controllers.rb +10 -10
- data/spec/spec_helper.rb +1 -1
- data/spec/views/accounts/index.haml_spec.rb +1 -1
- data/spec/views/accounts/update.js.haml_spec.rb +2 -2
- data/spec/views/admin/users/update.js.haml_spec.rb +2 -2
- data/spec/views/application/auto_complete.haml_spec.rb +1 -1
- data/spec/views/campaigns/index.haml_spec.rb +1 -1
- data/spec/views/campaigns/update.js.haml_spec.rb +2 -2
- data/spec/views/contacts/index.haml_spec.rb +1 -1
- data/spec/views/contacts/update.js.haml_spec.rb +2 -2
- data/spec/views/home/options.js.haml_spec.rb +1 -1
- data/spec/views/leads/index.haml_spec.rb +1 -1
- data/spec/views/leads/promote.js.haml_spec.rb +2 -2
- data/spec/views/leads/update.js.haml_spec.rb +2 -2
- data/spec/views/opportunities/index.haml_spec.rb +1 -1
- data/spec/views/opportunities/update.js.haml_spec.rb +1 -1
- data/spec/views/tasks/_edit.haml_spec.rb +2 -2
- data/spec/views/tasks/create.js.haml_spec.rb +2 -2
- data/spec/views/tasks/edit.js.haml_spec.rb +1 -1
- data/spec/views/users/change_password.js.haml_spec.rb +2 -2
- data/spec/views/users/update.js.haml_spec.rb +2 -2
- data/spec/views/users/upload_avatar.js.haml_spec.rb +2 -2
- metadata +17 -20
- data/lib/fat_free_crm/gem_ext/active_record/schema_dumper.rb +0 -27
@@ -44,14 +44,14 @@ describe LeadsController do
|
|
44
44
|
get :index
|
45
45
|
# Note: can't compare campaigns directly because of BigDecimals.
|
46
46
|
expect(assigns[:leads].size).to eq(2)
|
47
|
-
expect(assigns[:leads].map(&:status).sort).to eq(%w
|
47
|
+
expect(assigns[:leads].map(&:status).sort).to eq(%w[contacted new])
|
48
48
|
end
|
49
49
|
|
50
50
|
it "should perform lookup using query string" do
|
51
51
|
@billy_bones = FactoryGirl.create(:lead, user: current_user, first_name: "Billy", last_name: "Bones")
|
52
52
|
@captain_flint = FactoryGirl.create(:lead, user: current_user, first_name: "Captain", last_name: "Flint")
|
53
53
|
|
54
|
-
get :index, query: "bill"
|
54
|
+
get :index, params: { query: "bill" }
|
55
55
|
expect(assigns[:leads]).to eq([@billy_bones])
|
56
56
|
expect(assigns[:current_query]).to eq("bill")
|
57
57
|
expect(session[:leads_current_query]).to eq("bill")
|
@@ -60,7 +60,7 @@ describe LeadsController do
|
|
60
60
|
describe "AJAX pagination" do
|
61
61
|
it "should pick up page number from params" do
|
62
62
|
@leads = [FactoryGirl.create(:lead, user: current_user)]
|
63
|
-
|
63
|
+
get :index, params: { page: 42 }, xhr: true
|
64
64
|
|
65
65
|
expect(assigns[:current_page].to_i).to eq(42)
|
66
66
|
expect(assigns[:leads]).to eq([]) # page #42 should be empty if there's only one lead ;-)
|
@@ -72,7 +72,7 @@ describe LeadsController do
|
|
72
72
|
session[:leads_current_page] = 42
|
73
73
|
session[:leads_current_query] = "bill"
|
74
74
|
@leads = [FactoryGirl.create(:lead, user: current_user)]
|
75
|
-
|
75
|
+
get :index, params: { query: "bill" }, xhr: true
|
76
76
|
|
77
77
|
expect(assigns[:current_page]).to eq(42)
|
78
78
|
expect(assigns[:leads]).to eq([])
|
@@ -83,7 +83,7 @@ describe LeadsController do
|
|
83
83
|
session[:leads_current_page] = 42
|
84
84
|
session[:leads_current_query] = "bill"
|
85
85
|
@leads = [FactoryGirl.create(:lead, user: current_user)]
|
86
|
-
|
86
|
+
get :index, xhr: true
|
87
87
|
|
88
88
|
expect(assigns[:current_page]).to eq(1)
|
89
89
|
expect(assigns[:leads]).to eq(@leads)
|
@@ -125,14 +125,14 @@ describe LeadsController do
|
|
125
125
|
end
|
126
126
|
|
127
127
|
it "should expose the requested lead as @lead and render [show] template" do
|
128
|
-
get :show, id: 42
|
128
|
+
get :show, params: { id: 42 }
|
129
129
|
expect(assigns[:lead]).to eq(@lead)
|
130
130
|
expect(assigns[:comment].attributes).to eq(@comment.attributes)
|
131
131
|
expect(response).to render_template("leads/show")
|
132
132
|
end
|
133
133
|
|
134
134
|
it "should update an activity when viewing the lead" do
|
135
|
-
get :show, id: @lead.id
|
135
|
+
get :show, params: { id: @lead.id }
|
136
136
|
expect(@lead.versions.last.event).to eq('view')
|
137
137
|
end
|
138
138
|
end
|
@@ -144,7 +144,7 @@ describe LeadsController do
|
|
144
144
|
expect(@lead).to receive(:to_json).and_return("generated JSON")
|
145
145
|
|
146
146
|
request.env["HTTP_ACCEPT"] = "application/json"
|
147
|
-
get :show, id: 42
|
147
|
+
get :show, params: { id: 42 }
|
148
148
|
expect(response.body).to eq("generated JSON")
|
149
149
|
end
|
150
150
|
end
|
@@ -156,7 +156,7 @@ describe LeadsController do
|
|
156
156
|
expect(@lead).to receive(:to_xml).and_return("generated XML")
|
157
157
|
|
158
158
|
request.env["HTTP_ACCEPT"] = "application/xml"
|
159
|
-
get :show, id: 42
|
159
|
+
get :show, params: { id: 42 }
|
160
160
|
expect(response.body).to eq("generated XML")
|
161
161
|
end
|
162
162
|
end
|
@@ -166,7 +166,7 @@ describe LeadsController do
|
|
166
166
|
@lead = FactoryGirl.create(:lead, user: current_user)
|
167
167
|
@lead.destroy
|
168
168
|
|
169
|
-
get :show, id: @lead.id
|
169
|
+
get :show, params: { id: @lead.id }
|
170
170
|
expect(flash[:warning]).not_to eq(nil)
|
171
171
|
expect(response).to redirect_to(leads_path)
|
172
172
|
end
|
@@ -174,7 +174,7 @@ describe LeadsController do
|
|
174
174
|
it "should redirect to lead index if the lead is protected" do
|
175
175
|
@private = FactoryGirl.create(:lead, user: FactoryGirl.create(:user), access: "Private")
|
176
176
|
|
177
|
-
get :show, id: @private.id
|
177
|
+
get :show, params: { id: @private.id }
|
178
178
|
expect(flash[:warning]).not_to eq(nil)
|
179
179
|
expect(response).to redirect_to(leads_path)
|
180
180
|
end
|
@@ -184,7 +184,7 @@ describe LeadsController do
|
|
184
184
|
@lead.destroy
|
185
185
|
request.env["HTTP_ACCEPT"] = "application/json"
|
186
186
|
|
187
|
-
get :show, id: @lead.id
|
187
|
+
get :show, params: { id: @lead.id }
|
188
188
|
expect(response.code).to eq("404") # :not_found
|
189
189
|
end
|
190
190
|
|
@@ -193,7 +193,7 @@ describe LeadsController do
|
|
193
193
|
@lead.destroy
|
194
194
|
request.env["HTTP_ACCEPT"] = "application/xml"
|
195
195
|
|
196
|
-
get :show, id: @lead.id
|
196
|
+
get :show, params: { id: @lead.id }
|
197
197
|
expect(response.code).to eq("404") # :not_found
|
198
198
|
end
|
199
199
|
end
|
@@ -208,7 +208,7 @@ describe LeadsController do
|
|
208
208
|
allow(Lead).to receive(:new).and_return(@lead)
|
209
209
|
@campaigns = [FactoryGirl.create(:campaign, user: current_user)]
|
210
210
|
|
211
|
-
|
211
|
+
get :new, xhr: true
|
212
212
|
expect(assigns[:lead].attributes).to eq(@lead.attributes)
|
213
213
|
expect(assigns[:campaigns]).to eq(@campaigns)
|
214
214
|
expect(response).to render_template("leads/new")
|
@@ -217,7 +217,7 @@ describe LeadsController do
|
|
217
217
|
it "should create related object when necessary" do
|
218
218
|
@campaign = FactoryGirl.create(:campaign, id: 123)
|
219
219
|
|
220
|
-
|
220
|
+
get :new, params: { related: "campaign_123" }, xhr: true
|
221
221
|
expect(assigns[:campaign]).to eq(@campaign)
|
222
222
|
end
|
223
223
|
|
@@ -226,7 +226,7 @@ describe LeadsController do
|
|
226
226
|
@campaign = FactoryGirl.create(:campaign)
|
227
227
|
@campaign.destroy
|
228
228
|
|
229
|
-
|
229
|
+
get :new, params: { related: "campaign_#{@campaign.id}" }, xhr: true
|
230
230
|
expect(flash[:warning]).not_to eq(nil)
|
231
231
|
expect(response.body).to eq('window.location.href = "/campaigns";')
|
232
232
|
end
|
@@ -234,7 +234,7 @@ describe LeadsController do
|
|
234
234
|
it "should redirect to parent asset's index page with the message if parent asset got protected" do
|
235
235
|
@campaign = FactoryGirl.create(:campaign, access: "Private")
|
236
236
|
|
237
|
-
|
237
|
+
get :new, params: { related: "campaign_#{@campaign.id}" }, xhr: true
|
238
238
|
expect(flash[:warning]).not_to eq(nil)
|
239
239
|
expect(response.body).to eq('window.location.href = "/campaigns";')
|
240
240
|
end
|
@@ -248,7 +248,7 @@ describe LeadsController do
|
|
248
248
|
@lead = FactoryGirl.create(:lead, id: 42, user: current_user, campaign: nil)
|
249
249
|
@campaigns = [FactoryGirl.create(:campaign, user: current_user)]
|
250
250
|
|
251
|
-
|
251
|
+
get :edit, params: { id: 42 }, xhr: true
|
252
252
|
expect(assigns[:lead]).to eq(@lead)
|
253
253
|
expect(assigns[:campaigns]).to eq(@campaigns)
|
254
254
|
expect(response).to render_template("leads/edit")
|
@@ -258,7 +258,7 @@ describe LeadsController do
|
|
258
258
|
@lead = FactoryGirl.create(:lead, id: 42)
|
259
259
|
@previous = FactoryGirl.create(:lead, id: 321)
|
260
260
|
|
261
|
-
|
261
|
+
get :edit, params: { id: 42, previous: 321 }, xhr: true
|
262
262
|
expect(assigns[:previous]).to eq(@previous)
|
263
263
|
end
|
264
264
|
|
@@ -267,7 +267,7 @@ describe LeadsController do
|
|
267
267
|
@lead = FactoryGirl.create(:lead, user: current_user)
|
268
268
|
@lead.destroy
|
269
269
|
|
270
|
-
|
270
|
+
get :edit, params: { id: @lead.id }, xhr: true
|
271
271
|
expect(flash[:warning]).not_to eq(nil)
|
272
272
|
expect(response.body).to eq("window.location.reload();")
|
273
273
|
end
|
@@ -275,7 +275,7 @@ describe LeadsController do
|
|
275
275
|
it "should reload current page with the flash message if the lead is protected" do
|
276
276
|
@private = FactoryGirl.create(:lead, user: FactoryGirl.create(:user), access: "Private")
|
277
277
|
|
278
|
-
|
278
|
+
get :edit, params: { id: @private.id }, xhr: true
|
279
279
|
expect(flash[:warning]).not_to eq(nil)
|
280
280
|
expect(response.body).to eq("window.location.reload();")
|
281
281
|
end
|
@@ -290,7 +290,7 @@ describe LeadsController do
|
|
290
290
|
it "should notify the view if previous lead got deleted" do
|
291
291
|
@previous.destroy
|
292
292
|
|
293
|
-
|
293
|
+
get :edit, params: { id: @lead.id, previous: @previous.id }, xhr: true
|
294
294
|
expect(flash[:warning]).to eq(nil) # no warning, just silently remove the div
|
295
295
|
expect(assigns[:previous]).to eq(@previous.id)
|
296
296
|
expect(response).to render_template("leads/edit")
|
@@ -299,7 +299,7 @@ describe LeadsController do
|
|
299
299
|
it "should notify the view if previous lead got protected" do
|
300
300
|
@previous.update_attribute(:access, "Private")
|
301
301
|
|
302
|
-
|
302
|
+
get :edit, params: { id: @lead.id, previous: @previous.id }, xhr: true
|
303
303
|
expect(flash[:warning]).to eq(nil)
|
304
304
|
expect(assigns[:previous]).to eq(@previous.id)
|
305
305
|
expect(response).to render_template("leads/edit")
|
@@ -317,7 +317,7 @@ describe LeadsController do
|
|
317
317
|
allow(Lead).to receive(:new).and_return(@lead)
|
318
318
|
@campaigns = [FactoryGirl.create(:campaign, user: current_user)]
|
319
319
|
|
320
|
-
|
320
|
+
post :create, params: { lead: { first_name: "Billy", last_name: "Bones" } }, xhr: true
|
321
321
|
expect(assigns(:lead)).to eq(@lead)
|
322
322
|
expect(assigns(:campaigns)).to eq(@campaigns)
|
323
323
|
expect(assigns[:lead_status_total]).to be_nil
|
@@ -335,12 +335,12 @@ describe LeadsController do
|
|
335
335
|
@lead = FactoryGirl.build(:lead, campaign: @campaign, user: current_user, access: "Shared")
|
336
336
|
allow(Lead).to receive(:new).and_return(@lead)
|
337
337
|
|
338
|
-
|
338
|
+
post :create, params: { lead: { first_name: "Billy", last_name: "Bones", access: "Campaign", user_ids: %w[7 8] }, campaign: @campaign.id }, xhr: true
|
339
339
|
expect(assigns(:lead)).to eq(@lead)
|
340
340
|
expect(@lead.reload.access).to eq("Shared")
|
341
341
|
expect(@lead.permissions.map(&:user_id).sort).to eq([7, 8])
|
342
342
|
expect(@lead.permissions.map(&:asset_id)).to eq([@lead.id, @lead.id])
|
343
|
-
expect(@lead.permissions.map(&:asset_type)).to eq(%w
|
343
|
+
expect(@lead.permissions.map(&:asset_type)).to eq(%w[Lead Lead])
|
344
344
|
end
|
345
345
|
|
346
346
|
it "should get the data to update leads sidebar if called from leads index" do
|
@@ -348,7 +348,7 @@ describe LeadsController do
|
|
348
348
|
allow(Lead).to receive(:new).and_return(@lead)
|
349
349
|
|
350
350
|
request.env["HTTP_REFERER"] = "http://localhost/leads"
|
351
|
-
|
351
|
+
post :create, params: { lead: { first_name: "Billy", last_name: "Bones" } }, xhr: true
|
352
352
|
expect(assigns[:lead_status_total]).to be_an_instance_of(HashWithIndifferentAccess)
|
353
353
|
end
|
354
354
|
|
@@ -357,7 +357,7 @@ describe LeadsController do
|
|
357
357
|
allow(Lead).to receive(:new).and_return(@lead)
|
358
358
|
|
359
359
|
request.env["HTTP_REFERER"] = "http://localhost/leads"
|
360
|
-
|
360
|
+
post :create, params: { lead: { first_name: "Billy", last_name: "Bones" } }, xhr: true
|
361
361
|
expect(assigns[:leads]).to eq([@lead])
|
362
362
|
end
|
363
363
|
|
@@ -366,14 +366,14 @@ describe LeadsController do
|
|
366
366
|
@lead = FactoryGirl.build(:lead, user: current_user, campaign: @campaign)
|
367
367
|
|
368
368
|
request.env["HTTP_REFERER"] = "http://localhost/campaigns/#{@campaign.id}"
|
369
|
-
|
369
|
+
put :create, params: { lead: { first_name: "Billy", last_name: "Bones" }, campaign: @campaign.id }, xhr: true
|
370
370
|
expect(assigns[:campaign]).to eq(@campaign)
|
371
371
|
end
|
372
372
|
|
373
373
|
it "should add a new comment to the newly created lead when specified" do
|
374
374
|
@lead = FactoryGirl.create(:lead)
|
375
375
|
allow(Lead).to receive(:new).and_return(@lead)
|
376
|
-
|
376
|
+
post :create, params: { lead: { first_name: "Test", last_name: "Lead" }, comment_body: "This is an important lead." }, xhr: true
|
377
377
|
expect(@lead.reload.comments.map(&:comment)).to include("This is an important lead.")
|
378
378
|
end
|
379
379
|
end
|
@@ -384,7 +384,7 @@ describe LeadsController do
|
|
384
384
|
allow(Lead).to receive(:new).and_return(@lead)
|
385
385
|
@campaigns = [FactoryGirl.create(:campaign, user: current_user)]
|
386
386
|
|
387
|
-
|
387
|
+
post :create, params: { lead: { first_name: nil } }, xhr: true
|
388
388
|
expect(assigns(:lead)).to eq(@lead)
|
389
389
|
expect(assigns(:campaigns)).to eq(@campaigns)
|
390
390
|
expect(assigns[:lead_status_total]).to eq(nil)
|
@@ -401,7 +401,7 @@ describe LeadsController do
|
|
401
401
|
it "should update the requested lead, expose it as @lead, and render [update] template" do
|
402
402
|
@lead = FactoryGirl.create(:lead, first_name: "Billy", user: current_user)
|
403
403
|
|
404
|
-
|
404
|
+
put :update, params: { id: @lead.id, lead: { first_name: "Bones" } }, xhr: true
|
405
405
|
expect(@lead.reload.first_name).to eq("Bones")
|
406
406
|
expect(assigns[:lead]).to eq(@lead)
|
407
407
|
expect(assigns[:lead_status_total]).to eq(nil)
|
@@ -411,14 +411,14 @@ describe LeadsController do
|
|
411
411
|
it "should update lead status" do
|
412
412
|
@lead = FactoryGirl.create(:lead, status: "new", user: current_user)
|
413
413
|
|
414
|
-
|
414
|
+
put :update, params: { id: @lead.id, lead: { status: "rejected" } }, xhr: true
|
415
415
|
expect(@lead.reload.status).to eq("rejected")
|
416
416
|
end
|
417
417
|
|
418
418
|
it "should update lead source" do
|
419
419
|
@lead = FactoryGirl.create(:lead, source: "campaign", user: current_user)
|
420
420
|
|
421
|
-
|
421
|
+
put :update, params: { id: @lead.id, lead: { source: "cald_call" } }, xhr: true
|
422
422
|
expect(@lead.reload.source).to eq("cald_call")
|
423
423
|
end
|
424
424
|
|
@@ -426,7 +426,7 @@ describe LeadsController do
|
|
426
426
|
@campaigns = { old: FactoryGirl.create(:campaign), new: FactoryGirl.create(:campaign) }
|
427
427
|
@lead = FactoryGirl.create(:lead, campaign: @campaigns[:old])
|
428
428
|
|
429
|
-
|
429
|
+
put :update, params: { id: @lead.id, lead: { campaign_id: @campaigns[:new].id } }, xhr: true
|
430
430
|
expect(@lead.reload.campaign).to eq(@campaigns[:new])
|
431
431
|
end
|
432
432
|
|
@@ -435,7 +435,7 @@ describe LeadsController do
|
|
435
435
|
@lead = FactoryGirl.create(:lead, campaign: @campaign)
|
436
436
|
@count = @campaign.reload.leads_count
|
437
437
|
|
438
|
-
|
438
|
+
put :update, params: { id: @lead, lead: { campaign_id: nil } }, xhr: true
|
439
439
|
expect(@lead.reload.campaign).to eq(nil)
|
440
440
|
expect(@campaign.reload.leads_count).to eq(@count - 1)
|
441
441
|
end
|
@@ -445,7 +445,7 @@ describe LeadsController do
|
|
445
445
|
@lead = FactoryGirl.create(:lead, campaign: nil)
|
446
446
|
@count = @campaign.leads_count
|
447
447
|
|
448
|
-
|
448
|
+
put :update, params: { id: @lead, lead: { campaign_id: @campaign.id } }, xhr: true
|
449
449
|
expect(@lead.reload.campaign).to eq(@campaign)
|
450
450
|
expect(@campaign.reload.leads_count).to eq(@count + 1)
|
451
451
|
end
|
@@ -455,7 +455,7 @@ describe LeadsController do
|
|
455
455
|
@lead = FactoryGirl.create(:lead, campaign: @campaigns[:old])
|
456
456
|
@counts = { old: @campaigns[:old].reload.leads_count, new: @campaigns[:new].leads_count }
|
457
457
|
|
458
|
-
|
458
|
+
put :update, params: { id: @lead, lead: { campaign_id: @campaigns[:new].id } }, xhr: true
|
459
459
|
expect(@lead.reload.campaign).to eq(@campaigns[:new])
|
460
460
|
expect(@campaigns[:old].reload.leads_count).to eq(@counts[:old] - 1)
|
461
461
|
expect(@campaigns[:new].reload.leads_count).to eq(@counts[:new] + 1)
|
@@ -466,7 +466,7 @@ describe LeadsController do
|
|
466
466
|
he = FactoryGirl.create(:user, id: 7)
|
467
467
|
she = FactoryGirl.create(:user, id: 8)
|
468
468
|
|
469
|
-
|
469
|
+
put :update, params: { id: @lead.id, lead: { access: "Shared", user_ids: %w[7 8] } }, xhr: true
|
470
470
|
expect(@lead.user_ids.sort).to eq([he.id, she.id])
|
471
471
|
end
|
472
472
|
|
@@ -474,7 +474,7 @@ describe LeadsController do
|
|
474
474
|
@lead = FactoryGirl.create(:lead)
|
475
475
|
|
476
476
|
request.env["HTTP_REFERER"] = "http://localhost/leads"
|
477
|
-
|
477
|
+
put :update, params: { id: @lead.id, lead: { first_name: "Billy" } }, xhr: true
|
478
478
|
expect(assigns[:lead_status_total]).not_to be_nil
|
479
479
|
expect(assigns[:lead_status_total]).to be_an_instance_of(HashWithIndifferentAccess)
|
480
480
|
end
|
@@ -484,7 +484,7 @@ describe LeadsController do
|
|
484
484
|
@lead = FactoryGirl.create(:lead, campaign: @campaign)
|
485
485
|
|
486
486
|
request.env["HTTP_REFERER"] = "http://localhost/campaigns/#{@campaign.id}"
|
487
|
-
|
487
|
+
put :update, params: { id: @lead.id, lead: { first_name: "Hello" } }, xhr: true
|
488
488
|
expect(assigns[:campaign]).to eq(@campaign)
|
489
489
|
end
|
490
490
|
|
@@ -493,7 +493,7 @@ describe LeadsController do
|
|
493
493
|
@lead = FactoryGirl.create(:lead, user: current_user)
|
494
494
|
@lead.destroy
|
495
495
|
|
496
|
-
|
496
|
+
put :update, params: { id: @lead.id }, xhr: true
|
497
497
|
expect(flash[:warning]).not_to eq(nil)
|
498
498
|
expect(response.body).to eq("window.location.reload();")
|
499
499
|
end
|
@@ -501,7 +501,7 @@ describe LeadsController do
|
|
501
501
|
it "should reload current page with the flash message if the lead is protected" do
|
502
502
|
@private = FactoryGirl.create(:lead, user: FactoryGirl.create(:user), access: "Private")
|
503
503
|
|
504
|
-
|
504
|
+
put :update, params: { id: @private.id }, xhr: true
|
505
505
|
expect(flash[:warning]).not_to eq(nil)
|
506
506
|
expect(response.body).to eq("window.location.reload();")
|
507
507
|
end
|
@@ -513,7 +513,7 @@ describe LeadsController do
|
|
513
513
|
@lead = FactoryGirl.create(:lead, id: 42, user: current_user, campaign: nil)
|
514
514
|
@campaigns = [FactoryGirl.create(:campaign, user: current_user)]
|
515
515
|
|
516
|
-
|
516
|
+
put :update, params: { id: 42, lead: { first_name: nil } }, xhr: true
|
517
517
|
expect(assigns[:lead]).to eq(@lead)
|
518
518
|
expect(assigns[:campaigns]).to eq(@campaigns)
|
519
519
|
expect(response).to render_template("leads/update")
|
@@ -531,7 +531,7 @@ describe LeadsController do
|
|
531
531
|
|
532
532
|
describe "AJAX request" do
|
533
533
|
it "should destroy the requested lead and render [destroy] template" do
|
534
|
-
|
534
|
+
delete :destroy, params: { id: @lead.id }, xhr: true
|
535
535
|
|
536
536
|
expect(assigns[:leads]).to eq(nil) # @lead got deleted
|
537
537
|
expect { Lead.find(@lead.id) }.to raise_error(ActiveRecord::RecordNotFound)
|
@@ -546,7 +546,7 @@ describe LeadsController do
|
|
546
546
|
it "should get data for the sidebar" do
|
547
547
|
@another_lead = FactoryGirl.create(:lead, user: current_user)
|
548
548
|
|
549
|
-
|
549
|
+
delete :destroy, params: { id: @lead.id }, xhr: true
|
550
550
|
expect(assigns[:leads]).to eq([@another_lead]) # @lead got deleted
|
551
551
|
expect(assigns[:lead_status_total]).not_to be_nil
|
552
552
|
expect(assigns[:lead_status_total]).to be_an_instance_of(HashWithIndifferentAccess)
|
@@ -556,7 +556,7 @@ describe LeadsController do
|
|
556
556
|
it "should try previous page and render index action if current page has no leads" do
|
557
557
|
session[:leads_current_page] = 42
|
558
558
|
|
559
|
-
|
559
|
+
delete :destroy, params: { id: @lead.id }, xhr: true
|
560
560
|
expect(session[:leads_current_page]).to eq(41)
|
561
561
|
expect(response).to render_template("leads/index")
|
562
562
|
end
|
@@ -564,7 +564,7 @@ describe LeadsController do
|
|
564
564
|
it "should render index action when deleting last lead" do
|
565
565
|
session[:leads_current_page] = 1
|
566
566
|
|
567
|
-
|
567
|
+
delete :destroy, params: { id: @lead.id }, xhr: true
|
568
568
|
expect(session[:leads_current_page]).to eq(1)
|
569
569
|
expect(response).to render_template("leads/index")
|
570
570
|
end
|
@@ -578,13 +578,13 @@ describe LeadsController do
|
|
578
578
|
end
|
579
579
|
|
580
580
|
it "should reset current page to 1" do
|
581
|
-
|
581
|
+
delete :destroy, params: { id: @lead.id }, xhr: true
|
582
582
|
expect(session[:leads_current_page]).to eq(1)
|
583
583
|
expect(response).to render_template("leads/destroy")
|
584
584
|
end
|
585
585
|
|
586
586
|
it "should reload campaiign to be able to refresh its summary" do
|
587
|
-
|
587
|
+
delete :destroy, params: { id: @lead.id }, xhr: true
|
588
588
|
expect(assigns[:campaign]).to eq(@campaign)
|
589
589
|
expect(response).to render_template("leads/destroy")
|
590
590
|
end
|
@@ -595,7 +595,7 @@ describe LeadsController do
|
|
595
595
|
@lead = FactoryGirl.create(:lead, user: current_user)
|
596
596
|
@lead.destroy
|
597
597
|
|
598
|
-
|
598
|
+
delete :destroy, params: { id: @lead.id }, xhr: true
|
599
599
|
expect(flash[:warning]).not_to eq(nil)
|
600
600
|
expect(response.body).to eq("window.location.reload();")
|
601
601
|
end
|
@@ -603,7 +603,7 @@ describe LeadsController do
|
|
603
603
|
it "should reload current page with the flash message if the lead is protected" do
|
604
604
|
@private = FactoryGirl.create(:lead, user: FactoryGirl.create(:user), access: "Private")
|
605
605
|
|
606
|
-
|
606
|
+
delete :destroy, params: { id: @private.id }, xhr: true
|
607
607
|
expect(flash[:warning]).not_to eq(nil)
|
608
608
|
expect(response.body).to eq("window.location.reload();")
|
609
609
|
end
|
@@ -612,7 +612,7 @@ describe LeadsController do
|
|
612
612
|
|
613
613
|
describe "HTML request" do
|
614
614
|
it "should redirect to Leads index when a lead gets deleted from its landing page" do
|
615
|
-
delete :destroy, id: @lead.id
|
615
|
+
delete :destroy, params: { id: @lead.id }
|
616
616
|
expect(flash[:notice]).not_to eq(nil)
|
617
617
|
expect(session[:leads_current_page]).to eq(1)
|
618
618
|
expect(response).to redirect_to(leads_path)
|
@@ -622,7 +622,7 @@ describe LeadsController do
|
|
622
622
|
@lead = FactoryGirl.create(:lead, user: current_user)
|
623
623
|
@lead.destroy
|
624
624
|
|
625
|
-
delete :destroy, id: @lead.id
|
625
|
+
delete :destroy, params: { id: @lead.id }
|
626
626
|
expect(flash[:warning]).not_to eq(nil)
|
627
627
|
expect(response).to redirect_to(leads_path)
|
628
628
|
end
|
@@ -630,7 +630,7 @@ describe LeadsController do
|
|
630
630
|
it "should redirect to lead index with the flash message if the lead is protected" do
|
631
631
|
@private = FactoryGirl.create(:lead, user: FactoryGirl.create(:user), access: "Private")
|
632
632
|
|
633
|
-
delete :destroy, id: @private.id
|
633
|
+
delete :destroy, params: { id: @private.id }
|
634
634
|
expect(flash[:warning]).not_to eq(nil)
|
635
635
|
expect(response).to redirect_to(leads_path)
|
636
636
|
end
|
@@ -648,7 +648,7 @@ describe LeadsController do
|
|
648
648
|
@account = Account.new(user: current_user, name: @lead.company, access: "Lead")
|
649
649
|
@opportunity = Opportunity.new(user: current_user, access: "Lead", stage: "prospecting", campaign: @lead.campaign, source: @lead.source)
|
650
650
|
|
651
|
-
|
651
|
+
get :convert, params: { id: @lead.id }, xhr: true
|
652
652
|
expect(assigns[:lead]).to eq(@lead)
|
653
653
|
expect(assigns[:accounts]).to eq(@accounts)
|
654
654
|
expect(assigns[:account].attributes).to eq(@account.attributes)
|
@@ -662,7 +662,7 @@ describe LeadsController do
|
|
662
662
|
@lead = FactoryGirl.create(:lead, user: current_user)
|
663
663
|
@lead.destroy
|
664
664
|
|
665
|
-
|
665
|
+
get :convert, params: { id: @lead.id }, xhr: true
|
666
666
|
expect(flash[:warning]).not_to eq(nil)
|
667
667
|
expect(response.body).to eq("window.location.reload();")
|
668
668
|
end
|
@@ -670,7 +670,7 @@ describe LeadsController do
|
|
670
670
|
it "should reload current page with the flash message if the lead is protected" do
|
671
671
|
@private = FactoryGirl.create(:lead, user: FactoryGirl.create(:user), access: "Private")
|
672
672
|
|
673
|
-
|
673
|
+
get :convert, params: { id: @private.id }, xhr: true
|
674
674
|
expect(flash[:warning]).not_to eq(nil)
|
675
675
|
expect(response.body).to eq("window.location.reload();")
|
676
676
|
end
|
@@ -685,7 +685,7 @@ describe LeadsController do
|
|
685
685
|
it "should notify the view if previous lead got deleted" do
|
686
686
|
@previous.destroy
|
687
687
|
|
688
|
-
|
688
|
+
get :convert, params: { id: @lead.id, previous: @previous.id }, xhr: true
|
689
689
|
expect(flash[:warning]).to eq(nil) # no warning, just silently remove the div
|
690
690
|
expect(assigns[:previous]).to eq(@previous.id)
|
691
691
|
expect(response).to render_template("leads/convert")
|
@@ -694,7 +694,7 @@ describe LeadsController do
|
|
694
694
|
it "should notify the view if previous lead got protected" do
|
695
695
|
@previous.update_attribute(:access, "Private")
|
696
696
|
|
697
|
-
|
697
|
+
get :convert, params: { id: @lead.id, previous: @previous.id }, xhr: true
|
698
698
|
expect(flash[:warning]).to eq(nil)
|
699
699
|
expect(assigns[:previous]).to eq(@previous.id)
|
700
700
|
expect(response).to render_template("leads/convert")
|
@@ -715,7 +715,7 @@ describe LeadsController do
|
|
715
715
|
@contact = FactoryGirl.build(:contact, user: current_user, lead: @lead)
|
716
716
|
allow(Contact).to receive(:new).and_return(@contact)
|
717
717
|
|
718
|
-
|
718
|
+
put :promote, params: { id: 42, account: { id: 123 }, opportunity: { name: "Hello" } }, xhr: true
|
719
719
|
expect(@lead.reload.status).to eq("converted")
|
720
720
|
expect(assigns[:lead]).to eq(@lead)
|
721
721
|
expect(assigns[:account]).to eq(@account)
|
@@ -742,29 +742,29 @@ describe LeadsController do
|
|
742
742
|
@opportunity.permissions << FactoryGirl.create(:permission, user: she, asset: @opportunity)
|
743
743
|
allow(@opportunity).to receive(:new).and_return(@opportunity)
|
744
744
|
|
745
|
-
|
745
|
+
put :promote, params: { id: @lead.id, access: "Lead", account: { name: "Hello", access: "Lead", user_id: current_user.id }, opportunity: { name: "World", access: "Lead", user_id: current_user.id } }, xhr: true
|
746
746
|
expect(@account.access).to eq("Shared")
|
747
747
|
expect(@account.permissions.map(&:user_id).sort).to eq([7, 8])
|
748
748
|
expect(@account.permissions.map(&:asset_id)).to eq([@account.id, @account.id])
|
749
|
-
expect(@account.permissions.map(&:asset_type)).to eq(%w
|
749
|
+
expect(@account.permissions.map(&:asset_type)).to eq(%w[Account Account])
|
750
750
|
expect(@opportunity.access).to eq("Shared")
|
751
751
|
expect(@opportunity.permissions.map(&:user_id).sort).to eq([7, 8])
|
752
752
|
expect(@opportunity.permissions.map(&:asset_id)).to eq([@opportunity.id, @opportunity.id])
|
753
|
-
expect(@opportunity.permissions.map(&:asset_type)).to eq(%w
|
753
|
+
expect(@opportunity.permissions.map(&:asset_type)).to eq(%w[Opportunity Opportunity])
|
754
754
|
end
|
755
755
|
|
756
756
|
it "should assign lead's campaign to the newly created opportunity" do
|
757
757
|
@campaign = FactoryGirl.create(:campaign)
|
758
758
|
@lead = FactoryGirl.create(:lead, user: current_user, campaign: @campaign)
|
759
759
|
|
760
|
-
|
760
|
+
put :promote, params: { id: @lead.id, account: { name: "Hello" }, opportunity: { name: "Hello", campaign_id: @campaign.id } }, xhr: true
|
761
761
|
expect(assigns[:opportunity].campaign).to eq(@campaign)
|
762
762
|
end
|
763
763
|
|
764
764
|
it "should assign lead's source to the newly created opportunity" do
|
765
765
|
@lead = FactoryGirl.create(:lead, user: current_user, source: "cold_call")
|
766
766
|
|
767
|
-
|
767
|
+
put :promote, params: { id: @lead.id, account: { name: "Hello" }, opportunity: { name: "Hello", source: @lead.source } }, xhr: true
|
768
768
|
expect(assigns[:opportunity].source).to eq(@lead.source)
|
769
769
|
end
|
770
770
|
|
@@ -772,7 +772,7 @@ describe LeadsController do
|
|
772
772
|
@lead = FactoryGirl.create(:lead)
|
773
773
|
request.env["HTTP_REFERER"] = "http://localhost/leads"
|
774
774
|
|
775
|
-
|
775
|
+
put :promote, params: { id: @lead.id, account: { name: "Hello" }, opportunity: {} }, xhr: true
|
776
776
|
expect(assigns[:lead_status_total]).not_to be_nil
|
777
777
|
expect(assigns[:lead_status_total]).to be_an_instance_of(HashWithIndifferentAccess)
|
778
778
|
end
|
@@ -782,7 +782,7 @@ describe LeadsController do
|
|
782
782
|
@lead = FactoryGirl.create(:lead, campaign: @campaign)
|
783
783
|
request.env["HTTP_REFERER"] = "http://localhost/campaigns/#{@campaign.id}"
|
784
784
|
|
785
|
-
|
785
|
+
put :promote, params: { id: @lead.id, account: { name: "Hello" }, opportunity: {} }, xhr: true
|
786
786
|
expect(assigns[:campaign]).to eq(@campaign)
|
787
787
|
end
|
788
788
|
|
@@ -792,7 +792,7 @@ describe LeadsController do
|
|
792
792
|
@contact = FactoryGirl.build(:contact, first_name: nil) # make it fail
|
793
793
|
allow(Contact).to receive(:new).and_return(@contact)
|
794
794
|
|
795
|
-
|
795
|
+
put :promote, params: { id: 42, account: { id: 123 } }, xhr: true
|
796
796
|
expect(@lead.reload.status).to eq("new")
|
797
797
|
expect(response).to render_template("leads/promote")
|
798
798
|
end
|
@@ -802,7 +802,7 @@ describe LeadsController do
|
|
802
802
|
@lead = FactoryGirl.create(:lead, user: current_user)
|
803
803
|
@lead.destroy
|
804
804
|
|
805
|
-
|
805
|
+
put :promote, params: { id: @lead.id }, xhr: true
|
806
806
|
expect(flash[:warning]).not_to eq(nil)
|
807
807
|
expect(response.body).to eq("window.location.reload();")
|
808
808
|
end
|
@@ -810,7 +810,7 @@ describe LeadsController do
|
|
810
810
|
it "should reload current page with the flash message if the lead is protected" do
|
811
811
|
@private = FactoryGirl.create(:lead, user: FactoryGirl.create(:user), access: "Private")
|
812
812
|
|
813
|
-
|
813
|
+
put :promote, params: { id: @private.id }, xhr: true
|
814
814
|
expect(flash[:warning]).not_to eq(nil)
|
815
815
|
expect(response.body).to eq("window.location.reload();")
|
816
816
|
end
|
@@ -827,7 +827,7 @@ describe LeadsController do
|
|
827
827
|
|
828
828
|
describe "AJAX request" do
|
829
829
|
it "should reject the requested lead and render [reject] template" do
|
830
|
-
|
830
|
+
put :reject, params: { id: @lead.id }, xhr: true
|
831
831
|
|
832
832
|
expect(assigns[:lead]).to eq(@lead.reload)
|
833
833
|
expect(@lead.status).to eq("rejected")
|
@@ -836,7 +836,7 @@ describe LeadsController do
|
|
836
836
|
|
837
837
|
it "should get the data for leads sidebar when called from leads index" do
|
838
838
|
request.env["HTTP_REFERER"] = "http://localhost/leads"
|
839
|
-
|
839
|
+
put :reject, params: { id: @lead.id }, xhr: true
|
840
840
|
expect(assigns[:lead_status_total]).not_to be_nil
|
841
841
|
expect(assigns[:lead_status_total]).to be_an_instance_of(HashWithIndifferentAccess)
|
842
842
|
end
|
@@ -846,7 +846,7 @@ describe LeadsController do
|
|
846
846
|
@lead = FactoryGirl.create(:lead, campaign: @campaign)
|
847
847
|
|
848
848
|
request.env["HTTP_REFERER"] = "http://localhost/campaigns/#{@campaign.id}"
|
849
|
-
|
849
|
+
put :reject, params: { id: @lead.id }, xhr: true
|
850
850
|
expect(assigns[:campaign]).to eq(@campaign)
|
851
851
|
end
|
852
852
|
|
@@ -855,7 +855,7 @@ describe LeadsController do
|
|
855
855
|
@lead = FactoryGirl.create(:lead, user: current_user)
|
856
856
|
@lead.destroy
|
857
857
|
|
858
|
-
|
858
|
+
put :reject, params: { id: @lead.id }, xhr: true
|
859
859
|
expect(flash[:warning]).not_to eq(nil)
|
860
860
|
expect(response.body).to eq("window.location.reload();")
|
861
861
|
end
|
@@ -863,7 +863,7 @@ describe LeadsController do
|
|
863
863
|
it "should reload current page with the flash message if the lead is protected" do
|
864
864
|
@private = FactoryGirl.create(:lead, user: FactoryGirl.create(:user), access: "Private")
|
865
865
|
|
866
|
-
|
866
|
+
put :reject, params: { id: @private.id }, xhr: true
|
867
867
|
expect(flash[:warning]).not_to eq(nil)
|
868
868
|
expect(response.body).to eq("window.location.reload();")
|
869
869
|
end
|
@@ -872,7 +872,7 @@ describe LeadsController do
|
|
872
872
|
|
873
873
|
describe "HTML request" do
|
874
874
|
it "should redirect to Leads index when a lead gets rejected from its landing page" do
|
875
|
-
put :reject, id: @lead.id
|
875
|
+
put :reject, params: { id: @lead.id }
|
876
876
|
|
877
877
|
expect(assigns[:lead]).to eq(@lead.reload)
|
878
878
|
expect(@lead.status).to eq("rejected")
|
@@ -885,7 +885,7 @@ describe LeadsController do
|
|
885
885
|
@lead = FactoryGirl.create(:lead, user: current_user)
|
886
886
|
@lead.destroy
|
887
887
|
|
888
|
-
put :reject, id: @lead.id
|
888
|
+
put :reject, params: { id: @lead.id }
|
889
889
|
expect(flash[:warning]).not_to eq(nil)
|
890
890
|
expect(response).to redirect_to(leads_path)
|
891
891
|
end
|
@@ -893,7 +893,7 @@ describe LeadsController do
|
|
893
893
|
it "should redirect to lead index if the lead is protected" do
|
894
894
|
@private = FactoryGirl.create(:lead, user: FactoryGirl.create(:user), access: "Private")
|
895
895
|
|
896
|
-
put :reject, id: @private.id
|
896
|
+
put :reject, params: { id: @private.id }
|
897
897
|
expect(flash[:warning]).not_to eq(nil)
|
898
898
|
expect(response).to redirect_to(leads_path)
|
899
899
|
end
|
@@ -954,7 +954,7 @@ describe LeadsController do
|
|
954
954
|
#----------------------------------------------------------------------------
|
955
955
|
describe "responding to GET redraw" do
|
956
956
|
it "should save user selected lead preference" do
|
957
|
-
|
957
|
+
get :redraw, params: { per_page: 42, view: "long", sort_by: "first_name", naming: "after" }, xhr: true
|
958
958
|
expect(current_user.preference[:leads_per_page]).to eq("42")
|
959
959
|
expect(current_user.preference[:leads_index_view]).to eq("long")
|
960
960
|
expect(current_user.preference[:leads_sort_by]).to eq("leads.first_name ASC")
|
@@ -962,13 +962,13 @@ describe LeadsController do
|
|
962
962
|
end
|
963
963
|
|
964
964
|
it "should set similar options for Contacts" do
|
965
|
-
|
965
|
+
get :redraw, params: { sort_by: "first_name", naming: "after" }, xhr: true
|
966
966
|
expect(current_user.pref[:contacts_sort_by]).to eq("contacts.first_name ASC")
|
967
967
|
expect(current_user.pref[:contacts_naming]).to eq("after")
|
968
968
|
end
|
969
969
|
|
970
970
|
it "should reset current page to 1" do
|
971
|
-
|
971
|
+
get :redraw, params: { per_page: 42, view: "long", sort_by: "first_name", naming: "after" }, xhr: true
|
972
972
|
expect(session[:leads_current_page]).to eq(1)
|
973
973
|
end
|
974
974
|
|
@@ -978,7 +978,7 @@ describe LeadsController do
|
|
978
978
|
FactoryGirl.create(:lead, first_name: "Bobby", user: current_user)
|
979
979
|
]
|
980
980
|
|
981
|
-
|
981
|
+
get :redraw, params: { per_page: 1, sort_by: "first_name" }, xhr: true
|
982
982
|
expect(assigns(:leads)).to eq([@leads.first])
|
983
983
|
expect(response).to render_template("leads/index")
|
984
984
|
end
|
@@ -991,7 +991,7 @@ describe LeadsController do
|
|
991
991
|
session[:leads_filter] = "contacted,rejected"
|
992
992
|
|
993
993
|
@leads = [FactoryGirl.create(:lead, user: current_user, status: "new")]
|
994
|
-
|
994
|
+
post :filter, params: { status: "new" }, xhr: true
|
995
995
|
expect(assigns[:leads]).to eq(@leads)
|
996
996
|
expect(response).to be_a_success
|
997
997
|
expect(response).to render_template("leads/index")
|
@@ -999,7 +999,7 @@ describe LeadsController do
|
|
999
999
|
|
1000
1000
|
it "should reset current page to 1" do
|
1001
1001
|
@leads = []
|
1002
|
-
|
1002
|
+
post :filter, params: { status: "new" }, xhr: true
|
1003
1003
|
|
1004
1004
|
expect(session[:leads_current_page]).to eq(1)
|
1005
1005
|
end
|