fat_free_crm 0.17.3 → 0.19.2
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of fat_free_crm might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/.rubocop.yml +1 -1
- data/.rubocop_todo.yml +71 -148
- data/.travis.yml +35 -14
- data/CHANGELOG.md +92 -6
- data/CONTRIBUTORS.md +96 -53
- data/Dockerfile +45 -14
- data/Gemfile +23 -13
- data/Gemfile.lock +256 -248
- data/Procfile +1 -1
- data/README.md +9 -6
- data/Rakefile +1 -1
- data/app/assets/javascripts/crm.js.coffee +3 -3
- data/app/assets/javascripts/crm_select2.js.coffee +15 -14
- data/app/assets/stylesheets/common.scss +1 -1
- data/app/controllers/admin/application_controller.rb +1 -1
- data/app/controllers/admin/field_groups_controller.rb +9 -4
- data/app/controllers/admin/fields_controller.rb +4 -4
- data/app/controllers/admin/groups_controller.rb +1 -1
- data/app/controllers/admin/tags_controller.rb +2 -4
- data/app/controllers/admin/users_controller.rb +5 -8
- data/app/controllers/application_controller.rb +22 -45
- data/app/controllers/comments_controller.rb +16 -11
- data/{config/initializers/authlogic.rb → app/controllers/confirmations_controller.rb} +4 -2
- data/app/controllers/emails_controller.rb +0 -2
- data/app/controllers/entities/accounts_controller.rb +1 -3
- data/app/controllers/entities/campaigns_controller.rb +8 -5
- data/app/controllers/entities/contacts_controller.rb +4 -24
- data/app/controllers/entities/leads_controller.rb +16 -12
- data/app/controllers/entities/opportunities_controller.rb +17 -16
- data/app/controllers/entities_controller.rb +31 -12
- data/app/controllers/home_controller.rb +2 -4
- data/app/controllers/lists_controller.rb +5 -1
- data/app/controllers/passwords_controller.rb +3 -59
- data/{spec/features/support/maintain_sessions.rb → app/controllers/registrations_controller.rb} +12 -5
- data/{lib/development_tasks/gem.rake → app/controllers/sessions_controller.rb} +6 -6
- data/app/controllers/tasks_controller.rb +22 -17
- data/app/controllers/users_controller.rb +8 -29
- data/app/helpers/accounts_helper.rb +1 -1
- data/app/helpers/admin/users_helper.rb +1 -1
- data/app/helpers/application_helper.rb +28 -33
- data/app/helpers/campaigns_helper.rb +1 -1
- data/app/helpers/contacts_helper.rb +1 -3
- data/app/helpers/leads_helper.rb +1 -1
- data/app/helpers/opportunities_helper.rb +48 -3
- data/app/helpers/tasks_helper.rb +1 -1
- data/app/helpers/users_helper.rb +1 -3
- data/{config/initializers/paper_trail.rb → app/mailers/devise_mailer.rb} +5 -1
- data/app/mailers/user_mailer.rb +0 -9
- data/app/models/entities/account.rb +10 -10
- data/app/models/entities/campaign.rb +4 -6
- data/app/models/entities/contact.rb +24 -12
- data/app/models/entities/lead.rb +7 -14
- data/app/models/entities/opportunity.rb +10 -11
- data/app/models/fields/custom_field.rb +1 -0
- data/app/models/fields/custom_field_date_pair.rb +2 -0
- data/app/models/fields/field.rb +1 -3
- data/app/models/list.rb +1 -1
- data/app/models/observers/entity_observer.rb +3 -7
- data/app/models/observers/lead_observer.rb +2 -4
- data/app/models/observers/opportunity_observer.rb +5 -7
- data/app/models/observers/task_observer.rb +1 -1
- data/app/models/polymorphic/email.rb +2 -2
- data/app/models/polymorphic/task.rb +13 -9
- data/app/models/polymorphic/version.rb +3 -2
- data/app/models/setting.rb +2 -0
- data/app/models/users/ability.rb +3 -4
- data/app/models/users/permission.rb +3 -3
- data/app/models/users/preference.rb +2 -1
- data/app/models/users/user.rb +67 -42
- data/app/views/accounts/_top_section.html.haml +1 -1
- data/app/views/accounts/edit.js.haml +1 -1
- data/app/views/accounts/update.js.haml +2 -2
- data/app/views/admin/users/_user.html.haml +4 -4
- data/app/views/campaigns/_metrics.html.haml +3 -3
- data/app/views/contacts/_index_brief.html.haml +1 -1
- data/app/views/contacts/_index_full.html.haml +1 -1
- data/app/views/contacts/_index_long.html.haml +1 -1
- data/app/views/devise/confirmations/new.html.haml +9 -0
- data/app/views/devise/mailer/confirmation_instructions.html.haml +4 -0
- data/app/views/devise/mailer/password_change.html.haml +3 -0
- data/app/views/devise/mailer/reset_password_instructions.html.haml +6 -0
- data/app/views/devise/passwords/edit.html.haml +18 -0
- data/app/views/devise/passwords/new.html.haml +10 -0
- data/app/views/devise/registrations/new.html.haml +21 -0
- data/app/views/devise/sessions/new.html.haml +32 -0
- data/app/views/home/_opportunity.html.haml +4 -19
- data/app/views/layouts/_about.html.haml +5 -5
- data/app/views/layouts/_header.html.haml +3 -3
- data/app/views/layouts/admin/_header.html.haml +1 -1
- data/app/views/opportunities/_index_long.html.haml +1 -24
- data/app/views/opportunities/_sidebar_show.html.haml +3 -3
- data/app/views/opportunities/_top_section.html.haml +1 -1
- data/app/views/shared/_address.html.haml +5 -5
- data/app/views/shared/_empty.html.haml +1 -1
- data/app/views/shared/_paginate_with_per_page.html.haml +1 -0
- data/app/views/users/_avatar.html.haml +1 -1
- data/bin/bundle +1 -1
- data/bin/rails +1 -1
- data/bin/setup +38 -0
- data/bin/update +33 -0
- data/bin/yarn +13 -0
- data/config/application.rb +8 -6
- data/config/boot.rb +1 -1
- data/config/brakeman.ignore +2 -2
- data/config/database.postgres.docker.yml +5 -5
- data/config/environment.rb +1 -1
- data/config/environments/development.rb +1 -0
- data/config/environments/test.rb +7 -0
- data/config/initializers/action_mailer.rb +1 -3
- data/config/initializers/application_controller_renderer.rb +9 -0
- data/config/initializers/assets.rb +6 -11
- data/config/initializers/backtrace_silencers.rb +0 -6
- data/config/initializers/content_security_policy.rb +26 -0
- data/config/initializers/cookies_serializer.rb +3 -6
- data/config/initializers/devise.rb +289 -0
- data/config/initializers/filter_parameter_logging.rb +0 -5
- data/config/initializers/gravatar.rb +0 -1
- data/config/initializers/inflections.rb +0 -6
- data/config/initializers/mime_types.rb +1 -9
- data/config/initializers/new_framework_defaults_5_2.rb +40 -0
- data/config/initializers/relative_url_root.rb +1 -3
- data/config/initializers/session_store.rb +1 -3
- data/config/initializers/wrap_parameters.rb +4 -9
- data/config/locales/fat_free_crm.en-GB.yml +5 -5
- data/config/locales/fat_free_crm.en-US.yml +5 -5
- data/config/locales/fat_free_crm.fr.yml +1 -1
- data/config/locales/fat_free_crm.ru.yml +1 -0
- data/config/routes.rb +20 -9
- data/db/demo/users.yml +62 -81
- data/db/migrate/20100928030620_remove_uuid.rb +1 -2
- data/db/migrate/20120316045804_activities_to_versions.rb +1 -0
- data/db/migrate/20120510025219_add_not_null_constraints_for_timestamp_columns.rb +1 -0
- data/db/migrate/20180107082701_authlogic_to_devise.rb +58 -0
- data/db/schema.rb +48 -46
- data/docker-compose.yml +10 -0
- data/fat_free_crm.gemspec +12 -14
- data/lib/development_tasks/license.rake +2 -2
- data/lib/fat_free_crm/callback.rb +2 -2
- data/lib/fat_free_crm/comment_extensions.rb +2 -4
- data/lib/fat_free_crm/core_ext/string.rb +1 -1
- data/lib/fat_free_crm/engine.rb +2 -2
- data/lib/fat_free_crm/errors.rb +1 -1
- data/lib/fat_free_crm/export_csv.rb +1 -0
- data/lib/fat_free_crm/exportable.rb +1 -1
- data/lib/fat_free_crm/fields.rb +2 -2
- data/lib/fat_free_crm/gem_dependencies.rb +1 -1
- data/lib/fat_free_crm/gem_ext/simple_form/action_view_extensions/form_helper.rb +1 -3
- data/lib/fat_free_crm/i18n.rb +2 -2
- data/lib/fat_free_crm/mail_processor/base.rb +4 -10
- data/lib/fat_free_crm/mail_processor/dropbox.rb +5 -15
- data/lib/fat_free_crm/permissions.rb +7 -18
- data/lib/fat_free_crm/sortable.rb +1 -1
- data/lib/fat_free_crm/tabs.rb +2 -2
- data/lib/fat_free_crm/version.rb +2 -2
- data/lib/gravatar_image_tag.rb +7 -8
- data/lib/missing_translation_detector.rb +1 -0
- data/lib/tasks/ffcrm/missing_translations.rake +1 -0
- data/lib/tasks/ffcrm/setup.rake +13 -4
- data/lib/tasks/ffcrm/update_data.rake +2 -2
- data/script/rails +2 -2
- data/spec/controllers/admin/users_controller_spec.rb +25 -81
- data/spec/controllers/comments_controller_spec.rb +19 -19
- data/spec/controllers/emails_controller_spec.rb +2 -2
- data/spec/controllers/entities/accounts_controller_spec.rb +56 -56
- data/spec/controllers/entities/campaigns_controller_spec.rb +66 -66
- data/spec/controllers/entities/contacts_controller_spec.rb +69 -68
- data/spec/controllers/entities/leads_controller_spec.rb +126 -126
- data/spec/controllers/entities/opportunities_controller_spec.rb +101 -101
- data/spec/controllers/entities_controller_spec.rb +5 -0
- data/spec/controllers/home_controller_spec.rb +30 -30
- data/spec/controllers/tasks_controller_spec.rb +42 -40
- data/spec/controllers/users_controller_spec.rb +43 -113
- data/spec/factories/account_factories.rb +13 -13
- data/spec/factories/campaign_factories.rb +8 -8
- data/spec/factories/contact_factories.rb +18 -18
- data/spec/factories/field_factories.rb +11 -10
- data/spec/factories/lead_factories.rb +13 -13
- data/spec/factories/list_factories.rb +3 -3
- data/spec/factories/opportunity_factories.rb +9 -9
- data/spec/factories/sequences.rb +1 -1
- data/spec/factories/setting_factories.rb +5 -5
- data/spec/factories/shared_factories.rb +25 -23
- data/spec/factories/subscription_factories.rb +1 -1
- data/spec/factories/tag_factories.rb +1 -1
- data/spec/factories/task_factories.rb +11 -11
- data/spec/factories/user_factories.rb +27 -30
- data/spec/features/accounts_spec.rb +17 -4
- data/spec/features/admin/groups_spec.rb +2 -2
- data/spec/features/admin/users_spec.rb +4 -2
- data/spec/features/campaigns_spec.rb +5 -5
- data/spec/features/contacts_spec.rb +11 -5
- data/spec/features/dashboard_spec.rb +8 -8
- data/spec/features/devise/sign_in_spec.rb +58 -0
- data/spec/features/devise/sign_up_spec.rb +36 -0
- data/spec/features/leads_spec.rb +5 -5
- data/spec/features/opportunities_overview_spec.rb +16 -16
- data/spec/features/opportunities_spec.rb +35 -9
- data/spec/features/support/autocomlete_helper.rb +17 -0
- data/spec/features/support/browser.rb +5 -9
- data/spec/features/tasks_spec.rb +5 -5
- data/spec/helpers/admin/field_groups_helper_spec.rb +1 -1
- data/spec/helpers/application_helper_spec.rb +1 -1
- data/spec/helpers/tasks_helper_spec.rb +1 -1
- data/spec/helpers/users_helper_spec.rb +7 -7
- data/spec/lib/comment_extensions_spec.rb +11 -5
- data/spec/lib/errors_spec.rb +2 -2
- data/spec/lib/mail_processor/base_spec.rb +3 -3
- data/spec/lib/mail_processor/comment_replies_spec.rb +3 -3
- data/spec/lib/mail_processor/dropbox_spec.rb +17 -17
- data/spec/lib/mail_processor/sample_emails/dropbox.rb +8 -8
- data/spec/lib/permissions_spec.rb +15 -28
- data/spec/mailers/devise_mailer_spec.rb +35 -0
- data/spec/mailers/user_mailer_spec.rb +6 -32
- data/spec/models/entities/account_spec.rb +58 -32
- data/spec/models/entities/campaign_spec.rb +18 -25
- data/spec/models/entities/contact_spec.rb +113 -21
- data/spec/models/entities/lead_spec.rb +9 -11
- data/spec/models/entities/opportunity_spec.rb +45 -45
- data/spec/models/fields/custom_field_date_pair_spec.rb +4 -2
- data/spec/models/fields/custom_field_spec.rb +21 -19
- data/spec/models/list_spec.rb +2 -2
- data/spec/models/observers/entity_observer_spec.rb +7 -7
- data/spec/models/polymorphic/address_spec.rb +1 -1
- data/spec/models/polymorphic/avatar_spec.rb +5 -5
- data/spec/models/polymorphic/comment_spec.rb +5 -5
- data/spec/models/polymorphic/task_spec.rb +65 -58
- data/spec/models/polymorphic/version_spec.rb +31 -31
- data/spec/models/setting_spec.rb +2 -2
- data/spec/models/users/preference_spec.rb +6 -6
- data/spec/models/users/user_spec.rb +46 -50
- data/spec/routing/users_routing_spec.rb +30 -8
- data/spec/shared/controllers.rb +3 -9
- data/spec/shared/models.rb +22 -22
- data/spec/spec_helper.rb +12 -4
- data/spec/support/assert_select.rb +1 -0
- data/spec/support/devise_helpers.rb +28 -0
- data/spec/{features/support/helpers.rb → support/feature_helpers.rb} +11 -11
- data/spec/support/macros.rb +7 -4
- data/spec/views/accounts/_edit.haml_spec.rb +1 -1
- data/spec/views/accounts/create.js.haml_spec.rb +3 -3
- data/spec/views/accounts/destroy.js.haml_spec.rb +1 -1
- data/spec/views/accounts/edit.js.haml_spec.rb +2 -2
- data/spec/views/accounts/index.haml_spec.rb +2 -2
- data/spec/views/accounts/index.js.haml_spec.rb +1 -1
- data/spec/views/accounts/show.haml_spec.rb +4 -4
- data/spec/views/accounts/update.js.haml_spec.rb +1 -1
- data/spec/views/admin/field_groups/create.js.haml_spec.rb +1 -1
- data/spec/views/admin/field_groups/destroy.js.haml_spec.rb +1 -1
- data/spec/views/admin/field_groups/edit.js.haml_spec.rb +1 -1
- data/spec/views/admin/field_groups/new.js.haml_spec.rb +1 -1
- data/spec/views/admin/field_groups/update.js.haml_spec.rb +1 -1
- data/spec/views/admin/users/create.js.haml_spec.rb +2 -2
- data/spec/views/admin/users/destroy.js.haml_spec.rb +2 -2
- data/spec/views/admin/users/edit.js.haml_spec.rb +2 -2
- data/spec/views/admin/users/index.haml_spec.rb +1 -1
- data/spec/views/admin/users/index.js.haml_spec.rb +2 -2
- data/spec/views/admin/users/reactivate.js.haml_spec.rb +1 -1
- data/spec/views/admin/users/suspend.js.haml_spec.rb +1 -1
- data/spec/views/admin/users/update.js.haml_spec.rb +1 -1
- data/spec/views/application/auto_complete.haml_spec.rb +3 -3
- data/spec/views/campaigns/_edit.haml_spec.rb +1 -1
- data/spec/views/campaigns/create.js.haml_spec.rb +4 -4
- data/spec/views/campaigns/destroy.js.haml_spec.rb +1 -1
- data/spec/views/campaigns/edit.js.haml_spec.rb +4 -4
- data/spec/views/campaigns/index.haml_spec.rb +1 -1
- data/spec/views/campaigns/index.js.haml_spec.rb +2 -2
- data/spec/views/campaigns/show.haml_spec.rb +4 -4
- data/spec/views/campaigns/update.js.haml_spec.rb +2 -2
- data/spec/views/contacts/_edit.haml_spec.rb +7 -7
- data/spec/views/contacts/_new.haml_spec.rb +1 -1
- data/spec/views/contacts/create.js.haml_spec.rb +5 -5
- data/spec/views/contacts/destroy.js.haml_spec.rb +1 -1
- data/spec/views/contacts/edit.js.haml_spec.rb +4 -4
- data/spec/views/contacts/index.haml_spec.rb +1 -1
- data/spec/views/contacts/index.js.html_spec.rb +2 -2
- data/spec/views/contacts/new.js.haml_spec.rb +1 -1
- data/spec/views/contacts/show.haml_spec.rb +3 -3
- data/spec/views/contacts/update.js.haml_spec.rb +5 -5
- data/spec/views/home/index.haml_spec.rb +1 -1
- data/spec/views/home/index.js.haml_spec.rb +1 -1
- data/spec/views/home/options.js.haml_spec.rb +2 -2
- data/spec/views/leads/_convert.haml_spec.rb +3 -3
- data/spec/views/leads/_edit.haml_spec.rb +2 -2
- data/spec/views/leads/_new.haml_spec.rb +2 -2
- data/spec/views/leads/_sidebar_show.haml_spec.rb +5 -5
- data/spec/views/leads/convert.js.haml_spec.rb +4 -4
- data/spec/views/leads/create.js.haml_spec.rb +5 -5
- data/spec/views/leads/destroy.js.haml_spec.rb +2 -2
- data/spec/views/leads/edit.js.haml_spec.rb +4 -4
- data/spec/views/leads/index.haml_spec.rb +1 -1
- data/spec/views/leads/index.js.haml_spec.rb +1 -1
- data/spec/views/leads/new.js.haml_spec.rb +1 -1
- data/spec/views/leads/promote.js.haml_spec.rb +7 -7
- data/spec/views/leads/reject.js.haml_spec.rb +2 -2
- data/spec/views/leads/show.haml_spec.rb +2 -2
- data/spec/views/leads/update.js.haml_spec.rb +4 -4
- data/spec/views/opportunities/_edit.haml_spec.rb +7 -7
- data/spec/views/opportunities/_new.haml_spec.rb +2 -2
- data/spec/views/opportunities/create.js.haml_spec.rb +6 -6
- data/spec/views/opportunities/destroy.js.haml_spec.rb +3 -3
- data/spec/views/opportunities/edit.js.haml_spec.rb +3 -3
- data/spec/views/opportunities/index.haml_spec.rb +1 -1
- data/spec/views/opportunities/index.js.haml_spec.rb +1 -1
- data/spec/views/opportunities/new.js.haml_spec.rb +1 -1
- data/spec/views/opportunities/show.haml_spec.rb +3 -3
- data/spec/views/opportunities/update.js.haml_spec.rb +5 -5
- data/spec/views/tasks/_edit.haml_spec.rb +1 -1
- data/spec/views/tasks/complete.js.haml_spec.rb +4 -4
- data/spec/views/tasks/create.js.haml_spec.rb +6 -6
- data/spec/views/tasks/destroy.js.haml_spec.rb +2 -2
- data/spec/views/tasks/index.haml_spec.rb +4 -4
- data/spec/views/tasks/new.js.haml_spec.rb +1 -1
- data/spec/views/tasks/uncomplete.js.haml_spec.rb +2 -2
- data/spec/views/tasks/update.js.haml_spec.rb +18 -18
- data/spec/views/users/upload_avatar.js.haml_spec.rb +2 -2
- metadata +49 -71
- data/app/controllers/authentications_controller.rb +0 -53
- data/app/models/users/authentication.rb +0 -56
- data/app/views/authentications/new.html.haml +0 -19
- data/app/views/passwords/edit.html.haml +0 -15
- data/app/views/passwords/new.html.haml +0 -10
- data/app/views/user_mailer/password_reset_instructions.html.haml +0 -6
- data/app/views/users/new.html.haml +0 -19
- data/spec/controllers/authentications_controller_spec.rb +0 -150
- data/spec/controllers/passwords_controller_spec.rb +0 -32
- data/spec/models/users/authentication_spec.rb +0 -19
- data/spec/support/auth_macros.rb +0 -49
- data/spec/views/authentications/new.haml_spec.rb +0 -31
@@ -50,7 +50,6 @@ describe UsersController do
|
|
50
50
|
it "should render the requested user as JSON" do
|
51
51
|
expect(User).to receive(:find).and_return(current_user)
|
52
52
|
expect_any_instance_of(User).to receive(:to_json).and_return("generated JSON")
|
53
|
-
|
54
53
|
get :show, params: { id: current_user.id }
|
55
54
|
expect(response.body).to eq("generated JSON")
|
56
55
|
end
|
@@ -85,32 +84,6 @@ describe UsersController do
|
|
85
84
|
end
|
86
85
|
end
|
87
86
|
|
88
|
-
# GET /users/new
|
89
|
-
# GET /users/new.xml HTML
|
90
|
-
#----------------------------------------------------------------------------
|
91
|
-
describe "responding to GET new" do
|
92
|
-
describe "if user is allowed to sign up" do
|
93
|
-
it "should expose a new user as @user and render [new] template" do
|
94
|
-
expect(User).to receive(:can_signup?).and_return(true)
|
95
|
-
@user = FactoryGirl.build(:user)
|
96
|
-
allow(User).to receive(:new).and_return(@user)
|
97
|
-
|
98
|
-
get :new
|
99
|
-
expect(assigns[:user]).to eq(@user)
|
100
|
-
expect(response).to render_template("users/new")
|
101
|
-
end
|
102
|
-
end
|
103
|
-
|
104
|
-
describe "if user is not allowed to sign up" do
|
105
|
-
it "should redirect to login_path" do
|
106
|
-
expect(User).to receive(:can_signup?).and_return(false)
|
107
|
-
|
108
|
-
get :new
|
109
|
-
expect(response).to redirect_to(login_path)
|
110
|
-
end
|
111
|
-
end
|
112
|
-
end
|
113
|
-
|
114
87
|
# GET /users/1/edit AJAX
|
115
88
|
#----------------------------------------------------------------------------
|
116
89
|
describe "responding to GET edit" do
|
@@ -138,50 +111,6 @@ describe UsersController do
|
|
138
111
|
end
|
139
112
|
end
|
140
113
|
|
141
|
-
# POST /users
|
142
|
-
# POST /users.xml HTML
|
143
|
-
#----------------------------------------------------------------------------
|
144
|
-
describe "responding to POST create" do
|
145
|
-
describe "with valid params" do
|
146
|
-
before(:each) do
|
147
|
-
@username = "none"
|
148
|
-
@email = @username + "@example.com"
|
149
|
-
@password = "secret"
|
150
|
-
@user = FactoryGirl.build(:user, username: @username, email: @email)
|
151
|
-
allow(User).to receive(:new).and_return(@user)
|
152
|
-
end
|
153
|
-
|
154
|
-
it "exposes a newly created user as @user and redirect to profile page" do
|
155
|
-
login_admin
|
156
|
-
post :create, params: { user: { username: @username, email: @email, password: @password, password_confirmation: @password } }
|
157
|
-
expect(assigns[:user]).to eq(@user)
|
158
|
-
expect(flash[:notice]).to match(/welcome/)
|
159
|
-
expect(response).to redirect_to(profile_path)
|
160
|
-
end
|
161
|
-
|
162
|
-
it "should redirect to login page if user signup needs approval" do
|
163
|
-
allow(Setting).to receive(:user_signup).and_return(:needs_approval)
|
164
|
-
|
165
|
-
post :create, params: { user: { username: @username, email: @email, password: @password, password_confirmation: @password } }
|
166
|
-
expect(assigns[:user]).to eq(@user)
|
167
|
-
expect(flash[:notice]).to match(/approval/)
|
168
|
-
expect(response).to redirect_to(login_path)
|
169
|
-
end
|
170
|
-
end
|
171
|
-
|
172
|
-
describe "with invalid params" do
|
173
|
-
it "assigns a newly created but unsaved user as @user and renders [new] template" do
|
174
|
-
login_admin
|
175
|
-
@user = FactoryGirl.build(:user, username: "", email: "")
|
176
|
-
allow(User).to receive(:new).and_return(@user)
|
177
|
-
|
178
|
-
post :create, params: { user: {} }
|
179
|
-
expect(assigns[:user]).to eq(@user)
|
180
|
-
expect(response).to render_template("users/new")
|
181
|
-
end
|
182
|
-
end
|
183
|
-
end
|
184
|
-
|
185
114
|
# PUT /users/1
|
186
115
|
# PUT /users/1.xml AJAX
|
187
116
|
#----------------------------------------------------------------------------
|
@@ -253,7 +182,7 @@ describe UsersController do
|
|
253
182
|
end
|
254
183
|
|
255
184
|
it "should delete avatar if user chooses to use Gravatar" do
|
256
|
-
@avatar =
|
185
|
+
@avatar = create(:avatar, user: @user, entity: @user)
|
257
186
|
|
258
187
|
put :upload_avatar, params: { id: @user.id, gravatar: 1 }, xhr: true
|
259
188
|
expect(@user.reload.avatar).to eq(nil)
|
@@ -261,7 +190,7 @@ describe UsersController do
|
|
261
190
|
end
|
262
191
|
|
263
192
|
it "should do nothing if user hasn't specified the avatar file to upload" do
|
264
|
-
@avatar =
|
193
|
+
@avatar = create(:avatar, user: @user, entity: @user)
|
265
194
|
|
266
195
|
put :upload_avatar, params: { id: @user.id }, xhr: true
|
267
196
|
expect(@user.avatar).to eq(@avatar)
|
@@ -312,52 +241,53 @@ describe UsersController do
|
|
312
241
|
#----------------------------------------------------------------------------
|
313
242
|
describe "responding to PUT change_password" do
|
314
243
|
before(:each) do
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
|
319
|
-
@
|
320
|
-
@new_password = "secret?!"
|
244
|
+
@old_password = 'foobar123'
|
245
|
+
@user = FactoryBot.create(:user, password: @old_password, password_confirmation: @old_password)
|
246
|
+
perform_login(@user)
|
247
|
+
@old_encrypted_password = @user.encrypted_password
|
248
|
+
@new_password = 'secret?!'
|
321
249
|
end
|
322
250
|
|
323
251
|
it "should set new user password" do
|
324
|
-
put :change_password, params: { id: @user.id, current_password: @
|
325
|
-
expect(assigns[:user]).to eq(
|
326
|
-
expect(
|
327
|
-
expect(
|
328
|
-
expect(
|
252
|
+
put :change_password, params: { id: @user.id, current_password: @old_password, user: { password: @new_password, password_confirmation: @new_password } }, xhr: true
|
253
|
+
expect(assigns[:user]).to eq(@user)
|
254
|
+
expect(assigns[:user].password).to eq('secret?!')
|
255
|
+
expect(assigns[:user].errors).to be_empty
|
256
|
+
expect(assigns[:user].reload.encrypted_password).to_not eq(@old_encrypted_password) # password change
|
329
257
|
expect(response).to render_template("users/change_password")
|
330
258
|
end
|
331
259
|
|
332
|
-
it "should allow to change password if current password is blank" do
|
333
|
-
|
260
|
+
it "should not allow to change password if current password is blank" do
|
261
|
+
current_user.encrypted_password = nil
|
334
262
|
put :change_password, params: { id: @user.id, current_password: "", user: { password: @new_password, password_confirmation: @new_password } }, xhr: true
|
335
|
-
expect(
|
336
|
-
expect(
|
337
|
-
expect(
|
263
|
+
expect(assigns[:user].password).to eq(nil)
|
264
|
+
expect(assigns[:user].errors.size).to eq(1) # .error_on(:current_password)
|
265
|
+
expect(assigns[:user].reload.encrypted_password).to eq(@old_encrypted_password) # password stays the same
|
338
266
|
expect(response).to render_template("users/change_password")
|
339
267
|
end
|
340
268
|
|
341
269
|
it "should not change user password if password field is blank" do
|
342
|
-
put :change_password, params: { id: @user.id, current_password: @
|
270
|
+
put :change_password, params: { id: @user.id, current_password: @old_password, user: { password: "", password_confirmation: "" } }, xhr: true
|
343
271
|
expect(assigns[:user]).to eq(current_user)
|
344
|
-
expect(
|
345
|
-
expect(
|
346
|
-
expect(
|
272
|
+
expect(assigns[:user].password).to eq(nil)
|
273
|
+
expect(assigns[:user].errors).to be_empty # no errors
|
274
|
+
expect(assigns[:user].reload.encrypted_password).to eq(@old_encrypted_password) # password stays the same
|
347
275
|
expect(response).to render_template("users/change_password")
|
348
276
|
end
|
349
277
|
|
350
278
|
it "should require valid current password" do
|
351
279
|
put :change_password, params: { id: @user.id, current_password: "what?!", user: { password: @new_password, password_confirmation: @new_password } }, xhr: true
|
352
|
-
expect(
|
353
|
-
expect(
|
280
|
+
expect(assigns[:user].password).to eq(nil)
|
281
|
+
expect(assigns[:user].errors.size).to eq(1) # .error_on(:current_password)
|
282
|
+
expect(assigns[:user].reload.encrypted_password).to eq(@old_encrypted_password) # password stays the same
|
354
283
|
expect(response).to render_template("users/change_password")
|
355
284
|
end
|
356
285
|
|
357
286
|
it "should require new password and password confirmation to match" do
|
358
|
-
put :change_password, params: { id: @user.id, current_password: @
|
359
|
-
expect(
|
360
|
-
expect(
|
287
|
+
put :change_password, params: { id: @user.id, current_password: @old_password, user: { password: @new_password, password_confirmation: "none" } }, xhr: true
|
288
|
+
expect(assigns[:user].password).to eq('secret?!')
|
289
|
+
expect(assigns[:user].errors.size).to eq(1) # .error_on(:current_password)
|
290
|
+
expect(assigns[:user].reload.encrypted_password).to eq(@old_encrypted_password) # password stays the same
|
361
291
|
expect(response).to render_template("users/change_password")
|
362
292
|
end
|
363
293
|
end
|
@@ -368,24 +298,24 @@ describe UsersController do
|
|
368
298
|
describe "responding to GET opportunities_overview" do
|
369
299
|
before(:each) do
|
370
300
|
login
|
371
|
-
@user =
|
301
|
+
@user = current_user
|
372
302
|
@user.update_attributes(first_name: "Apple", last_name: "Boy")
|
373
303
|
end
|
374
304
|
|
375
305
|
it "should assign @users_with_opportunities" do
|
376
|
-
|
306
|
+
create(:opportunity, stage: "prospecting", assignee: @user)
|
377
307
|
get :opportunities_overview, xhr: true
|
378
|
-
expect(assigns[:users_with_opportunities]).to eq([@
|
308
|
+
expect(assigns[:users_with_opportunities]).to eq([@user])
|
379
309
|
end
|
380
310
|
|
381
311
|
it "@users_with_opportunities should be ordered by name" do
|
382
|
-
|
312
|
+
create(:opportunity, stage: "prospecting", assignee: @user)
|
383
313
|
|
384
|
-
user1 =
|
385
|
-
|
314
|
+
user1 = create(:user, first_name: "Zebra", last_name: "Stripes")
|
315
|
+
create(:opportunity, stage: "prospecting", assignee: user1)
|
386
316
|
|
387
|
-
user2 =
|
388
|
-
|
317
|
+
user2 = create(:user, first_name: "Bilbo", last_name: "Magic")
|
318
|
+
create(:opportunity, stage: "prospecting", assignee: user2)
|
389
319
|
|
390
320
|
get :opportunities_overview, xhr: true
|
391
321
|
|
@@ -393,9 +323,9 @@ describe UsersController do
|
|
393
323
|
end
|
394
324
|
|
395
325
|
it "should assign @unassigned_opportunities with only open unassigned opportunities" do
|
396
|
-
@o1 =
|
397
|
-
@o2 =
|
398
|
-
@o3 =
|
326
|
+
@o1 = create(:opportunity, stage: "prospecting", assignee: nil)
|
327
|
+
@o2 = create(:opportunity, stage: "won", assignee: nil)
|
328
|
+
@o3 = create(:opportunity, stage: "prospecting", assignee: nil)
|
399
329
|
|
400
330
|
get :opportunities_overview, xhr: true
|
401
331
|
|
@@ -404,9 +334,9 @@ describe UsersController do
|
|
404
334
|
end
|
405
335
|
|
406
336
|
it "@unassigned_opportunities should be ordered by stage" do
|
407
|
-
@o1 =
|
408
|
-
@o2 =
|
409
|
-
@o3 =
|
337
|
+
@o1 = create(:opportunity, stage: "proposal", assignee: nil)
|
338
|
+
@o2 = create(:opportunity, stage: "prospecting", assignee: nil)
|
339
|
+
@o3 = create(:opportunity, stage: "negotiation", assignee: nil)
|
410
340
|
|
411
341
|
get :opportunities_overview, xhr: true
|
412
342
|
|
@@ -419,7 +349,7 @@ describe UsersController do
|
|
419
349
|
end
|
420
350
|
|
421
351
|
it "should not include users who have no open assigned opportunities" do
|
422
|
-
|
352
|
+
create(:opportunity, stage: "won", assignee: @user)
|
423
353
|
|
424
354
|
get :opportunities_overview, xhr: true
|
425
355
|
expect(assigns[:users_with_opportunities]).to eq([])
|
@@ -5,36 +5,36 @@
|
|
5
5
|
# Fat Free CRM is freely distributable under the terms of MIT license.
|
6
6
|
# See MIT-LICENSE file or http://www.opensource.org/licenses/mit-license.php
|
7
7
|
#------------------------------------------------------------------------------
|
8
|
-
|
8
|
+
FactoryBot.define do
|
9
9
|
factory :account do
|
10
10
|
user
|
11
|
-
assigned_to nil
|
11
|
+
assigned_to { nil }
|
12
12
|
name { FFaker::Company.name + rand(100).to_s }
|
13
|
-
access "Public"
|
14
|
-
website {
|
13
|
+
access { "Public" }
|
14
|
+
website { FactoryBot.generate(:website) }
|
15
15
|
email { FFaker::Internet.email }
|
16
16
|
toll_free_phone { FFaker::PhoneNumber.phone_number }
|
17
17
|
phone { FFaker::PhoneNumber.phone_number }
|
18
18
|
fax { FFaker::PhoneNumber.phone_number }
|
19
19
|
background_info { FFaker::Lorem.paragraph[0, 255] }
|
20
|
-
deleted_at nil
|
21
|
-
updated_at {
|
22
|
-
created_at {
|
20
|
+
deleted_at { nil }
|
21
|
+
updated_at { FactoryBot.generate(:time) }
|
22
|
+
created_at { FactoryBot.generate(:time) }
|
23
23
|
end
|
24
24
|
|
25
25
|
factory :account_contact do
|
26
26
|
account
|
27
27
|
contact
|
28
|
-
deleted_at nil
|
29
|
-
updated_at {
|
30
|
-
created_at {
|
28
|
+
deleted_at { nil }
|
29
|
+
updated_at { FactoryBot.generate(:time) }
|
30
|
+
created_at { FactoryBot.generate(:time) }
|
31
31
|
end
|
32
32
|
|
33
33
|
factory :account_opportunity do
|
34
34
|
account
|
35
35
|
opportunity
|
36
|
-
deleted_at nil
|
37
|
-
updated_at {
|
38
|
-
created_at {
|
36
|
+
deleted_at { nil }
|
37
|
+
updated_at { FactoryBot.generate(:time) }
|
38
|
+
created_at { FactoryBot.generate(:time) }
|
39
39
|
end
|
40
40
|
end
|
@@ -5,12 +5,12 @@
|
|
5
5
|
# Fat Free CRM is freely distributable under the terms of MIT license.
|
6
6
|
# See MIT-LICENSE file or http://www.opensource.org/licenses/mit-license.php
|
7
7
|
#------------------------------------------------------------------------------
|
8
|
-
|
8
|
+
FactoryBot.define do
|
9
9
|
factory :campaign do
|
10
10
|
user
|
11
11
|
name { FFaker::Lorem.sentence[0, 64] }
|
12
|
-
assigned_to nil
|
13
|
-
access "Public"
|
12
|
+
assigned_to { nil }
|
13
|
+
access { "Public" }
|
14
14
|
status { %w[planned started completed planned started completed on_hold called_off].sample }
|
15
15
|
budget { rand(500) }
|
16
16
|
target_leads { rand(200) }
|
@@ -19,12 +19,12 @@ FactoryGirl.define do
|
|
19
19
|
leads_count { rand(200) }
|
20
20
|
opportunities_count { rand(20) }
|
21
21
|
revenue { rand(1000) }
|
22
|
-
ends_on {
|
23
|
-
starts_on {
|
22
|
+
ends_on { FactoryBot.generate(:date) }
|
23
|
+
starts_on { FactoryBot.generate(:date) }
|
24
24
|
objectives { FFaker::Lorem.paragraph[0, 255] }
|
25
25
|
background_info { FFaker::Lorem.paragraph[0, 255] }
|
26
|
-
deleted_at nil
|
27
|
-
updated_at {
|
28
|
-
created_at {
|
26
|
+
deleted_at { nil }
|
27
|
+
updated_at { FactoryBot.generate(:time) }
|
28
|
+
created_at { FactoryBot.generate(:time) }
|
29
29
|
end
|
30
30
|
end
|
@@ -5,16 +5,16 @@
|
|
5
5
|
# Fat Free CRM is freely distributable under the terms of MIT license.
|
6
6
|
# See MIT-LICENSE file or http://www.opensource.org/licenses/mit-license.php
|
7
7
|
#------------------------------------------------------------------------------
|
8
|
-
|
8
|
+
FactoryBot.define do
|
9
9
|
factory :contact do
|
10
10
|
user
|
11
11
|
lead
|
12
|
-
assigned_to nil
|
13
|
-
reports_to nil
|
12
|
+
assigned_to { nil }
|
13
|
+
reports_to { nil }
|
14
14
|
first_name { FFaker::Name.first_name }
|
15
15
|
last_name { FFaker::Name.last_name }
|
16
|
-
access "Public"
|
17
|
-
title {
|
16
|
+
access { "Public" }
|
17
|
+
title { FactoryBot.generate(:title) }
|
18
18
|
department { FFaker::Name.name + " Dept." }
|
19
19
|
source { %w[campaign cold_call conference online referral self web word_of_mouth other].sample }
|
20
20
|
email { FFaker::Internet.email }
|
@@ -22,24 +22,24 @@ FactoryGirl.define do
|
|
22
22
|
phone { FFaker::PhoneNumber.phone_number }
|
23
23
|
mobile { FFaker::PhoneNumber.phone_number }
|
24
24
|
fax { FFaker::PhoneNumber.phone_number }
|
25
|
-
blog {
|
26
|
-
facebook {
|
27
|
-
linkedin {
|
28
|
-
twitter {
|
29
|
-
do_not_call false
|
30
|
-
born_on "1992-10-10"
|
25
|
+
blog { FactoryBot.generate(:website) }
|
26
|
+
facebook { FactoryBot.generate(:website) }
|
27
|
+
linkedin { FactoryBot.generate(:website) }
|
28
|
+
twitter { FactoryBot.generate(:website) }
|
29
|
+
do_not_call { false }
|
30
|
+
born_on { "1992-10-10" }
|
31
31
|
background_info { FFaker::Lorem.paragraph[0, 255] }
|
32
|
-
deleted_at nil
|
33
|
-
updated_at {
|
34
|
-
created_at {
|
32
|
+
deleted_at { nil }
|
33
|
+
updated_at { FactoryBot.generate(:time) }
|
34
|
+
created_at { FactoryBot.generate(:time) }
|
35
35
|
end
|
36
36
|
|
37
37
|
factory :contact_opportunity do
|
38
38
|
contact
|
39
39
|
opportunity
|
40
|
-
role "foo"
|
41
|
-
deleted_at nil
|
42
|
-
updated_at {
|
43
|
-
created_at {
|
40
|
+
role { "foo" }
|
41
|
+
deleted_at { nil }
|
42
|
+
updated_at { FactoryBot.generate(:time) }
|
43
|
+
created_at { FactoryBot.generate(:time) }
|
44
44
|
end
|
45
45
|
end
|
@@ -5,7 +5,7 @@
|
|
5
5
|
# Fat Free CRM is freely distributable under the terms of MIT license.
|
6
6
|
# See MIT-LICENSE file or http://www.opensource.org/licenses/mit-license.php
|
7
7
|
#------------------------------------------------------------------------------
|
8
|
-
|
8
|
+
FactoryBot.define do
|
9
9
|
sequence :klass_name do |_x|
|
10
10
|
%w[Contact Account Opportunity Lead Campaign].sample
|
11
11
|
end
|
@@ -17,23 +17,24 @@ FactoryGirl.define do
|
|
17
17
|
end
|
18
18
|
|
19
19
|
factory :field_group do
|
20
|
-
klass_name {
|
21
|
-
label {
|
20
|
+
klass_name { FactoryBot.generate(:klass_name) }
|
21
|
+
label { FactoryBot.generate(:field_label) }
|
22
22
|
tag
|
23
23
|
end
|
24
24
|
|
25
25
|
factory :field do
|
26
|
-
type "Field"
|
26
|
+
type { "Field" }
|
27
27
|
field_group
|
28
|
-
position {
|
29
|
-
label {
|
28
|
+
position { FactoryBot.generate(:field_position) }
|
29
|
+
label { FactoryBot.generate(:field_label) }
|
30
30
|
name { |f| f.label.downcase.gsub(/[^a-z0-9]+/, '_') }
|
31
|
-
as "string"
|
32
|
-
|
33
|
-
|
31
|
+
as { "string" }
|
32
|
+
minlength { rand(100) }
|
33
|
+
updated_at { FactoryBot.generate(:time) }
|
34
|
+
created_at { FactoryBot.generate(:time) }
|
34
35
|
end
|
35
36
|
|
36
37
|
factory :custom_field do
|
37
|
-
type "CustomField"
|
38
|
+
type { "CustomField" }
|
38
39
|
end
|
39
40
|
end
|
@@ -5,32 +5,32 @@
|
|
5
5
|
# Fat Free CRM is freely distributable under the terms of MIT license.
|
6
6
|
# See MIT-LICENSE file or http://www.opensource.org/licenses/mit-license.php
|
7
7
|
#------------------------------------------------------------------------------
|
8
|
-
|
8
|
+
FactoryBot.define do
|
9
9
|
factory :lead do
|
10
10
|
user
|
11
11
|
campaign
|
12
|
-
assigned_to nil
|
12
|
+
assigned_to { nil }
|
13
13
|
first_name { FFaker::Name.first_name }
|
14
14
|
last_name { FFaker::Name.last_name }
|
15
|
-
access "Public"
|
15
|
+
access { "Public" }
|
16
16
|
company { FFaker::Company.name }
|
17
|
-
title {
|
17
|
+
title { FactoryBot.generate(:title) }
|
18
18
|
source { %w[campaign cold_call conference online referral self web word_of_mouth other].sample }
|
19
19
|
status { %w[new contacted converted rejected].sample }
|
20
|
-
rating 1
|
20
|
+
rating { 1 }
|
21
21
|
referred_by { FFaker::Name.name }
|
22
|
-
do_not_call false
|
23
|
-
blog {
|
24
|
-
linkedin {
|
25
|
-
facebook {
|
26
|
-
twitter {
|
22
|
+
do_not_call { false }
|
23
|
+
blog { FactoryBot.generate(:website) }
|
24
|
+
linkedin { FactoryBot.generate(:website) }
|
25
|
+
facebook { FactoryBot.generate(:website) }
|
26
|
+
twitter { FactoryBot.generate(:website) }
|
27
27
|
email { FFaker::Internet.email }
|
28
28
|
alt_email { FFaker::Internet.email }
|
29
29
|
phone { FFaker::PhoneNumber.phone_number }
|
30
30
|
mobile { FFaker::PhoneNumber.phone_number }
|
31
31
|
background_info { FFaker::Lorem.paragraph[0, 255] }
|
32
|
-
deleted_at nil
|
33
|
-
updated_at {
|
34
|
-
created_at {
|
32
|
+
deleted_at { nil }
|
33
|
+
updated_at { FactoryBot.generate(:time) }
|
34
|
+
created_at { FactoryBot.generate(:time) }
|
35
35
|
end
|
36
36
|
end
|