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
@@ -51,14 +51,14 @@ describe CampaignsController do
|
|
51
51
|
get :index
|
52
52
|
# Note: can't compare campaigns directly because of BigDecimal objects.
|
53
53
|
expect(assigns[:campaigns].size).to eq(2)
|
54
|
-
expect(assigns[:campaigns].map(&:status).sort).to eq(%w
|
54
|
+
expect(assigns[:campaigns].map(&:status).sort).to eq(%w[planned started])
|
55
55
|
end
|
56
56
|
|
57
57
|
it "should perform lookup using query string" do
|
58
58
|
@first = FactoryGirl.create(:campaign, user: current_user, name: "Hello, world!")
|
59
59
|
@second = FactoryGirl.create(:campaign, user: current_user, name: "Hello again")
|
60
60
|
|
61
|
-
get :index, query: "again"
|
61
|
+
get :index, params: { query: "again" }
|
62
62
|
expect(assigns[:campaigns]).to eq([@second])
|
63
63
|
expect(assigns[:current_query]).to eq("again")
|
64
64
|
expect(session[:campaigns_current_query]).to eq("again")
|
@@ -67,7 +67,7 @@ describe CampaignsController do
|
|
67
67
|
describe "AJAX pagination" do
|
68
68
|
it "should pick up page number from params" do
|
69
69
|
@campaigns = [FactoryGirl.create(:campaign, user: current_user)]
|
70
|
-
|
70
|
+
get :index, params: { page: 42 }, xhr: true
|
71
71
|
|
72
72
|
expect(assigns[:current_page].to_i).to eq(42)
|
73
73
|
expect(assigns[:campaigns]).to eq([]) # page #42 should be empty if there's only one campaign ;-)
|
@@ -78,7 +78,7 @@ describe CampaignsController do
|
|
78
78
|
it "should pick up saved page number from session" do
|
79
79
|
session[:campaigns_current_page] = 42
|
80
80
|
@campaigns = [FactoryGirl.create(:campaign, user: current_user)]
|
81
|
-
|
81
|
+
get :index, xhr: true
|
82
82
|
|
83
83
|
expect(assigns[:current_page]).to eq(42)
|
84
84
|
expect(assigns[:campaigns]).to eq([])
|
@@ -89,7 +89,7 @@ describe CampaignsController do
|
|
89
89
|
session[:campaigns_current_page] = 42
|
90
90
|
session[:campaigns_current_query] = "bill"
|
91
91
|
@campaigns = [FactoryGirl.create(:campaign, user: current_user)]
|
92
|
-
|
92
|
+
get :index, xhr: true
|
93
93
|
|
94
94
|
expect(assigns[:current_page]).to eq(1)
|
95
95
|
expect(assigns[:campaigns]).to eq(@campaigns)
|
@@ -132,7 +132,7 @@ describe CampaignsController do
|
|
132
132
|
end
|
133
133
|
|
134
134
|
it "should expose the requested campaign as @campaign and render [show] template" do
|
135
|
-
get :show, id: 42
|
135
|
+
get :show, params: { id: 42 }
|
136
136
|
expect(assigns[:campaign]).to eq(@campaign)
|
137
137
|
expect(assigns[:stage]).to eq(@stage)
|
138
138
|
expect(assigns[:comment].attributes).to eq(@comment.attributes)
|
@@ -140,7 +140,7 @@ describe CampaignsController do
|
|
140
140
|
end
|
141
141
|
|
142
142
|
it "should update an activity when viewing the campaign" do
|
143
|
-
get :show, id: @campaign.id
|
143
|
+
get :show, params: { id: @campaign.id }
|
144
144
|
expect(@campaign.versions.last.event).to eq('view')
|
145
145
|
end
|
146
146
|
end
|
@@ -152,7 +152,7 @@ describe CampaignsController do
|
|
152
152
|
expect(@campaign).to receive(:to_json).and_return("generated JSON")
|
153
153
|
|
154
154
|
request.env["HTTP_ACCEPT"] = "application/json"
|
155
|
-
get :show, id: 42
|
155
|
+
get :show, params: { id: 42 }
|
156
156
|
expect(response.body).to eq("generated JSON")
|
157
157
|
end
|
158
158
|
end
|
@@ -164,7 +164,7 @@ describe CampaignsController do
|
|
164
164
|
expect(@campaign).to receive(:to_xml).and_return("generated XML")
|
165
165
|
|
166
166
|
request.env["HTTP_ACCEPT"] = "application/xml"
|
167
|
-
get :show, id: 42
|
167
|
+
get :show, params: { id: 42 }
|
168
168
|
expect(response.body).to eq("generated XML")
|
169
169
|
end
|
170
170
|
end
|
@@ -174,7 +174,7 @@ describe CampaignsController do
|
|
174
174
|
@campaign = FactoryGirl.create(:campaign, user: current_user)
|
175
175
|
@campaign.destroy
|
176
176
|
|
177
|
-
get :show, id: @campaign.id
|
177
|
+
get :show, params: { id: @campaign.id }
|
178
178
|
expect(flash[:warning]).not_to eq(nil)
|
179
179
|
expect(response).to redirect_to(campaigns_path)
|
180
180
|
end
|
@@ -182,7 +182,7 @@ describe CampaignsController do
|
|
182
182
|
it "should redirect to campaign index if the campaign is protected" do
|
183
183
|
@campaign = FactoryGirl.create(:campaign, user: FactoryGirl.create(:user), access: "Private")
|
184
184
|
|
185
|
-
get :show, id: @campaign.id
|
185
|
+
get :show, params: { id: @campaign.id }
|
186
186
|
expect(flash[:warning]).not_to eq(nil)
|
187
187
|
expect(response).to redirect_to(campaigns_path)
|
188
188
|
end
|
@@ -192,7 +192,7 @@ describe CampaignsController do
|
|
192
192
|
@campaign.destroy
|
193
193
|
request.env["HTTP_ACCEPT"] = "application/json"
|
194
194
|
|
195
|
-
get :show, id: @campaign.id
|
195
|
+
get :show, params: { id: @campaign.id }
|
196
196
|
expect(response.code).to eq("404") # :not_found
|
197
197
|
end
|
198
198
|
|
@@ -201,7 +201,7 @@ describe CampaignsController do
|
|
201
201
|
@campaign.destroy
|
202
202
|
request.env["HTTP_ACCEPT"] = "application/xml"
|
203
203
|
|
204
|
-
get :show, id: @campaign.id
|
204
|
+
get :show, params: { id: @campaign.id }
|
205
205
|
expect(response.code).to eq("404") # :not_found
|
206
206
|
end
|
207
207
|
end
|
@@ -214,7 +214,7 @@ describe CampaignsController do
|
|
214
214
|
it "should expose a new campaign as @campaign" do
|
215
215
|
@campaign = Campaign.new(user: current_user,
|
216
216
|
access: Setting.default_access)
|
217
|
-
|
217
|
+
get :new, xhr: true
|
218
218
|
expect(assigns[:campaign].attributes).to eq(@campaign.attributes)
|
219
219
|
expect(response).to render_template("campaigns/new")
|
220
220
|
end
|
@@ -222,7 +222,7 @@ describe CampaignsController do
|
|
222
222
|
it "should create related object when necessary" do
|
223
223
|
@lead = FactoryGirl.create(:lead, id: 42)
|
224
224
|
|
225
|
-
|
225
|
+
get :new, params: { related: "lead_42" }, xhr: true
|
226
226
|
expect(assigns[:lead]).to eq(@lead)
|
227
227
|
end
|
228
228
|
end
|
@@ -233,7 +233,7 @@ describe CampaignsController do
|
|
233
233
|
it "should expose the requested campaign as @campaign and render [edit] template" do
|
234
234
|
@campaign = FactoryGirl.create(:campaign, id: 42, user: current_user)
|
235
235
|
|
236
|
-
|
236
|
+
get :edit, params: { id: 42 }, xhr: true
|
237
237
|
expect(assigns[:campaign]).to eq(@campaign)
|
238
238
|
expect(response).to render_template("campaigns/edit")
|
239
239
|
end
|
@@ -242,7 +242,7 @@ describe CampaignsController do
|
|
242
242
|
@campaign = FactoryGirl.create(:campaign, id: 42)
|
243
243
|
@previous = FactoryGirl.create(:campaign, id: 99)
|
244
244
|
|
245
|
-
|
245
|
+
get :edit, params: { id: 42, previous: 99 }, xhr: true
|
246
246
|
expect(assigns[:campaign]).to eq(@campaign)
|
247
247
|
expect(assigns[:previous]).to eq(@previous)
|
248
248
|
end
|
@@ -252,7 +252,7 @@ describe CampaignsController do
|
|
252
252
|
@campaign = FactoryGirl.create(:campaign, user: current_user)
|
253
253
|
@campaign.destroy
|
254
254
|
|
255
|
-
|
255
|
+
get :edit, params: { id: @campaign.id }, xhr: true
|
256
256
|
expect(flash[:warning]).not_to eq(nil)
|
257
257
|
expect(response.body).to eq("window.location.reload();")
|
258
258
|
end
|
@@ -260,7 +260,7 @@ describe CampaignsController do
|
|
260
260
|
it "should reload current page with the flash message if the campaign is protected" do
|
261
261
|
@private = FactoryGirl.create(:campaign, user: FactoryGirl.create(:user), access: "Private")
|
262
262
|
|
263
|
-
|
263
|
+
get :edit, params: { id: @private.id }, xhr: true
|
264
264
|
expect(flash[:warning]).not_to eq(nil)
|
265
265
|
expect(response.body).to eq("window.location.reload();")
|
266
266
|
end
|
@@ -275,7 +275,7 @@ describe CampaignsController do
|
|
275
275
|
it "should notify the view if previous campaign got deleted" do
|
276
276
|
@previous.destroy
|
277
277
|
|
278
|
-
|
278
|
+
get :edit, params: { id: @campaign.id, previous: @previous.id }, xhr: true
|
279
279
|
expect(flash[:warning]).to eq(nil) # no warning, just silently remove the div
|
280
280
|
expect(assigns[:previous]).to eq(@previous.id)
|
281
281
|
expect(response).to render_template("campaigns/edit")
|
@@ -284,7 +284,7 @@ describe CampaignsController do
|
|
284
284
|
it "should notify the view if previous campaign got protected" do
|
285
285
|
@previous.update_attribute(:access, "Private")
|
286
286
|
|
287
|
-
|
287
|
+
get :edit, params: { id: @campaign.id, previous: @previous.id }, xhr: true
|
288
288
|
expect(flash[:warning]).to eq(nil)
|
289
289
|
expect(assigns[:previous]).to eq(@previous.id)
|
290
290
|
expect(response).to render_template("campaigns/edit")
|
@@ -301,7 +301,7 @@ describe CampaignsController do
|
|
301
301
|
@campaign = FactoryGirl.build(:campaign, name: "Hello", user: current_user)
|
302
302
|
allow(Campaign).to receive(:new).and_return(@campaign)
|
303
303
|
|
304
|
-
|
304
|
+
post :create, params: { campaign: { name: "Hello" } }, xhr: true
|
305
305
|
expect(assigns(:campaign)).to eq(@campaign)
|
306
306
|
expect(response).to render_template("campaigns/create")
|
307
307
|
end
|
@@ -310,7 +310,7 @@ describe CampaignsController do
|
|
310
310
|
@campaign = FactoryGirl.build(:campaign, name: "Hello", user: current_user)
|
311
311
|
allow(Campaign).to receive(:new).and_return(@campaign)
|
312
312
|
|
313
|
-
|
313
|
+
post :create, params: { campaign: { name: "Hello" } }, xhr: true
|
314
314
|
expect(assigns[:campaign_status_total]).to be_instance_of(HashWithIndifferentAccess)
|
315
315
|
end
|
316
316
|
|
@@ -318,7 +318,7 @@ describe CampaignsController do
|
|
318
318
|
@campaign = FactoryGirl.build(:campaign, user: current_user)
|
319
319
|
allow(Campaign).to receive(:new).and_return(@campaign)
|
320
320
|
|
321
|
-
|
321
|
+
post :create, params: { campaign: { name: "Hello" } }, xhr: true
|
322
322
|
expect(assigns[:campaigns]).to eq([@campaign])
|
323
323
|
end
|
324
324
|
|
@@ -326,7 +326,7 @@ describe CampaignsController do
|
|
326
326
|
@campaign = FactoryGirl.build(:campaign, name: "Hello world", user: current_user)
|
327
327
|
allow(Campaign).to receive(:new).and_return(@campaign)
|
328
328
|
|
329
|
-
|
329
|
+
post :create, params: { campaign: { name: "Hello world" }, comment_body: "Awesome comment is awesome" }, xhr: true
|
330
330
|
expect(@campaign.reload.comments.map(&:comment)).to include("Awesome comment is awesome")
|
331
331
|
end
|
332
332
|
end
|
@@ -336,7 +336,7 @@ describe CampaignsController do
|
|
336
336
|
@campaign = FactoryGirl.build(:campaign, id: nil, name: nil, user: current_user)
|
337
337
|
allow(Campaign).to receive(:new).and_return(@campaign)
|
338
338
|
|
339
|
-
|
339
|
+
post :create, params: { campaign: {} }, xhr: true
|
340
340
|
expect(assigns(:campaign)).to eq(@campaign)
|
341
341
|
expect(response).to render_template("campaigns/create")
|
342
342
|
end
|
@@ -351,7 +351,7 @@ describe CampaignsController do
|
|
351
351
|
it "should update the requested campaign and render [update] template" do
|
352
352
|
@campaign = FactoryGirl.create(:campaign, id: 42, name: "Bye")
|
353
353
|
|
354
|
-
|
354
|
+
put :update, params: { id: 42, campaign: { name: "Hello" } }, xhr: true
|
355
355
|
expect(@campaign.reload.name).to eq("Hello")
|
356
356
|
expect(assigns(:campaign)).to eq(@campaign)
|
357
357
|
expect(response).to render_template("campaigns/update")
|
@@ -361,7 +361,7 @@ describe CampaignsController do
|
|
361
361
|
@campaign = FactoryGirl.create(:campaign, id: 42)
|
362
362
|
request.env["HTTP_REFERER"] = "http://localhost/campaigns"
|
363
363
|
|
364
|
-
|
364
|
+
put :update, params: { id: 42, campaign: { name: "Hello" } }, xhr: true
|
365
365
|
expect(assigns(:campaign)).to eq(@campaign)
|
366
366
|
expect(assigns[:campaign_status_total]).to be_instance_of(HashWithIndifferentAccess)
|
367
367
|
end
|
@@ -371,7 +371,7 @@ describe CampaignsController do
|
|
371
371
|
he = FactoryGirl.create(:user, id: 7)
|
372
372
|
she = FactoryGirl.create(:user, id: 8)
|
373
373
|
|
374
|
-
|
374
|
+
put :update, params: { id: 42, campaign: { name: "Hello", access: "Shared", user_ids: %w[7 8] } }, xhr: true
|
375
375
|
expect(assigns[:campaign].access).to eq("Shared")
|
376
376
|
expect(assigns[:campaign].user_ids.sort).to eq([he.id, she.id])
|
377
377
|
end
|
@@ -381,7 +381,7 @@ describe CampaignsController do
|
|
381
381
|
@campaign = FactoryGirl.create(:campaign, user: current_user)
|
382
382
|
@campaign.destroy
|
383
383
|
|
384
|
-
|
384
|
+
put :update, params: { id: @campaign.id }, xhr: true
|
385
385
|
expect(flash[:warning]).not_to eq(nil)
|
386
386
|
expect(response.body).to eq("window.location.reload();")
|
387
387
|
end
|
@@ -389,7 +389,7 @@ describe CampaignsController do
|
|
389
389
|
it "should reload current page with the flash message if the campaign is protected" do
|
390
390
|
@private = FactoryGirl.create(:campaign, user: FactoryGirl.create(:user), access: "Private")
|
391
391
|
|
392
|
-
|
392
|
+
put :update, params: { id: @private.id }, xhr: true
|
393
393
|
expect(flash[:warning]).not_to eq(nil)
|
394
394
|
expect(response.body).to eq("window.location.reload();")
|
395
395
|
end
|
@@ -400,7 +400,7 @@ describe CampaignsController do
|
|
400
400
|
it "should not update the requested campaign, but still expose it as @campaign and still render [update] template" do
|
401
401
|
@campaign = FactoryGirl.create(:campaign, id: 42, name: "Hello", user: current_user)
|
402
402
|
|
403
|
-
|
403
|
+
put :update, params: { id: 42, campaign: { name: nil } }, xhr: true
|
404
404
|
expect(@campaign.reload.name).to eq("Hello")
|
405
405
|
expect(assigns(:campaign)).to eq(@campaign)
|
406
406
|
expect(response).to render_template("campaigns/update")
|
@@ -419,7 +419,7 @@ describe CampaignsController do
|
|
419
419
|
describe "AJAX request" do
|
420
420
|
it "should destroy the requested campaign and render [destroy] template" do
|
421
421
|
@another_campaign = FactoryGirl.create(:campaign, user: current_user)
|
422
|
-
|
422
|
+
delete :destroy, params: { id: @campaign.id }, xhr: true
|
423
423
|
|
424
424
|
expect(assigns[:campaigns]).to eq([@another_campaign])
|
425
425
|
expect { Campaign.find(@campaign.id) }.to raise_error(ActiveRecord::RecordNotFound)
|
@@ -427,7 +427,7 @@ describe CampaignsController do
|
|
427
427
|
end
|
428
428
|
|
429
429
|
it "should get data for campaigns sidebar" do
|
430
|
-
|
430
|
+
delete :destroy, params: { id: @campaign.id }, xhr: true
|
431
431
|
|
432
432
|
expect(assigns[:campaign_status_total]).to be_instance_of(HashWithIndifferentAccess)
|
433
433
|
end
|
@@ -435,7 +435,7 @@ describe CampaignsController do
|
|
435
435
|
it "should try previous page and render index action if current page has no campaigns" do
|
436
436
|
session[:campaigns_current_page] = 42
|
437
437
|
|
438
|
-
|
438
|
+
delete :destroy, params: { id: @campaign.id }, xhr: true
|
439
439
|
expect(session[:campaigns_current_page]).to eq(41)
|
440
440
|
expect(response).to render_template("campaigns/index")
|
441
441
|
end
|
@@ -443,7 +443,7 @@ describe CampaignsController do
|
|
443
443
|
it "should render index action when deleting last campaign" do
|
444
444
|
session[:campaigns_current_page] = 1
|
445
445
|
|
446
|
-
|
446
|
+
delete :destroy, params: { id: @campaign.id }, xhr: true
|
447
447
|
expect(session[:campaigns_current_page]).to eq(1)
|
448
448
|
expect(response).to render_template("campaigns/index")
|
449
449
|
end
|
@@ -453,7 +453,7 @@ describe CampaignsController do
|
|
453
453
|
@campaign = FactoryGirl.create(:campaign, user: current_user)
|
454
454
|
@campaign.destroy
|
455
455
|
|
456
|
-
|
456
|
+
delete :destroy, params: { id: @campaign.id }, xhr: true
|
457
457
|
expect(flash[:warning]).not_to eq(nil)
|
458
458
|
expect(response.body).to eq("window.location.reload();")
|
459
459
|
end
|
@@ -461,7 +461,7 @@ describe CampaignsController do
|
|
461
461
|
it "should reload current page with the flash message if the campaign is protected" do
|
462
462
|
@private = FactoryGirl.create(:campaign, user: FactoryGirl.create(:user), access: "Private")
|
463
463
|
|
464
|
-
|
464
|
+
delete :destroy, params: { id: @private.id }, xhr: true
|
465
465
|
expect(flash[:warning]).not_to eq(nil)
|
466
466
|
expect(response.body).to eq("window.location.reload();")
|
467
467
|
end
|
@@ -470,7 +470,7 @@ describe CampaignsController do
|
|
470
470
|
|
471
471
|
describe "HTML request" do
|
472
472
|
it "should redirect to Campaigns index when a campaign gets deleted from its landing page" do
|
473
|
-
delete :destroy, id: @campaign.id
|
473
|
+
delete :destroy, params: { id: @campaign.id }
|
474
474
|
|
475
475
|
expect(flash[:notice]).not_to eq(nil)
|
476
476
|
expect(response).to redirect_to(campaigns_path)
|
@@ -480,7 +480,7 @@ describe CampaignsController do
|
|
480
480
|
@campaign = FactoryGirl.create(:campaign, user: current_user)
|
481
481
|
@campaign.destroy
|
482
482
|
|
483
|
-
delete :destroy, id: @campaign.id
|
483
|
+
delete :destroy, params: { id: @campaign.id }
|
484
484
|
expect(flash[:warning]).not_to eq(nil)
|
485
485
|
expect(response).to redirect_to(campaigns_path)
|
486
486
|
end
|
@@ -488,7 +488,7 @@ describe CampaignsController do
|
|
488
488
|
it "should redirect to campaign index with the flash message if the campaign is protected" do
|
489
489
|
@private = FactoryGirl.create(:campaign, user: FactoryGirl.create(:user), access: "Private")
|
490
490
|
|
491
|
-
delete :destroy, id: @private.id
|
491
|
+
delete :destroy, params: { id: @private.id }
|
492
492
|
expect(flash[:warning]).not_to eq(nil)
|
493
493
|
expect(response).to redirect_to(campaigns_path)
|
494
494
|
end
|
@@ -598,14 +598,14 @@ describe CampaignsController do
|
|
598
598
|
#----------------------------------------------------------------------------
|
599
599
|
describe "responding to GET redraw" do
|
600
600
|
it "should save user selected campaign preference" do
|
601
|
-
|
601
|
+
get :redraw, params: { per_page: 42, view: "brief", sort_by: "name" }, xhr: true
|
602
602
|
expect(current_user.preference[:campaigns_per_page]).to eq("42")
|
603
603
|
expect(current_user.preference[:campaigns_index_view]).to eq("brief")
|
604
604
|
expect(current_user.preference[:campaigns_sort_by]).to eq("campaigns.name ASC")
|
605
605
|
end
|
606
606
|
|
607
607
|
it "should reset current page to 1" do
|
608
|
-
|
608
|
+
get :redraw, params: { per_page: 42, view: "brief", sort_by: "name" }, xhr: true
|
609
609
|
expect(session[:campaigns_current_page]).to eq(1)
|
610
610
|
end
|
611
611
|
|
@@ -615,7 +615,7 @@ describe CampaignsController do
|
|
615
615
|
FactoryGirl.create(:campaign, name: "B", user: current_user)
|
616
616
|
]
|
617
617
|
|
618
|
-
|
618
|
+
get :redraw, params: { per_page: 1, sort_by: "name" }, xhr: true
|
619
619
|
expect(assigns(:campaigns)).to eq([@campaigns.first])
|
620
620
|
expect(response).to render_template("campaigns/index")
|
621
621
|
end
|
@@ -628,14 +628,14 @@ describe CampaignsController do
|
|
628
628
|
session[:campaigns_filter] = "planned,started"
|
629
629
|
@campaigns = [FactoryGirl.create(:campaign, status: "completed", user: current_user)]
|
630
630
|
|
631
|
-
|
631
|
+
post :filter, params: { status: "completed" }, xhr: true
|
632
632
|
expect(assigns(:campaigns)).to eq(@campaigns)
|
633
633
|
expect(response).to render_template("campaigns/index")
|
634
634
|
end
|
635
635
|
|
636
636
|
it "should reset current page to 1" do
|
637
637
|
@campaigns = []
|
638
|
-
|
638
|
+
post :filter, params: { status: "completed" }, xhr: true
|
639
639
|
|
640
640
|
expect(session[:campaigns_current_page]).to eq(1)
|
641
641
|
end
|
@@ -27,7 +27,7 @@ describe ContactsController do
|
|
27
27
|
@billy_bones = FactoryGirl.create(:contact, user: current_user, first_name: "Billy", last_name: "Bones")
|
28
28
|
@captain_flint = FactoryGirl.create(:contact, user: current_user, first_name: "Captain", last_name: "Flint")
|
29
29
|
|
30
|
-
get :index, query: @billy_bones.email
|
30
|
+
get :index, params: { query: @billy_bones.email }
|
31
31
|
expect(assigns[:contacts]).to eq([@billy_bones])
|
32
32
|
expect(assigns[:current_query]).to eq(@billy_bones.email)
|
33
33
|
expect(session[:contacts_current_query]).to eq(@billy_bones.email)
|
@@ -36,7 +36,7 @@ describe ContactsController do
|
|
36
36
|
describe "AJAX pagination" do
|
37
37
|
it "should pick up page number from params" do
|
38
38
|
@contacts = [FactoryGirl.create(:contact, user: current_user)]
|
39
|
-
|
39
|
+
get :index, params: { page: 42 }, xhr: true
|
40
40
|
|
41
41
|
expect(assigns[:current_page].to_i).to eq(42)
|
42
42
|
expect(assigns[:contacts]).to eq([]) # page #42 should be empty if there's only one contact ;-)
|
@@ -47,7 +47,7 @@ describe ContactsController do
|
|
47
47
|
it "should pick up saved page number from session" do
|
48
48
|
session[:contacts_current_page] = 42
|
49
49
|
@contacts = [FactoryGirl.create(:contact, user: current_user)]
|
50
|
-
|
50
|
+
get :index, xhr: true
|
51
51
|
|
52
52
|
expect(assigns[:current_page]).to eq(42)
|
53
53
|
expect(assigns[:contacts]).to eq([])
|
@@ -58,7 +58,7 @@ describe ContactsController do
|
|
58
58
|
session[:contacts_current_page] = 42
|
59
59
|
session[:contacts_current_query] = "bill"
|
60
60
|
@contacts = [FactoryGirl.create(:contact, user: current_user)]
|
61
|
-
|
61
|
+
get :index, xhr: true
|
62
62
|
|
63
63
|
expect(assigns[:current_page]).to eq(1)
|
64
64
|
expect(assigns[:contacts]).to eq(@contacts)
|
@@ -101,7 +101,7 @@ describe ContactsController do
|
|
101
101
|
end
|
102
102
|
|
103
103
|
it "should expose the requested contact as @contact" do
|
104
|
-
get :show, id: 42
|
104
|
+
get :show, params: { id: 42 }
|
105
105
|
expect(assigns[:contact]).to eq(@contact)
|
106
106
|
expect(assigns[:stage]).to eq(@stage)
|
107
107
|
expect(assigns[:comment].attributes).to eq(@comment.attributes)
|
@@ -109,7 +109,7 @@ describe ContactsController do
|
|
109
109
|
end
|
110
110
|
|
111
111
|
it "should update an activity when viewing the contact" do
|
112
|
-
get :show, id: @contact.id
|
112
|
+
get :show, params: { id: @contact.id }
|
113
113
|
expect(@contact.versions.last.event).to eq('view')
|
114
114
|
end
|
115
115
|
end
|
@@ -121,7 +121,7 @@ describe ContactsController do
|
|
121
121
|
expect(@contact).to receive(:to_json).and_return("generated JSON")
|
122
122
|
|
123
123
|
request.env["HTTP_ACCEPT"] = "application/json"
|
124
|
-
get :show, id: 42
|
124
|
+
get :show, params: { id: 42 }
|
125
125
|
expect(response.body).to eq("generated JSON")
|
126
126
|
end
|
127
127
|
end
|
@@ -133,7 +133,7 @@ describe ContactsController do
|
|
133
133
|
expect(@contact).to receive(:to_xml).and_return("generated XML")
|
134
134
|
|
135
135
|
request.env["HTTP_ACCEPT"] = "application/xml"
|
136
|
-
get :show, id: 42
|
136
|
+
get :show, params: { id: 42 }
|
137
137
|
expect(response.body).to eq("generated XML")
|
138
138
|
end
|
139
139
|
end
|
@@ -143,7 +143,7 @@ describe ContactsController do
|
|
143
143
|
@contact = FactoryGirl.create(:contact, user: current_user)
|
144
144
|
@contact.destroy
|
145
145
|
|
146
|
-
get :show, id: @contact.id
|
146
|
+
get :show, params: { id: @contact.id }
|
147
147
|
expect(flash[:warning]).not_to eq(nil)
|
148
148
|
expect(response).to redirect_to(contacts_path)
|
149
149
|
end
|
@@ -151,7 +151,7 @@ describe ContactsController do
|
|
151
151
|
it "should redirect to contact index if the contact is protected" do
|
152
152
|
@private = FactoryGirl.create(:contact, user: FactoryGirl.create(:user), access: "Private")
|
153
153
|
|
154
|
-
get :show, id: @private.id
|
154
|
+
get :show, params: { id: @private.id }
|
155
155
|
expect(flash[:warning]).not_to eq(nil)
|
156
156
|
expect(response).to redirect_to(contacts_path)
|
157
157
|
end
|
@@ -161,7 +161,7 @@ describe ContactsController do
|
|
161
161
|
@contact.destroy
|
162
162
|
request.env["HTTP_ACCEPT"] = "application/xml"
|
163
163
|
|
164
|
-
get :show, id: @contact.id
|
164
|
+
get :show, params: { id: @contact.id }
|
165
165
|
expect(response.code).to eq("404") # :not_found
|
166
166
|
end
|
167
167
|
end
|
@@ -177,7 +177,7 @@ describe ContactsController do
|
|
177
177
|
@account = Account.new(user: current_user)
|
178
178
|
@accounts = [FactoryGirl.create(:account, user: current_user)]
|
179
179
|
|
180
|
-
|
180
|
+
get :new, xhr: true
|
181
181
|
expect(assigns[:contact].attributes).to eq(@contact.attributes)
|
182
182
|
expect(assigns[:account].attributes).to eq(@account.attributes)
|
183
183
|
expect(assigns[:accounts]).to eq(@accounts)
|
@@ -188,7 +188,7 @@ describe ContactsController do
|
|
188
188
|
it "should created an instance of related object when necessary" do
|
189
189
|
@opportunity = FactoryGirl.create(:opportunity)
|
190
190
|
|
191
|
-
|
191
|
+
get :new, params: { related: "opportunity_#{@opportunity.id}" }, xhr: true
|
192
192
|
expect(assigns[:opportunity]).to eq(@opportunity)
|
193
193
|
end
|
194
194
|
|
@@ -197,7 +197,7 @@ describe ContactsController do
|
|
197
197
|
@account = FactoryGirl.create(:account)
|
198
198
|
@account.destroy
|
199
199
|
|
200
|
-
|
200
|
+
get :new, params: { related: "account_#{@account.id}" }, xhr: true
|
201
201
|
expect(flash[:warning]).not_to eq(nil)
|
202
202
|
expect(response.body).to eq('window.location.href = "/accounts";')
|
203
203
|
end
|
@@ -205,7 +205,7 @@ describe ContactsController do
|
|
205
205
|
it "should redirect to parent asset's index page with the message if parent asset got protected" do
|
206
206
|
@account = FactoryGirl.create(:account, access: "Private")
|
207
207
|
|
208
|
-
|
208
|
+
get :new, params: { related: "account_#{@account.id}" }, xhr: true
|
209
209
|
expect(flash[:warning]).not_to eq(nil)
|
210
210
|
expect(response.body).to eq('window.location.href = "/accounts";')
|
211
211
|
end
|
@@ -221,12 +221,12 @@ describe ContactsController do
|
|
221
221
|
end
|
222
222
|
|
223
223
|
it "should return with an existing tag name" do
|
224
|
-
|
224
|
+
get :field_group, params: { tag: @tag.name }, xhr: true
|
225
225
|
assigns[:tag].name == @tag.name
|
226
226
|
end
|
227
227
|
|
228
228
|
it "should have the same count of tags" do
|
229
|
-
|
229
|
+
get :field_group, params: { tag: @tag.name }, xhr: true
|
230
230
|
expect(Tag.count).to equal(1)
|
231
231
|
end
|
232
232
|
end
|
@@ -234,13 +234,13 @@ describe ContactsController do
|
|
234
234
|
context "without an existing tag" do
|
235
235
|
it "should not find a tag" do
|
236
236
|
tag_name = "New-Tag"
|
237
|
-
|
237
|
+
get :field_group, params: { tag: tag_name }, xhr: true
|
238
238
|
expect(assigns[:tag]).to eql(nil)
|
239
239
|
end
|
240
240
|
|
241
241
|
it "should have the same count of tags" do
|
242
242
|
tag_name = "New-Tag-1"
|
243
|
-
|
243
|
+
get :field_group, params: { tag: tag_name }, xhr: true
|
244
244
|
expect(Tag.count).to equal(0)
|
245
245
|
end
|
246
246
|
end
|
@@ -253,7 +253,7 @@ describe ContactsController do
|
|
253
253
|
@contact = FactoryGirl.create(:contact, id: 42, user: current_user, lead: nil)
|
254
254
|
@account = Account.new(user: current_user)
|
255
255
|
|
256
|
-
|
256
|
+
get :edit, params: { id: 42 }, xhr: true
|
257
257
|
expect(assigns[:contact]).to eq(@contact)
|
258
258
|
expect(assigns[:account].attributes).to eq(@account.attributes)
|
259
259
|
expect(assigns[:previous]).to eq(nil)
|
@@ -265,7 +265,7 @@ describe ContactsController do
|
|
265
265
|
@contact = FactoryGirl.create(:contact, id: 42, user: current_user, lead: nil)
|
266
266
|
FactoryGirl.create(:account_contact, account: @account, contact: @contact)
|
267
267
|
|
268
|
-
|
268
|
+
get :edit, params: { id: 42 }, xhr: true
|
269
269
|
expect(assigns[:contact]).to eq(@contact)
|
270
270
|
expect(assigns[:account]).to eq(@account)
|
271
271
|
end
|
@@ -274,7 +274,7 @@ describe ContactsController do
|
|
274
274
|
@contact = FactoryGirl.create(:contact, id: 42)
|
275
275
|
@previous = FactoryGirl.create(:contact, id: 1992)
|
276
276
|
|
277
|
-
|
277
|
+
get :edit, params: { id: 42, previous: 1992 }, xhr: true
|
278
278
|
expect(assigns[:previous]).to eq(@previous)
|
279
279
|
end
|
280
280
|
|
@@ -283,7 +283,7 @@ describe ContactsController do
|
|
283
283
|
@contact = FactoryGirl.create(:contact, user: current_user)
|
284
284
|
@contact.destroy
|
285
285
|
|
286
|
-
|
286
|
+
get :edit, params: { id: @contact.id }, xhr: true
|
287
287
|
expect(flash[:warning]).not_to eq(nil)
|
288
288
|
expect(response.body).to eq("window.location.reload();")
|
289
289
|
end
|
@@ -291,7 +291,7 @@ describe ContactsController do
|
|
291
291
|
it "should reload current page with the flash message if the contact is protected" do
|
292
292
|
@private = FactoryGirl.create(:contact, user: FactoryGirl.create(:user), access: "Private")
|
293
293
|
|
294
|
-
|
294
|
+
get :edit, params: { id: @private.id }, xhr: true
|
295
295
|
expect(flash[:warning]).not_to eq(nil)
|
296
296
|
expect(response.body).to eq("window.location.reload();")
|
297
297
|
end
|
@@ -306,7 +306,7 @@ describe ContactsController do
|
|
306
306
|
it "should notify the view if previous contact got deleted" do
|
307
307
|
@previous.destroy
|
308
308
|
|
309
|
-
|
309
|
+
get :edit, params: { id: @contact.id, previous: @previous.id }, xhr: true
|
310
310
|
expect(flash[:warning]).to eq(nil)
|
311
311
|
expect(assigns[:previous]).to eq(@previous.id)
|
312
312
|
expect(response).to render_template("contacts/edit")
|
@@ -315,7 +315,7 @@ describe ContactsController do
|
|
315
315
|
it "should notify the view if previous contact got protected" do
|
316
316
|
@previous.update_attribute(:access, "Private")
|
317
317
|
|
318
|
-
|
318
|
+
get :edit, params: { id: @contact.id, previous: @previous.id }, xhr: true
|
319
319
|
expect(flash[:warning]).to eq(nil)
|
320
320
|
expect(assigns[:previous]).to eq(@previous.id)
|
321
321
|
expect(response).to render_template("contacts/edit")
|
@@ -332,7 +332,7 @@ describe ContactsController do
|
|
332
332
|
@contact = FactoryGirl.build(:contact, first_name: "Billy", last_name: "Bones")
|
333
333
|
allow(Contact).to receive(:new).and_return(@contact)
|
334
334
|
|
335
|
-
|
335
|
+
post :create, params: { contact: { first_name: "Billy", last_name: "Bones" }, account: { name: "Hello world" } }, xhr: true
|
336
336
|
expect(assigns(:contact)).to eq(@contact)
|
337
337
|
expect(assigns(:contact).reload.account.name).to eq("Hello world")
|
338
338
|
expect(response).to render_template("contacts/create")
|
@@ -343,7 +343,7 @@ describe ContactsController do
|
|
343
343
|
@contact = FactoryGirl.build(:contact)
|
344
344
|
allow(Contact).to receive(:new).and_return(@contact)
|
345
345
|
|
346
|
-
|
346
|
+
post :create, params: { contact: { first_name: "Billy" }, account: {}, opportunity: 987 }, xhr: true
|
347
347
|
expect(assigns(:contact).opportunities).to include(@opportunity)
|
348
348
|
expect(response).to render_template("contacts/create")
|
349
349
|
end
|
@@ -353,7 +353,7 @@ describe ContactsController do
|
|
353
353
|
allow(Contact).to receive(:new).and_return(@contact)
|
354
354
|
|
355
355
|
request.env["HTTP_REFERER"] = "http://localhost/contacts"
|
356
|
-
|
356
|
+
post :create, params: { contact: { first_name: "Billy", last_name: "Bones" }, account: {} }, xhr: true
|
357
357
|
expect(assigns[:contacts]).to eq([@contact])
|
358
358
|
end
|
359
359
|
|
@@ -361,7 +361,7 @@ describe ContactsController do
|
|
361
361
|
@contact = FactoryGirl.build(:contact, user: current_user)
|
362
362
|
allow(Contact).to receive(:new).and_return(@contact)
|
363
363
|
|
364
|
-
|
364
|
+
post :create, params: { contact: { first_name: "Testy", last_name: "McTest" }, account: { name: "Hello world" }, comment_body: "Awesome comment is awesome" }, xhr: true
|
365
365
|
expect(assigns[:contact].comments.map(&:comment)).to include("Awesome comment is awesome")
|
366
366
|
end
|
367
367
|
end
|
@@ -377,7 +377,7 @@ describe ContactsController do
|
|
377
377
|
@account = FactoryGirl.create(:account, id: 42, user: current_user)
|
378
378
|
|
379
379
|
# This redraws [create] form with blank account.
|
380
|
-
|
380
|
+
post :create, params: { contact: {}, account: { id: 42, user_id: current_user.id } }, xhr: true
|
381
381
|
expect(assigns(:contact)).to eq(@contact)
|
382
382
|
expect(assigns(:account)).to eq(@account)
|
383
383
|
expect(assigns(:accounts)).to eq([@account])
|
@@ -389,7 +389,7 @@ describe ContactsController do
|
|
389
389
|
@account = FactoryGirl.create(:account, id: 123, user: current_user)
|
390
390
|
|
391
391
|
request.env["HTTP_REFERER"] = "http://localhost/accounts/123"
|
392
|
-
|
392
|
+
post :create, params: { contact: { first_name: nil }, account: { name: nil, user_id: current_user.id } }, xhr: true
|
393
393
|
expect(assigns(:contact)).to eq(@contact)
|
394
394
|
expect(assigns(:account)).to eq(@account)
|
395
395
|
expect(assigns(:accounts)).to eq([@account])
|
@@ -400,7 +400,7 @@ describe ContactsController do
|
|
400
400
|
@accounts = [FactoryGirl.create(:account, user: current_user)]
|
401
401
|
@account = Account.new(user: current_user)
|
402
402
|
|
403
|
-
|
403
|
+
post :create, params: { contact: { first_name: nil }, account: { name: nil, user_id: current_user.id } }, xhr: true
|
404
404
|
expect(assigns(:contact)).to eq(@contact)
|
405
405
|
expect(assigns(:account).attributes).to eq(@account.attributes)
|
406
406
|
expect(assigns(:accounts)).to eq(@accounts)
|
@@ -410,7 +410,7 @@ describe ContactsController do
|
|
410
410
|
it "should preserve Opportunity when called from Oppotuunity page" do
|
411
411
|
@opportunity = FactoryGirl.create(:opportunity, id: 987)
|
412
412
|
|
413
|
-
|
413
|
+
post :create, params: { contact: {}, account: {}, opportunity: 987 }, xhr: true
|
414
414
|
expect(assigns(:opportunity)).to eq(@opportunity)
|
415
415
|
expect(response).to render_template("contacts/create")
|
416
416
|
end
|
@@ -425,7 +425,7 @@ describe ContactsController do
|
|
425
425
|
it "should update the requested contact and render [update] template" do
|
426
426
|
@contact = FactoryGirl.create(:contact, id: 42, first_name: "Billy")
|
427
427
|
|
428
|
-
|
428
|
+
put :update, params: { id: 42, contact: { first_name: "Bones" }, account: {} }, xhr: true
|
429
429
|
expect(assigns[:contact].first_name).to eq("Bones")
|
430
430
|
expect(assigns[:contact]).to eq(@contact)
|
431
431
|
expect(response).to render_template("contacts/update")
|
@@ -434,7 +434,7 @@ describe ContactsController do
|
|
434
434
|
it "should be able to create a new account and link it to the contact" do
|
435
435
|
@contact = FactoryGirl.create(:contact, id: 42, first_name: "Billy")
|
436
436
|
|
437
|
-
|
437
|
+
put :update, params: { id: 42, contact: { first_name: "Bones" }, account: { name: "new account" } }, xhr: true
|
438
438
|
expect(assigns[:contact].first_name).to eq("Bones")
|
439
439
|
expect(assigns[:contact].account.name).to eq("new account")
|
440
440
|
end
|
@@ -443,7 +443,7 @@ describe ContactsController do
|
|
443
443
|
@account = FactoryGirl.create(:account, id: 99, name: "Hello world")
|
444
444
|
@contact = FactoryGirl.create(:contact, id: 42, first_name: "Billy")
|
445
445
|
|
446
|
-
|
446
|
+
put :update, params: { id: 42, contact: { first_name: "Bones" }, account: { id: 99 } }, xhr: true
|
447
447
|
expect(assigns[:contact].first_name).to eq("Bones")
|
448
448
|
expect(assigns[:contact].account.id).to eq(99)
|
449
449
|
end
|
@@ -451,7 +451,7 @@ describe ContactsController do
|
|
451
451
|
it "should update contact permissions when sharing with specific users" do
|
452
452
|
@contact = FactoryGirl.create(:contact, id: 42, access: "Public")
|
453
453
|
|
454
|
-
|
454
|
+
put :update, params: { id: 42, contact: { first_name: "Hello", access: "Shared", user_ids: [7, 8] }, account: {} }, xhr: true
|
455
455
|
expect(assigns[:contact].access).to eq("Shared")
|
456
456
|
expect(assigns[:contact].user_ids.sort).to eq([7, 8])
|
457
457
|
expect(assigns[:contact]).to eq(@contact)
|
@@ -462,7 +462,7 @@ describe ContactsController do
|
|
462
462
|
@contact = FactoryGirl.create(:contact, user: current_user)
|
463
463
|
@contact.destroy
|
464
464
|
|
465
|
-
|
465
|
+
put :update, params: { id: @contact.id }, xhr: true
|
466
466
|
expect(flash[:warning]).not_to eq(nil)
|
467
467
|
expect(response.body).to eq("window.location.reload();")
|
468
468
|
end
|
@@ -470,7 +470,7 @@ describe ContactsController do
|
|
470
470
|
it "should reload current page with the flash message if the contact is protected" do
|
471
471
|
@private = FactoryGirl.create(:contact, user: FactoryGirl.create(:user), access: "Private")
|
472
472
|
|
473
|
-
|
473
|
+
put :update, params: { id: @private.id }, xhr: true
|
474
474
|
expect(flash[:warning]).not_to eq(nil)
|
475
475
|
expect(response.body).to eq("window.location.reload();")
|
476
476
|
end
|
@@ -481,7 +481,7 @@ describe ContactsController do
|
|
481
481
|
it "should not update the contact, but still expose it as @contact and render [update] template" do
|
482
482
|
@contact = FactoryGirl.create(:contact, id: 42, user: current_user, first_name: "Billy", lead: nil)
|
483
483
|
|
484
|
-
|
484
|
+
put :update, params: { id: 42, contact: { first_name: nil }, account: {} }, xhr: true
|
485
485
|
expect(assigns[:contact].reload.first_name).to eq("Billy")
|
486
486
|
expect(assigns[:contact]).to eq(@contact)
|
487
487
|
expect(response).to render_template("contacts/update")
|
@@ -491,7 +491,7 @@ describe ContactsController do
|
|
491
491
|
@account = FactoryGirl.create(:account, id: 99)
|
492
492
|
@contact = FactoryGirl.create(:contact, id: 42, account: @account)
|
493
493
|
|
494
|
-
|
494
|
+
put :update, params: { id: 42, contact: { first_name: nil }, account: { id: 99 } }, xhr: true
|
495
495
|
expect(assigns[:account]).to eq(@account)
|
496
496
|
end
|
497
497
|
end
|
@@ -507,7 +507,7 @@ describe ContactsController do
|
|
507
507
|
|
508
508
|
describe "AJAX request" do
|
509
509
|
it "should destroy the requested contact and render [destroy] template" do
|
510
|
-
|
510
|
+
delete :destroy, params: { id: @contact.id }, xhr: true
|
511
511
|
|
512
512
|
expect { Contact.find(@contact.id) }.to raise_error(ActiveRecord::RecordNotFound)
|
513
513
|
expect(response).to render_template("contacts/destroy")
|
@@ -520,7 +520,7 @@ describe ContactsController do
|
|
520
520
|
|
521
521
|
it "should try previous page and render index action if current page has no contacts" do
|
522
522
|
session[:contacts_current_page] = 42
|
523
|
-
|
523
|
+
delete :destroy, params: { id: @contact.id }, xhr: true
|
524
524
|
|
525
525
|
expect(session[:contacts_current_page]).to eq(41)
|
526
526
|
expect(response).to render_template("contacts/index")
|
@@ -528,7 +528,7 @@ describe ContactsController do
|
|
528
528
|
|
529
529
|
it "should render index action when deleting last contact" do
|
530
530
|
session[:contacts_current_page] = 1
|
531
|
-
|
531
|
+
delete :destroy, params: { id: @contact.id }, xhr: true
|
532
532
|
|
533
533
|
expect(session[:contacts_current_page]).to eq(1)
|
534
534
|
expect(response).to render_template("contacts/index")
|
@@ -538,7 +538,7 @@ describe ContactsController do
|
|
538
538
|
describe "when called from related asset page page" do
|
539
539
|
it "should reset current page to 1" do
|
540
540
|
request.env["HTTP_REFERER"] = "http://localhost/accounts/123"
|
541
|
-
|
541
|
+
delete :destroy, params: { id: @contact.id }, xhr: true
|
542
542
|
|
543
543
|
expect(session[:contacts_current_page]).to eq(1)
|
544
544
|
expect(response).to render_template("contacts/destroy")
|
@@ -550,7 +550,7 @@ describe ContactsController do
|
|
550
550
|
@contact = FactoryGirl.create(:contact, user: current_user)
|
551
551
|
@contact.destroy
|
552
552
|
|
553
|
-
|
553
|
+
delete :destroy, params: { id: @contact.id }, xhr: true
|
554
554
|
expect(flash[:warning]).not_to eq(nil)
|
555
555
|
expect(response.body).to eq("window.location.reload();")
|
556
556
|
end
|
@@ -558,7 +558,7 @@ describe ContactsController do
|
|
558
558
|
it "should reload current page with the flash message if the contact is protected" do
|
559
559
|
@private = FactoryGirl.create(:contact, user: FactoryGirl.create(:user), access: "Private")
|
560
560
|
|
561
|
-
|
561
|
+
delete :destroy, params: { id: @private.id }, xhr: true
|
562
562
|
expect(flash[:warning]).not_to eq(nil)
|
563
563
|
expect(response.body).to eq("window.location.reload();")
|
564
564
|
end
|
@@ -567,7 +567,7 @@ describe ContactsController do
|
|
567
567
|
|
568
568
|
describe "HTML request" do
|
569
569
|
it "should redirect to Contacts index when a contact gets deleted from its landing page" do
|
570
|
-
delete :destroy, id: @contact.id
|
570
|
+
delete :destroy, params: { id: @contact.id }
|
571
571
|
|
572
572
|
expect(flash[:notice]).not_to eq(nil)
|
573
573
|
expect(response).to redirect_to(contacts_path)
|
@@ -577,7 +577,7 @@ describe ContactsController do
|
|
577
577
|
@contact = FactoryGirl.create(:contact, user: current_user)
|
578
578
|
@contact.destroy
|
579
579
|
|
580
|
-
delete :destroy, id: @contact.id
|
580
|
+
delete :destroy, params: { id: @contact.id }
|
581
581
|
expect(flash[:warning]).not_to eq(nil)
|
582
582
|
expect(response).to redirect_to(contacts_path)
|
583
583
|
end
|
@@ -585,7 +585,7 @@ describe ContactsController do
|
|
585
585
|
it "should redirect to contact index with the flash message if the contact is protected" do
|
586
586
|
@private = FactoryGirl.create(:contact, user: FactoryGirl.create(:user), access: "Private")
|
587
587
|
|
588
|
-
delete :destroy, id: @private.id
|
588
|
+
delete :destroy, params: { id: @private.id }
|
589
589
|
expect(flash[:warning]).not_to eq(nil)
|
590
590
|
expect(response).to redirect_to(contacts_path)
|
591
591
|
end
|
@@ -670,7 +670,7 @@ describe ContactsController do
|
|
670
670
|
#----------------------------------------------------------------------------
|
671
671
|
describe "responding to POST redraw" do
|
672
672
|
it "should save user selected contact preference" do
|
673
|
-
|
673
|
+
get :redraw, params: { per_page: 42, view: "long", sort_by: "first_name", naming: "after" }, xhr: true
|
674
674
|
expect(current_user.preference[:contacts_per_page].to_i).to eq(42)
|
675
675
|
expect(current_user.preference[:contacts_index_view]).to eq("long")
|
676
676
|
expect(current_user.preference[:contacts_sort_by]).to eq("contacts.first_name ASC")
|
@@ -678,13 +678,13 @@ describe ContactsController do
|
|
678
678
|
end
|
679
679
|
|
680
680
|
it "should set similar options for Leads" do
|
681
|
-
|
681
|
+
get :redraw, params: { sort_by: "first_name", naming: "after" }, xhr: true
|
682
682
|
expect(current_user.pref[:leads_sort_by]).to eq("leads.first_name ASC")
|
683
683
|
expect(current_user.pref[:leads_naming]).to eq("after")
|
684
684
|
end
|
685
685
|
|
686
686
|
it "should reset current page to 1" do
|
687
|
-
|
687
|
+
get :redraw, params: { per_page: 42, view: "long", sort_by: "first_name", naming: "after" }, xhr: true
|
688
688
|
expect(session[:contacts_current_page]).to eq(1)
|
689
689
|
end
|
690
690
|
|
@@ -694,7 +694,7 @@ describe ContactsController do
|
|
694
694
|
FactoryGirl.create(:contact, first_name: "Bobby", user: current_user)
|
695
695
|
]
|
696
696
|
|
697
|
-
|
697
|
+
get :redraw, params: { per_page: 1, sort_by: "first_name" }, xhr: true
|
698
698
|
expect(assigns(:contacts)).to eq([@contacts.first])
|
699
699
|
expect(response).to render_template("contacts/index")
|
700
700
|
end
|