fat_free_crm 0.11.1 → 0.11.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.
- data/Gemfile +30 -12
- data/Gemfile.lock +131 -119
- data/Procfile +1 -1
- data/README.md +1 -1
- data/app/assets/images/notifications.png +0 -0
- data/app/assets/javascripts/application.js.erb +3 -0
- data/app/assets/javascripts/crm_textarea_autocomplete.js +44 -0
- data/app/assets/stylesheets/application.css.erb +2 -0
- data/app/assets/stylesheets/common.scss +7 -11
- data/app/assets/stylesheets/textarea_autocomplete.scss +42 -0
- data/app/controllers/admin/application_controller.rb +5 -5
- data/app/controllers/admin/field_groups_controller.rb +11 -51
- data/app/controllers/admin/fields_controller.rb +13 -59
- data/app/controllers/admin/plugins_controller.rb +1 -4
- data/app/controllers/admin/settings_controller.rb +0 -4
- data/app/controllers/admin/tags_controller.rb +11 -66
- data/app/controllers/admin/users_controller.rb +20 -83
- data/app/controllers/application_controller.rb +83 -69
- data/app/controllers/comments_controller.rb +12 -29
- data/app/controllers/emails_controller.rb +1 -5
- data/app/controllers/entities/accounts_controller.rb +13 -32
- data/app/controllers/entities/campaigns_controller.rb +17 -32
- data/app/controllers/entities/contacts_controller.rb +20 -38
- data/app/controllers/entities/leads_controller.rb +33 -55
- data/app/controllers/entities/opportunities_controller.rb +26 -42
- data/app/controllers/entities_controller.rb +92 -83
- data/app/controllers/home_controller.rb +1 -10
- data/app/controllers/lists_controller.rb +1 -4
- data/app/controllers/{entities/tasks_controller.rb → tasks_controller.rb} +21 -32
- data/app/controllers/users_controller.rb +6 -5
- data/app/helpers/accounts_helper.rb +32 -9
- data/app/helpers/application_helper.rb +15 -1
- data/app/helpers/campaigns_helper.rb +1 -1
- data/app/helpers/comments_helper.rb +11 -1
- data/app/helpers/leads_helper.rb +1 -1
- data/app/helpers/opportunities_helper.rb +1 -1
- data/app/{models/mailers/notifier.rb → mailers/dropbox_mailer.rb} +5 -16
- data/app/mailers/subscription_mailer.rb +37 -0
- data/{lib/tasks/dropbox.rake → app/mailers/user_mailer.rb} +11 -13
- data/app/models/entities/account.rb +3 -1
- data/app/models/entities/campaign.rb +3 -1
- data/app/models/entities/contact.rb +3 -1
- data/app/models/entities/lead.rb +6 -5
- data/app/models/entities/opportunity.rb +3 -1
- data/app/models/fields/field.rb +1 -1
- data/app/models/polymorphic/comment.rb +34 -0
- data/app/models/{entities → polymorphic}/task.rb +16 -3
- data/app/models/setting.rb +15 -15
- data/app/models/users/ability.rb +12 -5
- data/app/models/users/user.rb +7 -2
- data/app/views/accounts/index.html.haml +1 -1
- data/app/views/accounts/index.js.rjs +1 -1
- data/app/views/admin/plugins/index.html.haml +1 -7
- data/app/views/{shared/auto_complete.html.haml → application/_auto_complete.html.haml} +0 -0
- data/app/views/{shared → application}/index.atom.builder +1 -1
- data/app/views/{shared → application}/index.rss.builder +1 -1
- data/app/views/campaigns/index.html.haml +1 -1
- data/app/views/campaigns/index.js.rjs +1 -1
- data/app/views/comments/_new.html.haml +6 -0
- data/app/views/comments/_subscription_links.html.haml +13 -0
- data/app/views/comments/new.js.rjs +2 -0
- data/app/views/contacts/_top_section.html.haml +3 -13
- data/app/views/contacts/index.html.haml +1 -1
- data/app/views/contacts/index.js.rjs +1 -1
- data/app/views/{notifier/dropbox_ack_notification.html.haml → dropbox_mailer/dropbox_notification.html.haml} +2 -2
- data/app/views/{shared → entities}/attach.js.rjs +1 -1
- data/app/views/entities/contacts.js.rjs +1 -1
- data/app/views/{shared/discard.rjs → entities/discard.js.rjs} +0 -0
- data/app/views/entities/leads.js.rjs +1 -1
- data/app/views/entities/opportunities.js.rjs +1 -1
- data/app/views/entities/subscription_update.js.rjs +4 -0
- data/app/views/entities/versions.js.rjs +1 -1
- data/app/views/layouts/_footer.html.haml +1 -1
- data/app/views/layouts/application.html.haml +3 -0
- data/app/views/leads/_contact.html.haml +1 -0
- data/app/views/leads/index.html.haml +1 -1
- data/app/views/leads/index.js.rjs +1 -1
- data/app/views/opportunities/_top_section.html.haml +4 -14
- data/app/views/opportunities/index.html.haml +1 -1
- data/app/views/opportunities/index.js.rjs +1 -1
- data/app/views/subscription_mailer/comment_notification.text.erb +7 -0
- data/app/views/{notifier → user_mailer}/password_reset_instructions.html.haml +0 -0
- data/config/application.rb +3 -1
- data/config/environments/development.rb +1 -1
- data/config/environments/test.rb +3 -0
- data/config/initializers/action_mailer.rb +8 -5
- data/config/initializers/cancan.rb +151 -0
- data/config/initializers/constants.rb +1 -0
- data/config/initializers/locale.rb +20 -0
- data/config/initializers/paper_trail.rb +4 -5
- data/config/initializers/relative_url_root.rb +0 -1
- data/config/initializers/squeel.rb +5 -0
- data/config/locales/cz_fat_free_crm.yml +3 -3
- data/config/locales/de.yml +2 -2
- data/config/locales/de_fat_free_crm.yml +651 -596
- data/config/locales/en-GB_fat_free_crm.yml +3 -3
- data/config/locales/en-US_fat_free_crm.yml +13 -3
- data/config/locales/es_fat_free_crm.yml +3 -3
- data/config/locales/fr-CA_fat_free_crm.yml +3 -3
- data/config/locales/fr_fat_free_crm.yml +3 -3
- data/config/locales/it_fat_free_crm.yml +3 -3
- data/config/locales/pl_fat_free_crm.yml +3 -3
- data/config/locales/pt-BR_fat_free_crm.yml +3 -3
- data/config/locales/ru_fat_free_crm.yml +3 -3
- data/config/locales/sv-SE_fat_free_crm.yml +3 -3
- data/config/locales/th_fat_free_crm.yml +3 -3
- data/config/routes.rb +10 -0
- data/config/settings.default.yml +29 -10
- data/config/unicorn.rb +4 -0
- data/db/migrate/20111201030535_add_field_groups_klass_name.rb +3 -1
- data/db/migrate/20120314080441_add_subscribed_users_to_entities.rb +23 -0
- data/db/migrate/20120405080727_change_subscribed_users_to_set.rb +24 -0
- data/db/migrate/20120405080742_change_further_subscribed_users_to_set.rb +27 -0
- data/db/migrate/20120413034923_add_index_on_versions_item_type.rb +5 -0
- data/db/schema.rb +109 -126
- data/fat_free_crm.gemspec +12 -18
- data/lib/fat_free_crm.rb +0 -1
- data/lib/fat_free_crm/core_ext/array.rb +1 -0
- data/lib/fat_free_crm/gem_dependencies.rb +1 -0
- data/lib/fat_free_crm/mail_processor/base.rb +226 -0
- data/lib/fat_free_crm/mail_processor/comment_replies.rb +86 -0
- data/lib/fat_free_crm/mail_processor/dropbox.rb +288 -0
- data/lib/fat_free_crm/permissions.rb +6 -19
- data/lib/fat_free_crm/renderers.rb +0 -8
- data/lib/fat_free_crm/tabs.rb +1 -1
- data/lib/fat_free_crm/version.rb +1 -1
- data/lib/plugins/country_select/lib/country_select.rb +2 -2
- data/lib/tasks/mail_processing.rake +60 -0
- data/spec/controllers/admin/users_controller_spec.rb +0 -2
- data/spec/controllers/{accounts_controller_spec.rb → entities/accounts_controller_spec.rb} +7 -9
- data/spec/controllers/{campaigns_controller_spec.rb → entities/campaigns_controller_spec.rb} +7 -7
- data/spec/controllers/{contacts_controller_spec.rb → entities/contacts_controller_spec.rb} +5 -9
- data/spec/controllers/{leads_controller_spec.rb → entities/leads_controller_spec.rb} +7 -9
- data/spec/controllers/{opportunities_controller_spec.rb → entities/opportunities_controller_spec.rb} +8 -15
- data/spec/controllers/tasks_controller_spec.rb +1 -5
- data/spec/controllers/users_controller_spec.rb +5 -9
- data/spec/factories/subscription_factories.rb +6 -0
- data/spec/lib/mail_processor/base_spec.rb +164 -0
- data/spec/lib/mail_processor/comment_replies_spec.rb +63 -0
- data/spec/lib/{dropbox_spec.rb → mail_processor/dropbox_spec.rb} +73 -181
- data/spec/lib/mail_processor/sample_emails/dropbox.rb +167 -0
- data/spec/mailers/subscription_mailer_spec.rb +17 -0
- data/spec/models/{base → entities}/account_contact_spec.rb +0 -0
- data/spec/models/{base → entities}/account_opportunity_spec.rb +0 -0
- data/spec/models/{base → entities}/account_spec.rb +4 -0
- data/spec/models/{base → entities}/campaign_spec.rb +4 -0
- data/spec/models/{base → entities}/contact_opportunity_spec.rb +0 -0
- data/spec/models/{base → entities}/contact_spec.rb +4 -0
- data/spec/models/{base → entities}/lead_spec.rb +4 -0
- data/spec/models/{base → entities}/opportunity_spec.rb +4 -0
- data/spec/models/polymorphic/comment_spec.rb +15 -0
- data/spec/models/{base → polymorphic}/task_spec.rb +124 -30
- data/spec/models/polymorphic/version_spec.rb +1 -1
- data/spec/shared/controllers.rb +5 -7
- data/spec/shared/models.rb +46 -0
- data/spec/spec_helper.rb +3 -4
- data/spec/support/mail_processor_mocks.rb +30 -0
- data/spec/support/uploaded_file.rb +3 -0
- data/spec/views/{common → application}/auto_complete.haml_spec.rb +1 -1
- data/vendor/assets/images/jquery-ui/ui-bg_diagonals-thick_18_b81900_40x40.png +0 -0
- data/vendor/assets/images/jquery-ui/ui-bg_diagonals-thick_20_666666_40x40.png +0 -0
- data/vendor/assets/images/jquery-ui/ui-bg_flat_10_000000_40x100.png +0 -0
- data/vendor/assets/images/jquery-ui/ui-bg_glass_100_f6f6f6_1x400.png +0 -0
- data/vendor/assets/images/jquery-ui/ui-bg_glass_100_fdf5ce_1x400.png +0 -0
- data/vendor/assets/images/jquery-ui/ui-bg_glass_65_ffffff_1x400.png +0 -0
- data/vendor/assets/images/jquery-ui/ui-bg_gloss-wave_35_f6a828_500x100.png +0 -0
- data/vendor/assets/images/jquery-ui/ui-bg_highlight-soft_100_eeeeee_1x100.png +0 -0
- data/vendor/assets/images/jquery-ui/ui-bg_highlight-soft_75_ffe45c_1x100.png +0 -0
- data/vendor/assets/images/jquery-ui/ui-icons_222222_256x240.png +0 -0
- data/vendor/assets/images/jquery-ui/ui-icons_228ef1_256x240.png +0 -0
- data/vendor/assets/images/jquery-ui/ui-icons_ef8c08_256x240.png +0 -0
- data/vendor/assets/images/jquery-ui/ui-icons_ffd27a_256x240.png +0 -0
- data/vendor/assets/images/jquery-ui/ui-icons_ffffff_256x240.png +0 -0
- data/vendor/assets/javascripts/textarea_autocomplete.js +605 -0
- data/vendor/assets/stylesheets/jquery-ui.custom.css.erb +565 -0
- metadata +234 -154
- data/config/locales/simple_form.en.yml +0 -24
- data/lib/fat_free_crm/dropbox.rb +0 -439
- data/spec/lib/dropbox/email_samples.rb +0 -77
@@ -32,26 +32,13 @@ module FatFreeCRM
|
|
32
32
|
# to implement Recycle Bin/Restore and 2) to honor permissions when
|
33
33
|
# displaying "object deleted..." in the activity log.
|
34
34
|
#
|
35
|
-
has_many :permissions, :as => :asset
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
# The defaults are:
|
41
|
-
# :user => currenly logged in user
|
42
|
-
# :order => primary key descending
|
43
|
-
# :limit => none
|
44
|
-
#
|
45
|
-
scope :my, lambda { |*args|
|
46
|
-
options = args[0] || {}
|
47
|
-
includes(:permissions).
|
48
|
-
where("#{quoted_table_name}.user_id = :user OR " <<
|
49
|
-
"#{quoted_table_name}.assigned_to = :user OR " <<
|
50
|
-
"permissions.user_id = :user OR " <<
|
51
|
-
"#{quoted_table_name}.access = 'Public'", :user => options[:user] || User.current_user).
|
52
|
-
order(options[:order] || "#{quoted_table_name}.id DESC").
|
53
|
-
limit(options[:limit]) # nil selects all records
|
35
|
+
has_many :permissions, :as => :asset
|
36
|
+
|
37
|
+
scope :my, lambda {
|
38
|
+
current_ability = Ability.new(User.current_user)
|
39
|
+
accessible_by(current_ability).readonly(false)
|
54
40
|
}
|
41
|
+
|
55
42
|
include FatFreeCRM::Permissions::InstanceMethods
|
56
43
|
extend FatFreeCRM::Permissions::SingletonMethods
|
57
44
|
end
|
@@ -28,11 +28,3 @@ ActionController::Renderers.add :xls do |obj, options|
|
|
28
28
|
send_data str, :type => :xls,
|
29
29
|
:disposition => "attachment; filename=#{filename}.xls"
|
30
30
|
end
|
31
|
-
|
32
|
-
ActionController::Renderers.add :atom do |obj, options|
|
33
|
-
render 'shared/index.atom.builder'
|
34
|
-
end
|
35
|
-
|
36
|
-
ActionController::Renderers.add :rss do |obj, options|
|
37
|
-
render 'shared/index.rss.builder'
|
38
|
-
end
|
data/lib/fat_free_crm/tabs.rb
CHANGED
data/lib/fat_free_crm/version.rb
CHANGED
@@ -21,8 +21,8 @@ module ActionView
|
|
21
21
|
country_options += options_for_select(priority_countries, selected)
|
22
22
|
country_options += "<option value=\"\" disabled=\"disabled\">-------------</option>\n"
|
23
23
|
|
24
|
-
other_countries = COUNTRIES.select{|c| !priority_countries.include?(c[0]) }
|
25
|
-
return country_options + options_for_select(other_countries, selected)
|
24
|
+
other_countries = COUNTRIES.select{|c| !priority_countries.include?(c[0]) }
|
25
|
+
return (country_options + options_for_select(other_countries, selected)).html_safe
|
26
26
|
end
|
27
27
|
# All the countries included in the country_options output.
|
28
28
|
|
@@ -0,0 +1,60 @@
|
|
1
|
+
# Fat Free CRM
|
2
|
+
# Copyright (C) 2008-2011 by Michael Dvorkin
|
3
|
+
#
|
4
|
+
# This program is free software: you can redistribute it and/or modify
|
5
|
+
# it under the terms of the GNU Affero General Public License as published by
|
6
|
+
# the Free Software Foundation, either version 3 of the License, or
|
7
|
+
# (at your option) any later version.
|
8
|
+
#
|
9
|
+
# This program is distributed in the hope that it will be useful,
|
10
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
11
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
12
|
+
# GNU Affero General Public License for more details.
|
13
|
+
#
|
14
|
+
# You should have received a copy of the GNU Affero General Public License
|
15
|
+
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
16
|
+
#------------------------------------------------------------------------------
|
17
|
+
|
18
|
+
namespace :ffcrm do
|
19
|
+
namespace :dropbox do
|
20
|
+
desc "Run dropbox crawler and process incoming emails"
|
21
|
+
task :run => :environment do
|
22
|
+
require "fat_free_crm/mail_processor/dropbox"
|
23
|
+
FatFreeCRM::MailProcessor::Dropbox.new.run(dry_run = false)
|
24
|
+
end
|
25
|
+
namespace :run do
|
26
|
+
desc "[Dry run] - Run dropbox crawler and process incoming emails"
|
27
|
+
task :dry => :environment do
|
28
|
+
require "fat_free_crm/mail_processor/dropbox"
|
29
|
+
FatFreeCRM::MailProcessor::Dropbox.new.run(dry_run = true)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
desc "Set up email dropbox based on currently loaded settings"
|
34
|
+
task :setup => :environment do
|
35
|
+
require "fat_free_crm/mail_processor/dropbox"
|
36
|
+
FatFreeCRM::MailProcessor::Dropbox.new.setup
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
namespace :comment_replies do
|
41
|
+
desc "Run comment inbox crawler and process incoming emails"
|
42
|
+
task :run => :environment do
|
43
|
+
require "fat_free_crm/mail_processor/comment_replies"
|
44
|
+
FatFreeCRM::MailProcessor::CommentReplies.new.run(dry_run = false)
|
45
|
+
end
|
46
|
+
namespace :run do
|
47
|
+
desc "[Dry run] - Run comment inbox crawler and process incoming emails"
|
48
|
+
task :dry => :environment do
|
49
|
+
require "fat_free_crm/mail_processor/comment_replies"
|
50
|
+
FatFreeCRM::MailProcessor::CommentReplies.new.run(dry_run = true)
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
desc "Set up comment inbox based on currently loaded settings"
|
55
|
+
task :setup => :environment do
|
56
|
+
require "fat_free_crm/mail_processor/comment_replies"
|
57
|
+
FatFreeCRM::MailProcessor::CommentReplies.new.setup
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
@@ -142,7 +142,6 @@ describe Admin::UsersController do
|
|
142
142
|
response.should render_template("admin/users/create")
|
143
143
|
end
|
144
144
|
end
|
145
|
-
|
146
145
|
end
|
147
146
|
|
148
147
|
# PUT /admin/users/1
|
@@ -196,7 +195,6 @@ describe Admin::UsersController do
|
|
196
195
|
response.should render_template("admin/users/update")
|
197
196
|
end
|
198
197
|
end
|
199
|
-
|
200
198
|
end
|
201
199
|
|
202
200
|
# GET /admin/users/1/confirm AJAX
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require File.expand_path(File.dirname(__FILE__) + '
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
|
2
2
|
|
3
3
|
describe AccountsController do
|
4
4
|
def get_data_for_sidebar
|
@@ -34,7 +34,7 @@ describe AccountsController do
|
|
34
34
|
|
35
35
|
it "should filter out accounts by category" do
|
36
36
|
categories = %w(customer vendor)
|
37
|
-
controller.session[:
|
37
|
+
controller.session[:accounts_filter] = categories.join(',')
|
38
38
|
@accounts = [
|
39
39
|
FactoryGirl.create(:account, :user => @current_user, :category => categories.first),
|
40
40
|
FactoryGirl.create(:account, :user => @current_user, :category => categories.last)
|
@@ -80,7 +80,7 @@ describe AccountsController do
|
|
80
80
|
|
81
81
|
describe "with mime type of JSON" do
|
82
82
|
it "should render all accounts as json" do
|
83
|
-
@controller.should_receive(:
|
83
|
+
@controller.should_receive(:get_accounts).and_return(accounts = mock("Array of Accounts"))
|
84
84
|
accounts.should_receive(:to_json).and_return("generated JSON")
|
85
85
|
|
86
86
|
request.env["HTTP_ACCEPT"] = "application/json"
|
@@ -91,7 +91,7 @@ describe AccountsController do
|
|
91
91
|
|
92
92
|
describe "with mime type of XML" do
|
93
93
|
it "should render all accounts as xml" do
|
94
|
-
@controller.should_receive(:
|
94
|
+
@controller.should_receive(:get_accounts).and_return(accounts = mock("Array of Accounts"))
|
95
95
|
accounts.should_receive(:to_xml).and_return("generated XML")
|
96
96
|
|
97
97
|
request.env["HTTP_ACCEPT"] = "application/xml"
|
@@ -130,7 +130,7 @@ describe AccountsController do
|
|
130
130
|
describe "with mime type of JSON" do
|
131
131
|
it "should render the requested account as json" do
|
132
132
|
@account = FactoryGirl.create(:account, :user => @current_user)
|
133
|
-
Account.
|
133
|
+
Account.should_receive(:find).and_return(@account)
|
134
134
|
@account.should_receive(:to_json).and_return("generated JSON")
|
135
135
|
|
136
136
|
request.env["HTTP_ACCEPT"] = "application/json"
|
@@ -142,7 +142,7 @@ describe AccountsController do
|
|
142
142
|
describe "with mime type of XML" do
|
143
143
|
it "should render the requested account as xml" do
|
144
144
|
@account = FactoryGirl.create(:account, :user => @current_user)
|
145
|
-
Account.
|
145
|
+
Account.should_receive(:find).and_return(@account)
|
146
146
|
@account.should_receive(:to_xml).and_return("generated XML")
|
147
147
|
|
148
148
|
request.env["HTTP_ACCEPT"] = "application/xml"
|
@@ -281,7 +281,6 @@ describe AccountsController do
|
|
281
281
|
response.should render_template("accounts/edit")
|
282
282
|
end
|
283
283
|
end
|
284
|
-
|
285
284
|
end
|
286
285
|
|
287
286
|
# POST /accounts
|
@@ -333,7 +332,6 @@ describe AccountsController do
|
|
333
332
|
response.should render_template("accounts/create")
|
334
333
|
end
|
335
334
|
end
|
336
|
-
|
337
335
|
end
|
338
336
|
|
339
337
|
# PUT /accounts/1
|
@@ -609,7 +607,7 @@ describe AccountsController do
|
|
609
607
|
#----------------------------------------------------------------------------
|
610
608
|
describe "responding to POST filter" do
|
611
609
|
it "should expose filtered accounts as @accounts and render [index] template" do
|
612
|
-
session[:
|
610
|
+
session[:accounts_filter] = "customer,vendor"
|
613
611
|
@accounts = [ FactoryGirl.create(:account, :category => "partner", :user => @current_user) ]
|
614
612
|
|
615
613
|
xhr :post, :filter, :category => "partner"
|
data/spec/controllers/{campaigns_controller_spec.rb → entities/campaigns_controller_spec.rb}
RENAMED
@@ -1,4 +1,4 @@
|
|
1
|
-
require File.expand_path(File.dirname(__FILE__) + '
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
|
2
2
|
|
3
3
|
describe CampaignsController do
|
4
4
|
|
@@ -36,7 +36,7 @@ describe CampaignsController do
|
|
36
36
|
end
|
37
37
|
|
38
38
|
it "should filter out campaigns by status" do
|
39
|
-
controller.session[:
|
39
|
+
controller.session[:campaigns_filter] = "planned,started"
|
40
40
|
@campaigns = [
|
41
41
|
FactoryGirl.create(:campaign, :user => @current_user, :status => "started"),
|
42
42
|
FactoryGirl.create(:campaign, :user => @current_user, :status => "planned")
|
@@ -85,7 +85,7 @@ describe CampaignsController do
|
|
85
85
|
|
86
86
|
describe "with mime type of JSON" do
|
87
87
|
it "should render all campaigns as JSON" do
|
88
|
-
@controller.should_receive(:
|
88
|
+
@controller.should_receive(:get_campaigns).and_return(@campaigns = [])
|
89
89
|
@campaigns.should_receive(:to_json).and_return("generated JSON")
|
90
90
|
|
91
91
|
request.env["HTTP_ACCEPT"] = "application/json"
|
@@ -96,7 +96,7 @@ describe CampaignsController do
|
|
96
96
|
|
97
97
|
describe "with mime type of XML" do
|
98
98
|
it "should render all campaigns as xml" do
|
99
|
-
@controller.should_receive(:
|
99
|
+
@controller.should_receive(:get_campaigns).and_return(@campaigns = [])
|
100
100
|
@campaigns.should_receive(:to_xml).and_return("generated XML")
|
101
101
|
|
102
102
|
request.env["HTTP_ACCEPT"] = "application/xml"
|
@@ -135,7 +135,7 @@ describe CampaignsController do
|
|
135
135
|
describe "with mime type of JSON" do
|
136
136
|
it "should render the requested campaign as JSON" do
|
137
137
|
@campaign = FactoryGirl.create(:campaign, :id => 42, :user => @current_user)
|
138
|
-
Campaign.
|
138
|
+
Campaign.should_receive(:find).and_return(@campaign)
|
139
139
|
@campaign.should_receive(:to_json).and_return("generated JSON")
|
140
140
|
|
141
141
|
request.env["HTTP_ACCEPT"] = "application/json"
|
@@ -147,7 +147,7 @@ describe CampaignsController do
|
|
147
147
|
describe "with mime type of XML" do
|
148
148
|
it "should render the requested campaign as XML" do
|
149
149
|
@campaign = FactoryGirl.create(:campaign, :id => 42, :user => @current_user)
|
150
|
-
Campaign.
|
150
|
+
Campaign.should_receive(:find).and_return(@campaign)
|
151
151
|
@campaign.should_receive(:to_xml).and_return("generated XML")
|
152
152
|
|
153
153
|
request.env["HTTP_ACCEPT"] = "application/xml"
|
@@ -647,7 +647,7 @@ describe CampaignsController do
|
|
647
647
|
describe "responding to POST filter" do
|
648
648
|
|
649
649
|
it "should expose filtered campaigns as @campaigns and render [index] template" do
|
650
|
-
session[:
|
650
|
+
session[:campaigns_filter] = "planned,started"
|
651
651
|
@campaigns = [ FactoryGirl.create(:campaign, :status => "completed", :user => @current_user) ]
|
652
652
|
|
653
653
|
xhr :post, :filter, :status => "completed"
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require File.expand_path(File.dirname(__FILE__) + '
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
|
2
2
|
|
3
3
|
describe ContactsController do
|
4
4
|
|
@@ -53,7 +53,7 @@ describe ContactsController do
|
|
53
53
|
|
54
54
|
describe "with mime type of JSON" do
|
55
55
|
it "should render all contacts as JSON" do
|
56
|
-
@controller.should_receive(:
|
56
|
+
@controller.should_receive(:get_contacts).and_return(contacts = mock("Array of Contacts"))
|
57
57
|
contacts.should_receive(:to_json).and_return("generated JSON")
|
58
58
|
|
59
59
|
request.env["HTTP_ACCEPT"] = "application/json"
|
@@ -64,7 +64,7 @@ describe ContactsController do
|
|
64
64
|
|
65
65
|
describe "with mime type of XML" do
|
66
66
|
it "should render all contacts as xml" do
|
67
|
-
@controller.should_receive(:
|
67
|
+
@controller.should_receive(:get_contacts).and_return(contacts = mock("Array of Contacts"))
|
68
68
|
contacts.should_receive(:to_xml).and_return("generated XML")
|
69
69
|
|
70
70
|
request.env["HTTP_ACCEPT"] = "application/xml"
|
@@ -103,7 +103,7 @@ describe ContactsController do
|
|
103
103
|
describe "with mime type of JSON" do
|
104
104
|
it "should render the requested contact as JSON" do
|
105
105
|
@contact = FactoryGirl.create(:contact, :id => 42)
|
106
|
-
Contact.
|
106
|
+
Contact.should_receive(:find).and_return(@contact)
|
107
107
|
@contact.should_receive(:to_json).and_return("generated JSON")
|
108
108
|
|
109
109
|
request.env["HTTP_ACCEPT"] = "application/json"
|
@@ -115,7 +115,7 @@ describe ContactsController do
|
|
115
115
|
describe "with mime type of XML" do
|
116
116
|
it "should render the requested contact as xml" do
|
117
117
|
@contact = FactoryGirl.create(:contact, :id => 42)
|
118
|
-
Contact.
|
118
|
+
Contact.should_receive(:find).and_return(@contact)
|
119
119
|
@contact.should_receive(:to_xml).and_return("generated XML")
|
120
120
|
|
121
121
|
request.env["HTTP_ACCEPT"] = "application/xml"
|
@@ -151,7 +151,6 @@ describe ContactsController do
|
|
151
151
|
response.code.should == "404" # :not_found
|
152
152
|
end
|
153
153
|
end
|
154
|
-
|
155
154
|
end
|
156
155
|
|
157
156
|
# GET /contacts/new
|
@@ -279,7 +278,6 @@ describe ContactsController do
|
|
279
278
|
response.should render_template("contacts/edit")
|
280
279
|
end
|
281
280
|
end
|
282
|
-
|
283
281
|
end
|
284
282
|
|
285
283
|
# POST /contacts
|
@@ -372,9 +370,7 @@ describe ContactsController do
|
|
372
370
|
assigns(:opportunity).should == @opportunity
|
373
371
|
response.should render_template("contacts/create")
|
374
372
|
end
|
375
|
-
|
376
373
|
end
|
377
|
-
|
378
374
|
end
|
379
375
|
|
380
376
|
# PUT /contacts/1
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require File.expand_path(File.dirname(__FILE__) + '
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
|
2
2
|
|
3
3
|
describe LeadsController do
|
4
4
|
|
@@ -29,7 +29,7 @@ describe LeadsController do
|
|
29
29
|
end
|
30
30
|
|
31
31
|
it "should filter out leads by status" do
|
32
|
-
controller.session[:
|
32
|
+
controller.session[:leads_filter] = "new,contacted"
|
33
33
|
@leads = [
|
34
34
|
FactoryGirl.create(:lead, :status => "new", :user => @current_user),
|
35
35
|
FactoryGirl.create(:lead, :status => "contacted", :user => @current_user)
|
@@ -78,7 +78,7 @@ describe LeadsController do
|
|
78
78
|
|
79
79
|
describe "with mime type of JSON" do
|
80
80
|
it "should render all leads as JSON" do
|
81
|
-
@controller.should_receive(:
|
81
|
+
@controller.should_receive(:get_leads).and_return(leads = mock("Array of Leads"))
|
82
82
|
leads.should_receive(:to_json).and_return("generated JSON")
|
83
83
|
|
84
84
|
request.env["HTTP_ACCEPT"] = "application/json"
|
@@ -89,7 +89,7 @@ describe LeadsController do
|
|
89
89
|
|
90
90
|
describe "with mime type of XML" do
|
91
91
|
it "should render all leads as xml" do
|
92
|
-
@controller.should_receive(:
|
92
|
+
@controller.should_receive(:get_leads).and_return(leads = mock("Array of Leads"))
|
93
93
|
leads.should_receive(:to_xml).and_return("generated XML")
|
94
94
|
|
95
95
|
request.env["HTTP_ACCEPT"] = "application/xml"
|
@@ -126,7 +126,7 @@ describe LeadsController do
|
|
126
126
|
describe "with mime type of JSON" do
|
127
127
|
it "should render the requested lead as JSON" do
|
128
128
|
@lead = FactoryGirl.create(:lead, :id => 42, :user => @current_user)
|
129
|
-
Lead.
|
129
|
+
Lead.should_receive(:find).and_return(@lead)
|
130
130
|
@lead.should_receive(:to_json).and_return("generated JSON")
|
131
131
|
|
132
132
|
request.env["HTTP_ACCEPT"] = "application/json"
|
@@ -138,7 +138,7 @@ describe LeadsController do
|
|
138
138
|
describe "with mime type of XML" do
|
139
139
|
it "should render the requested lead as xml" do
|
140
140
|
@lead = FactoryGirl.create(:lead, :id => 42, :user => @current_user)
|
141
|
-
Lead.
|
141
|
+
Lead.should_receive(:find).and_return(@lead)
|
142
142
|
@lead.should_receive(:to_xml).and_return("generated XML")
|
143
143
|
|
144
144
|
request.env["HTTP_ACCEPT"] = "application/xml"
|
@@ -229,7 +229,6 @@ describe LeadsController do
|
|
229
229
|
response.body.should == 'window.location.href = "/campaigns";'
|
230
230
|
end
|
231
231
|
end
|
232
|
-
|
233
232
|
end
|
234
233
|
|
235
234
|
# GET /leads/1/edit AJAX
|
@@ -299,7 +298,6 @@ describe LeadsController do
|
|
299
298
|
response.should render_template("leads/edit")
|
300
299
|
end
|
301
300
|
end
|
302
|
-
|
303
301
|
end
|
304
302
|
|
305
303
|
# POST /leads
|
@@ -1027,7 +1025,7 @@ describe LeadsController do
|
|
1027
1025
|
describe "responding to POST filter" do
|
1028
1026
|
|
1029
1027
|
it "should filter out leads as @leads and render :index action" do
|
1030
|
-
session[:
|
1028
|
+
session[:leads_filter] = "contacted,rejected"
|
1031
1029
|
|
1032
1030
|
@leads = [ FactoryGirl.create(:lead, :user => @current_user, :status => "new") ]
|
1033
1031
|
xhr :post, :filter, :status => "new"
|
data/spec/controllers/{opportunities_controller_spec.rb → entities/opportunities_controller_spec.rb}
RENAMED
@@ -1,4 +1,4 @@
|
|
1
|
-
require File.expand_path(File.dirname(__FILE__) + '
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
|
2
2
|
|
3
3
|
describe OpportunitiesController do
|
4
4
|
|
@@ -35,7 +35,7 @@ describe OpportunitiesController do
|
|
35
35
|
end
|
36
36
|
|
37
37
|
it "should filter out opportunities by stage" do
|
38
|
-
controller.session[:
|
38
|
+
controller.session[:opportunities_filter] = "prospecting,negotiation"
|
39
39
|
@opportunities = [
|
40
40
|
FactoryGirl.create(:opportunity, :user => @current_user, :stage => "negotiation"),
|
41
41
|
FactoryGirl.create(:opportunity, :user => @current_user, :stage => "prospecting")
|
@@ -83,7 +83,7 @@ describe OpportunitiesController do
|
|
83
83
|
|
84
84
|
describe "with mime type of JSON" do
|
85
85
|
it "should render all opportunities as JSON" do
|
86
|
-
@controller.should_receive(:
|
86
|
+
@controller.should_receive(:get_opportunities).and_return(opportunities = mock("Array of Opportunities"))
|
87
87
|
opportunities.should_receive(:to_json).and_return("generated JSON")
|
88
88
|
|
89
89
|
request.env["HTTP_ACCEPT"] = "application/json"
|
@@ -94,7 +94,7 @@ describe OpportunitiesController do
|
|
94
94
|
|
95
95
|
describe "with mime type of JSON" do
|
96
96
|
it "should render all opportunities as JSON" do
|
97
|
-
@controller.should_receive(:
|
97
|
+
@controller.should_receive(:get_opportunities).and_return(opportunities = mock("Array of Opportunities"))
|
98
98
|
opportunities.should_receive(:to_json).and_return("generated JSON")
|
99
99
|
|
100
100
|
request.env["HTTP_ACCEPT"] = "application/json"
|
@@ -105,7 +105,7 @@ describe OpportunitiesController do
|
|
105
105
|
|
106
106
|
describe "with mime type of XML" do
|
107
107
|
it "should render all opportunities as xml" do
|
108
|
-
@controller.should_receive(:
|
108
|
+
@controller.should_receive(:get_opportunities).and_return(opportunities = mock("Array of Opportunities"))
|
109
109
|
opportunities.should_receive(:to_xml).and_return("generated XML")
|
110
110
|
|
111
111
|
request.env["HTTP_ACCEPT"] = "application/xml"
|
@@ -144,7 +144,7 @@ describe OpportunitiesController do
|
|
144
144
|
describe "with mime type of JSON" do
|
145
145
|
it "should render the requested opportunity as JSON" do
|
146
146
|
@opportunity = FactoryGirl.create(:opportunity, :id => 42)
|
147
|
-
Opportunity.
|
147
|
+
Opportunity.should_receive(:find).and_return(@opportunity)
|
148
148
|
@opportunity.should_receive(:to_json).and_return("generated JSON")
|
149
149
|
|
150
150
|
request.env["HTTP_ACCEPT"] = "application/json"
|
@@ -156,7 +156,7 @@ describe OpportunitiesController do
|
|
156
156
|
describe "with mime type of XML" do
|
157
157
|
it "should render the requested opportunity as xml" do
|
158
158
|
@opportunity = FactoryGirl.create(:opportunity, :id => 42)
|
159
|
-
Opportunity.
|
159
|
+
Opportunity.should_receive(:find).and_return(@opportunity)
|
160
160
|
@opportunity.should_receive(:to_xml).and_return("generated XML")
|
161
161
|
|
162
162
|
request.env["HTTP_ACCEPT"] = "application/xml"
|
@@ -201,7 +201,6 @@ describe OpportunitiesController do
|
|
201
201
|
response.code.should == "404" # :not_found
|
202
202
|
end
|
203
203
|
end
|
204
|
-
|
205
204
|
end
|
206
205
|
|
207
206
|
# GET /opportunities/new
|
@@ -248,7 +247,6 @@ describe OpportunitiesController do
|
|
248
247
|
response.body.should == 'window.location.href = "/accounts";'
|
249
248
|
end
|
250
249
|
end
|
251
|
-
|
252
250
|
end
|
253
251
|
|
254
252
|
# GET /opportunities/1/edit AJAX
|
@@ -678,9 +676,7 @@ describe OpportunitiesController do
|
|
678
676
|
xhr :put, :update, :id => 42, :opportunity => { :name => nil }, :account => { :id => 99 }
|
679
677
|
assigns(:account).should == @account
|
680
678
|
end
|
681
|
-
|
682
679
|
end
|
683
|
-
|
684
680
|
end
|
685
681
|
|
686
682
|
# DELETE /opportunities/1
|
@@ -910,7 +906,7 @@ describe OpportunitiesController do
|
|
910
906
|
describe "responding to GET filter" do
|
911
907
|
|
912
908
|
it "should expose filtered opportunities as @opportunity and render [filter] template" do
|
913
|
-
session[:
|
909
|
+
session[:opportunities_filter] = "negotiation,analysis"
|
914
910
|
@opportunities = [ FactoryGirl.create(:opportunity, :stage => "prospecting", :user => @current_user) ]
|
915
911
|
@stage = Setting.unroll(:opportunity_stage)
|
916
912
|
|
@@ -927,8 +923,5 @@ describe OpportunitiesController do
|
|
927
923
|
|
928
924
|
session[:opportunities_current_page].should == 1
|
929
925
|
end
|
930
|
-
|
931
926
|
end
|
932
|
-
|
933
927
|
end
|
934
|
-
|