fat_free_crm 0.11.0 → 0.11.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of fat_free_crm might be problematic. Click here for more details.

Files changed (212) hide show
  1. data/.gitignore +1 -0
  2. data/.travis.yml +2 -2
  3. data/Gemfile +15 -2
  4. data/Gemfile.lock +34 -14
  5. data/README.md +37 -124
  6. data/app/assets/javascripts/application.js.erb +1 -1
  7. data/app/assets/javascripts/crm.js +22 -1
  8. data/app/assets/javascripts/crm_fields.js +2 -3
  9. data/app/assets/javascripts/jquery-noconflict.js +17 -0
  10. data/app/assets/stylesheets/application.css.erb +1 -0
  11. data/app/assets/stylesheets/common.scss +26 -0
  12. data/app/assets/stylesheets/ffcrm_chosen.scss +1 -1
  13. data/app/controllers/admin/application_controller.rb +1 -1
  14. data/app/controllers/application_controller.rb +0 -8
  15. data/app/controllers/{accounts_controller.rb → entities/accounts_controller.rb} +1 -13
  16. data/app/controllers/{campaigns_controller.rb → entities/campaigns_controller.rb} +1 -13
  17. data/app/controllers/{contacts_controller.rb → entities/contacts_controller.rb} +1 -7
  18. data/app/controllers/{leads_controller.rb → entities/leads_controller.rb} +1 -1
  19. data/app/controllers/{opportunities_controller.rb → entities/opportunities_controller.rb} +1 -7
  20. data/app/controllers/{tasks_controller.rb → entities/tasks_controller.rb} +1 -1
  21. data/app/controllers/{base_controller.rb → entities_controller.rb} +32 -1
  22. data/app/controllers/home_controller.rb +9 -9
  23. data/app/controllers/lists_controller.rb +17 -0
  24. data/app/helpers/admin/tags_helper.rb +1 -1
  25. data/app/helpers/application_helper.rb +14 -14
  26. data/app/helpers/crm_tags_helper.rb +1 -1
  27. data/app/helpers/home_helper.rb +13 -15
  28. data/app/helpers/lists_helper.rb +17 -0
  29. data/app/inputs/date_time_input.rb +17 -0
  30. data/app/inputs/text_input.rb +17 -1
  31. data/app/models/{base → entities}/account.rb +0 -1
  32. data/app/models/{base → entities}/account_contact.rb +0 -0
  33. data/app/models/{base → entities}/account_opportunity.rb +0 -0
  34. data/app/models/{base → entities}/campaign.rb +0 -1
  35. data/app/models/{base → entities}/contact.rb +0 -1
  36. data/app/models/{base → entities}/contact_opportunity.rb +0 -0
  37. data/app/models/{base → entities}/lead.rb +0 -1
  38. data/app/models/{base → entities}/opportunity.rb +0 -1
  39. data/app/models/{base → entities}/task.rb +5 -6
  40. data/app/models/list.rb +17 -0
  41. data/app/models/observers/lead_observer.rb +39 -0
  42. data/app/models/observers/opportunity_observer.rb +54 -0
  43. data/app/models/observers/task_observer.rb +41 -0
  44. data/app/models/polymorphic/address.rb +1 -3
  45. data/app/models/polymorphic/avatar.rb +0 -5
  46. data/app/models/polymorphic/comment.rb +2 -11
  47. data/app/models/polymorphic/email.rb +2 -9
  48. data/app/models/polymorphic/tag.rb +17 -0
  49. data/app/models/polymorphic/tagging.rb +17 -0
  50. data/app/models/users/ability.rb +13 -0
  51. data/app/models/users/user.rb +1 -4
  52. data/app/views/accounts/_account.html.haml +10 -6
  53. data/app/views/accounts/index.html.haml +1 -1
  54. data/app/views/accounts/show.html.haml +6 -24
  55. data/app/views/admin/fields/_field.html.haml +6 -6
  56. data/app/views/admin/tags/_tag.html.haml +2 -2
  57. data/app/views/admin/tags/index.html.haml +1 -1
  58. data/app/views/admin/users/_user.html.haml +3 -3
  59. data/app/views/admin/users/index.html.haml +1 -1
  60. data/app/views/campaigns/_campaign.html.haml +9 -5
  61. data/app/views/campaigns/index.html.haml +1 -1
  62. data/app/views/campaigns/show.html.haml +4 -24
  63. data/app/views/comments/_comment.html.haml +17 -14
  64. data/app/views/comments/_edit.html.haml +1 -1
  65. data/app/views/comments/_new.html.haml +3 -3
  66. data/app/views/contacts/_contact.html.haml +33 -15
  67. data/app/views/contacts/_contacts.html.haml +6 -0
  68. data/app/views/contacts/_sidebar_show.html.haml +1 -1
  69. data/app/views/contacts/index.html.haml +1 -1
  70. data/app/views/contacts/show.html.haml +3 -19
  71. data/app/views/emails/_email.html.haml +24 -21
  72. data/app/views/{base → entities}/_advanced_search.html.haml +0 -0
  73. data/app/views/{base → entities}/_condition_fields.html.haml +0 -0
  74. data/app/views/{base → entities}/_grouping_fields.html.haml +0 -0
  75. data/app/views/{base → entities}/_sort_fields.html.haml +0 -0
  76. data/app/views/{base → entities}/advanced_search.js.rjs +0 -0
  77. data/app/views/entities/contacts.js.rjs +3 -0
  78. data/app/views/entities/leads.js.rjs +3 -0
  79. data/app/views/entities/opportunities.js.rjs +3 -0
  80. data/app/views/entities/versions.js.rjs +3 -0
  81. data/app/views/home/_activity.html.haml +19 -18
  82. data/app/views/home/_events_menu.html.haml +8 -0
  83. data/app/views/home/_options.html.haml +2 -3
  84. data/app/views/home/index.html.haml +1 -1
  85. data/app/views/leads/_lead.html.haml +42 -23
  86. data/app/views/leads/_leads.html.haml +6 -0
  87. data/app/views/leads/_sidebar_show.html.haml +1 -1
  88. data/app/views/leads/index.html.haml +1 -1
  89. data/app/views/leads/show.html.haml +3 -13
  90. data/app/views/opportunities/_opportunities.html.haml +6 -0
  91. data/app/views/opportunities/_opportunity.html.haml +23 -11
  92. data/app/views/opportunities/index.html.haml +1 -1
  93. data/app/views/opportunities/show.html.haml +4 -18
  94. data/app/views/shared/_comment.html.haml +3 -3
  95. data/app/views/shared/_edit_comment.html.haml +1 -1
  96. data/app/views/shared/_recent.html.haml +4 -4
  97. data/app/views/shared/_recently.html.haml +3 -3
  98. data/app/views/shared/_timeline.html.haml +2 -3
  99. data/app/views/tasks/_assigned.html.haml +4 -4
  100. data/app/views/tasks/_completed.html.haml +2 -2
  101. data/app/views/tasks/_pending.html.haml +2 -2
  102. data/app/views/tasks/_related.html.haml +4 -5
  103. data/app/views/tasks/_tasks.html.haml +3 -0
  104. data/app/views/tasks/_title.html.haml +1 -1
  105. data/app/views/tasks/index.html.haml +1 -1
  106. data/app/views/users/_avatar.html.haml +2 -2
  107. data/app/views/versions/_version.html.haml +9 -12
  108. data/app/views/versions/_versions.html.haml +11 -0
  109. data/config/application.rb +3 -2
  110. data/config/environments/development.rb +2 -2
  111. data/config/environments/production.rb +0 -4
  112. data/config/environments/staging.rb +1 -1
  113. data/config/initializers/action_mailer.rb +9 -0
  114. data/config/initializers/paper_trail.rb +80 -0
  115. data/config/initializers/relative_url_root.rb +23 -0
  116. data/config/locales/cz_fat_free_crm.yml +1 -1
  117. data/config/locales/en-US_fat_free_crm.yml +22 -17
  118. data/config/locales/fr_fat_free_crm.yml +349 -134
  119. data/config/routes.rb +144 -140
  120. data/config/settings.default.yml +14 -2
  121. data/db/demo/addresses.yml +2 -2
  122. data/db/demo/emails.yml +2 -2
  123. data/db/migrate/20120216042541_is_paranoid_to_paper_trail.rb +1 -2
  124. data/db/migrate/20120309070209_add_versions_related.rb +6 -0
  125. data/db/migrate/20120316045804_activities_to_versions.rb +35 -0
  126. data/db/schema.rb +79 -53
  127. data/fat_free_crm.gemspec +8 -4
  128. data/lib/development_tasks/gem.rake +18 -1
  129. data/lib/development_tasks/license.rake +2 -4
  130. data/lib/development_tasks/rdoc.rake +17 -0
  131. data/lib/development_tasks/rspec.rake +17 -0
  132. data/lib/fat_free_crm.rb +20 -14
  133. data/lib/fat_free_crm/core_ext/array.rb +0 -27
  134. data/lib/fat_free_crm/dropbox.rb +11 -1
  135. data/lib/fat_free_crm/engine.rb +21 -3
  136. data/lib/fat_free_crm/gem_dependencies.rb +26 -0
  137. data/lib/fat_free_crm/gem_ext.rb +18 -1
  138. data/lib/fat_free_crm/gem_ext/active_record/schema_dumper.rb +18 -1
  139. data/lib/fat_free_crm/gem_ext/authlogic/session/cookies.rb +17 -0
  140. data/lib/fat_free_crm/gem_ext/rails/engine.rb +17 -0
  141. data/lib/fat_free_crm/gem_ext/rails/text_helper.rb +17 -0
  142. data/lib/fat_free_crm/gem_ext/rake/task.rb +17 -0
  143. data/lib/fat_free_crm/gem_ext/simple_form/action_view_extensions/form_helper.rb +18 -1
  144. data/lib/fat_free_crm/plugin_dependencies.rb +23 -5
  145. data/lib/fat_free_crm/renderers.rb +17 -0
  146. data/lib/fat_free_crm/syck_yaml.rb +17 -0
  147. data/lib/fat_free_crm/version.rb +1 -1
  148. data/lib/{country_select → plugins/country_select}/MIT-LICENSE +0 -0
  149. data/lib/{country_select → plugins/country_select}/README +0 -0
  150. data/lib/{country_select → plugins/country_select}/init.rb +0 -0
  151. data/lib/{country_select → plugins/country_select}/install.rb +0 -0
  152. data/lib/{country_select → plugins/country_select}/lib/country_select.rb +0 -0
  153. data/lib/{country_select → plugins/country_select}/uninstall.rb +0 -0
  154. data/lib/{gravatar_image_tag → plugins/gravatar_image_tag}/Gemfile +0 -0
  155. data/lib/{gravatar_image_tag → plugins/gravatar_image_tag}/README.textile +0 -0
  156. data/lib/{gravatar_image_tag → plugins/gravatar_image_tag}/ROADMAP.textile +0 -0
  157. data/lib/{gravatar_image_tag → plugins/gravatar_image_tag}/Rakefile +0 -0
  158. data/lib/{gravatar_image_tag → plugins/gravatar_image_tag}/VERSION +0 -0
  159. data/lib/{gravatar_image_tag → plugins/gravatar_image_tag}/gravatar_image_tag.gemspec +0 -0
  160. data/lib/{gravatar_image_tag → plugins/gravatar_image_tag}/init.rb +0 -0
  161. data/lib/{gravatar_image_tag → plugins/gravatar_image_tag}/lib/gravatar_image_tag.rb +0 -0
  162. data/lib/{gravatar_image_tag → plugins/gravatar_image_tag}/spec/gravatar_image_tag_spec.rb +0 -0
  163. data/lib/{gravatar_image_tag → plugins/gravatar_image_tag}/spec/test_helper.rb +0 -0
  164. data/lib/tasks/demo.rake +32 -29
  165. data/lib/tasks/dropbox.rake +1 -1
  166. data/lib/tasks/fat_free_crm.rake +3 -2
  167. data/lib/tasks/plugins.rake +1 -0
  168. data/spec/controllers/accounts_controller_spec.rb +7 -5
  169. data/spec/controllers/campaigns_controller_spec.rb +11 -9
  170. data/spec/controllers/contacts_controller_spec.rb +7 -5
  171. data/spec/controllers/home_controller_spec.rb +2 -2
  172. data/spec/controllers/leads_controller_spec.rb +7 -5
  173. data/spec/controllers/opportunities_controller_spec.rb +7 -5
  174. data/spec/factories/shared_factories.rb +8 -11
  175. data/spec/lib/dropbox_spec.rb +1 -0
  176. data/spec/models/polymorphic/version_spec.rb +247 -0
  177. data/spec/models/users/user_spec.rb +0 -9
  178. data/spec/spec_helper.rb +4 -0
  179. data/spec/views/home/index.haml_spec.rb +1 -1
  180. data/spec/views/home/index.rjs_spec.rb +4 -4
  181. data/spec/views/tasks/new.rjs_spec.rb +2 -2
  182. data/vendor/assets/javascripts/calendar_date_select/format_french.js +24 -0
  183. metadata +167 -126
  184. data/app/models/observers/activity_observer.rb +0 -84
  185. data/app/models/polymorphic/activity.rb +0 -106
  186. data/app/views/accounts/contacts.js.rjs +0 -3
  187. data/app/views/accounts/opportunities.js.rjs +0 -3
  188. data/app/views/campaigns/leads.js.rjs +0 -3
  189. data/app/views/campaigns/opportunities.js.rjs +0 -3
  190. data/app/views/contacts/opportunities.js.rjs +0 -3
  191. data/app/views/home/_actions_menu.html.haml +0 -8
  192. data/lib/dynamic_form/MIT-LICENSE +0 -20
  193. data/lib/dynamic_form/README +0 -13
  194. data/lib/dynamic_form/Rakefile +0 -10
  195. data/lib/dynamic_form/dynamic_form.gemspec +0 -12
  196. data/lib/dynamic_form/init.rb +0 -2
  197. data/lib/dynamic_form/lib/action_view/helpers/dynamic_form.rb +0 -301
  198. data/lib/dynamic_form/lib/action_view/locale/en-US.yml +0 -8
  199. data/lib/dynamic_form/lib/dynamic_form.rb +0 -6
  200. data/lib/dynamic_form/test/dynamic_form_i18n_test.rb +0 -42
  201. data/lib/dynamic_form/test/dynamic_form_test.rb +0 -370
  202. data/lib/dynamic_form/test/test_helper.rb +0 -10
  203. data/lib/responds_to_parent/MIT-LICENSE +0 -20
  204. data/lib/responds_to_parent/README +0 -47
  205. data/lib/responds_to_parent/Rakefile +0 -22
  206. data/lib/responds_to_parent/init.rb +0 -2
  207. data/lib/responds_to_parent/install.rb +0 -2
  208. data/lib/responds_to_parent/lib/responds_to_parent.rb +0 -70
  209. data/lib/responds_to_parent/test/responds_to_parent_test.rb +0 -11
  210. data/lib/responds_to_parent/test/test_helper.rb +0 -7
  211. data/lib/responds_to_parent/uninstall.rb +0 -2
  212. data/spec/models/polymorphic/activity_spec.rb +0 -303
@@ -1,3 +1,20 @@
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
+
1
18
  #
2
19
  # Removes simple_form's css class logic.
3
20
  module SimpleForm
@@ -10,7 +27,7 @@ module SimpleForm
10
27
  options[:html][:novalidate] = !SimpleForm.browser_validations
11
28
  end
12
29
 
13
- with_custom_field_error_proc do
30
+ with_simple_form_field_error_proc do
14
31
  form_for(record, options, &block)
15
32
  end
16
33
  end
@@ -1,6 +1,24 @@
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
+
1
18
  # Plugin dependencies
2
- %w(country_select dynamic_form gravatar_image_tag responds_to_parent).each do |plugin|
3
- $:.unshift File.join(File.dirname(__FILE__), '..', plugin, 'lib')
4
- require plugin
5
- require File.join(plugin, 'init')
6
- end
19
+ Dir.glob(File.join(File.dirname(__FILE__), '..', 'plugins', '**')).each do |plugin_dir|
20
+ # Add 'plugin/lib' to $LOAD_PATH
21
+ $:.unshift File.expand_path(File.join(plugin_dir, 'lib'))
22
+ require File.basename(plugin_dir) # require 'plugin'
23
+ require File.join(plugin_dir, 'init') # require 'plugin/init'
24
+ end
@@ -1,3 +1,20 @@
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
+
1
18
  ActionController::Renderers.add :csv do |obj, options|
2
19
  filename = options[:filename] || 'data'
3
20
  str = obj.respond_to?(:to_csv) ? obj.to_csv : obj.to_s
@@ -1,3 +1,20 @@
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
+
1
18
  if RUBY_VERSION.to_f >= 1.9
2
19
  require 'yaml'
3
20
  YAML::ENGINE.yamler = 'syck'
@@ -19,7 +19,7 @@ module FatFreeCRM
19
19
  module VERSION #:nodoc:
20
20
  MAJOR = 0
21
21
  MINOR = 11
22
- TINY = 0
22
+ TINY = 1
23
23
  PRE = nil
24
24
 
25
25
  STRING = [MAJOR, MINOR, TINY, PRE].compact.join('.')
@@ -26,39 +26,42 @@ namespace :ffcrm do
26
26
  ActiveRecord::Fixtures.create_fixtures(FatFreeCRM.root.join('db/demo'), File.basename(fixture_file, '.*'))
27
27
  end
28
28
 
29
+ def create_version(options)
30
+ version = Version.new
31
+ options.each { |k,v| version.send(k.to_s + '=', v) }
32
+ version.save!
33
+ end
34
+
29
35
  # Simulate random user activities.
30
36
  $stdout.sync = true
31
37
  puts "Generating user activities..."
32
- %w(Account Campaign Contact Lead Opportunity Task).map do |model|
33
- model.constantize.send(:find, :all)
34
- end.flatten.shuffle.each do |subject|
35
- info = subject.respond_to?(:full_name) ? subject.full_name : subject.name
36
- Activity.create(:action => "created", :created_at => subject.updated_at, :user => subject.user, :subject => subject, :info => info)
37
- Activity.create(:action => "updated", :created_at => subject.updated_at, :user => subject.user, :subject => subject, :info => info)
38
- unless subject.is_a?(Task)
39
- time = subject.updated_at + rand(12 * 60).minutes
40
- Activity.create(:action => "viewed", :created_at => time, :user => subject.user, :subject => subject, :info => info)
41
- comments = Comment.where(:commentable_id => subject.id, :commentable_type => subject.class.name)
42
- comments.each_with_index do |comment, i|
43
- time = subject.created_at + rand(12 * 60 * i).minutes
44
- if time > Time.now
45
- time = subject.created_at + rand(600).minutes
46
- end
47
- comment.update_attribute(:created_at, time)
48
- Activity.create(:action => "commented", :created_at => time, :user => comment.user, :subject => subject, :info => info)
49
- end
50
- emails = Email.where(:mediator_id => subject.id, :mediator_type => subject.class.name)
51
- emails.each do |email|
52
- time = subject.created_at + rand(24 * 60).minutes
53
- if time > Time.now
54
- time = subject.created_at + rand(600).minutes
55
- end
56
- sent_at = time - rand(600).minutes
57
- received_at = sent_at + rand(600).seconds
58
- email.update_attributes(:created_at => time, :sent_at => sent_at, :received_at => received_at)
59
- end
38
+ %w(Account Address Campaign Comment Contact Email Lead Opportunity Task).map do |model|
39
+ model.constantize.all
40
+ end.flatten.each do |item|
41
+ user = if item.respond_to?(:user)
42
+ item.user
43
+ elsif item.respond_to?(:addressable)
44
+ item.addressable.try(:user)
45
+ end
46
+ related = if item.respond_to?(:addressable)
47
+ item.addressable
48
+ elsif item.respond_to?(:commentable)
49
+ item.commentable
50
+ elsif item.respond_to?(:mediator)
51
+ item.mediator
52
+ end
53
+ # Backdate within the last 30 days
54
+ created_at = item.created_at - (rand(30) + 1).days + rand(12 * 60).minutes
55
+ updated_at = created_at + rand(12 * 60).minutes
56
+
57
+ create_version(:event => "create", :created_at => created_at, :user => user, :item => item, :related => related)
58
+ create_version(:event => "update", :created_at => updated_at, :user => user, :item => item, :related => related)
59
+
60
+ if [Account, Campaign, Contact, Lead, Opportunity].include?(item.class)
61
+ viewed_at = created_at + rand(12 * 60).minutes
62
+ version = create_version(:event => "view", :created_at => viewed_at, :user => user, :item => item)
60
63
  end
61
- print "." if subject.id % 10 == 0
64
+ print "." if item.id % 10 == 0
62
65
  end
63
66
  puts
64
67
  end
@@ -29,4 +29,4 @@ namespace :ffcrm do
29
29
  crawler.setup
30
30
  end
31
31
  end
32
- end
32
+ end
@@ -72,7 +72,7 @@ namespace :ffcrm do
72
72
  # Migrating plugins is not part of Rails 3 yet, but it is coming. See
73
73
  # https://rails.lighthouseapp.com/projects/8994/tickets/2058 for details.
74
74
  Rake::Task["db:migrate:plugins"].invoke rescue nil
75
- Rake::Task["setup:admin"].invoke
75
+ Rake::Task["ffcrm:setup:admin"].invoke
76
76
  end
77
77
 
78
78
  namespace :setup do
@@ -124,7 +124,8 @@ namespace :ffcrm do
124
124
  user = User.find_by_username(username) || User.new
125
125
  user.update_attributes(:username => username, :password => password, :email => email)
126
126
  user.update_attribute(:admin, true) # Mass assignments don't work for :admin because of the attr_protected
127
+ user.update_attribute(:suspended_at, nil) # Mass assignments don't work for :suspended_at because of the attr_protected
127
128
  puts "Admin user has been created."
128
129
  end
129
130
  end
130
- end
131
+ end
@@ -14,6 +14,7 @@
14
14
  # You should have received a copy of the GNU Affero General Public License
15
15
  # along with this program. If not, see <http://www.gnu.org/licenses/>.
16
16
  #------------------------------------------------------------------------------
17
+
17
18
  Rake::Task.remove("db:migrate:status") # (Clears task so that it can be extended)
18
19
 
19
20
  namespace :db do
@@ -122,15 +122,16 @@ describe AccountsController do
122
122
  end
123
123
 
124
124
  it "should update an activity when viewing the account" do
125
- Activity.should_receive(:log).with(@current_user, @account, :viewed).once
126
125
  get :show, :id => @account.id
126
+ @account.versions.last.event.should == 'view'
127
127
  end
128
128
  end
129
129
 
130
130
  describe "with mime type of JSON" do
131
131
  it "should render the requested account as json" do
132
- Account.stub_chain(:my, :find).and_return(account = mock_model(Account, :name => ''))
133
- account.should_receive(:to_json).and_return("generated JSON")
132
+ @account = FactoryGirl.create(:account, :user => @current_user)
133
+ Account.stub_chain(:my, :find).and_return(@account)
134
+ @account.should_receive(:to_json).and_return("generated JSON")
134
135
 
135
136
  request.env["HTTP_ACCEPT"] = "application/json"
136
137
  get :show, :id => 42
@@ -140,8 +141,9 @@ describe AccountsController do
140
141
 
141
142
  describe "with mime type of XML" do
142
143
  it "should render the requested account as xml" do
143
- Account.stub_chain(:my, :find).and_return(account = mock_model(Account, :name => ''))
144
- account.should_receive(:to_xml).and_return("generated XML")
144
+ @account = FactoryGirl.create(:account, :user => @current_user)
145
+ Account.stub_chain(:my, :find).and_return(@account)
146
+ @account.should_receive(:to_xml).and_return("generated XML")
145
147
 
146
148
  request.env["HTTP_ACCEPT"] = "application/xml"
147
149
  get :show, :id => 42
@@ -85,8 +85,8 @@ 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(:get_list_of_records).and_return(campaigns = mock("Array of Campaigns"))
89
- campaigns.should_receive(:to_json).and_return("generated JSON")
88
+ @controller.should_receive(:get_list_of_records).and_return(@campaigns = [])
89
+ @campaigns.should_receive(:to_json).and_return("generated JSON")
90
90
 
91
91
  request.env["HTTP_ACCEPT"] = "application/json"
92
92
  get :index
@@ -96,8 +96,8 @@ 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(:get_list_of_records).and_return(campaigns = mock("Array of Campaigns"))
100
- campaigns.should_receive(:to_xml).and_return("generated XML")
99
+ @controller.should_receive(:get_list_of_records).and_return(@campaigns = [])
100
+ @campaigns.should_receive(:to_xml).and_return("generated XML")
101
101
 
102
102
  request.env["HTTP_ACCEPT"] = "application/xml"
103
103
  get :index
@@ -127,15 +127,16 @@ describe CampaignsController do
127
127
  end
128
128
 
129
129
  it "should update an activity when viewing the campaign" do
130
- Activity.should_receive(:log).with(@current_user, @campaign, :viewed).once
131
130
  get :show, :id => @campaign.id
131
+ @campaign.versions.last.event.should == 'view'
132
132
  end
133
133
  end
134
134
 
135
135
  describe "with mime type of JSON" do
136
136
  it "should render the requested campaign as JSON" do
137
- Campaign.stub_chain(:my, :find).and_return(campaign = mock_model(Campaign, :name => ''))
138
- campaign.should_receive(:to_json).and_return("generated JSON")
137
+ @campaign = FactoryGirl.create(:campaign, :id => 42, :user => @current_user)
138
+ Campaign.stub_chain(:my, :find).and_return(@campaign)
139
+ @campaign.should_receive(:to_json).and_return("generated JSON")
139
140
 
140
141
  request.env["HTTP_ACCEPT"] = "application/json"
141
142
  get :show, :id => 42
@@ -145,8 +146,9 @@ describe CampaignsController do
145
146
 
146
147
  describe "with mime type of XML" do
147
148
  it "should render the requested campaign as XML" do
148
- Campaign.stub_chain(:my, :find).and_return(campaign = mock_model(Campaign, :name => ''))
149
- campaign.should_receive(:to_xml).and_return("generated XML")
149
+ @campaign = FactoryGirl.create(:campaign, :id => 42, :user => @current_user)
150
+ Campaign.stub_chain(:my, :find).and_return(@campaign)
151
+ @campaign.should_receive(:to_xml).and_return("generated XML")
150
152
 
151
153
  request.env["HTTP_ACCEPT"] = "application/xml"
152
154
  get :show, :id => 42
@@ -95,15 +95,16 @@ describe ContactsController do
95
95
  end
96
96
 
97
97
  it "should update an activity when viewing the contact" do
98
- Activity.should_receive(:log).with(@current_user, @contact, :viewed).once
99
98
  get :show, :id => @contact.id
99
+ @contact.versions.last.event.should == 'view'
100
100
  end
101
101
  end
102
102
 
103
103
  describe "with mime type of JSON" do
104
104
  it "should render the requested contact as JSON" do
105
- Contact.stub_chain(:my, :find).and_return(contact = mock_model(Contact, :name => ''))
106
- contact.should_receive(:to_json).and_return("generated JSON")
105
+ @contact = FactoryGirl.create(:contact, :id => 42)
106
+ Contact.stub_chain(:my, :find).and_return(@contact)
107
+ @contact.should_receive(:to_json).and_return("generated JSON")
107
108
 
108
109
  request.env["HTTP_ACCEPT"] = "application/json"
109
110
  get :show, :id => 42
@@ -113,8 +114,9 @@ describe ContactsController do
113
114
 
114
115
  describe "with mime type of XML" do
115
116
  it "should render the requested contact as xml" do
116
- Contact.stub_chain(:my, :find).and_return(contact = mock_model(Contact, :name => ''))
117
- contact.should_receive(:to_xml).and_return("generated XML")
117
+ @contact = FactoryGirl.create(:contact, :id => 42)
118
+ Contact.stub_chain(:my, :find).and_return(@contact)
119
+ @contact.should_receive(:to_xml).and_return("generated XML")
118
120
 
119
121
  request.env["HTTP_ACCEPT"] = "application/xml"
120
122
  get :show, :id => 42
@@ -10,7 +10,7 @@ describe HomeController do
10
10
  end
11
11
 
12
12
  it "should get a list of activities" do
13
- @activity = FactoryGirl.create(:activity, :subject => FactoryGirl.create(:account, :user => @current_user))
13
+ @activity = FactoryGirl.create(:version, :item => FactoryGirl.create(:account, :user => @current_user))
14
14
  controller.should_receive(:get_activities).once.and_return([ @activity ])
15
15
 
16
16
  get :index
@@ -69,7 +69,7 @@ describe HomeController do
69
69
  end
70
70
 
71
71
  it "should get a list of activities" do
72
- @activity = FactoryGirl.create(:activity, :subject => FactoryGirl.create(:account, :user => @current_user))
72
+ @activity = FactoryGirl.create(:version, :item => FactoryGirl.create(:account, :user => @current_user))
73
73
  controller.should_receive(:get_activities).once.and_return([ @activity ])
74
74
 
75
75
  get :index
@@ -118,15 +118,16 @@ describe LeadsController do
118
118
  end
119
119
 
120
120
  it "should update an activity when viewing the lead" do
121
- Activity.should_receive(:log).with(@current_user, @lead, :viewed).once
122
121
  get :show, :id => @lead.id
122
+ @lead.versions.last.event.should == 'view'
123
123
  end
124
124
  end
125
125
 
126
126
  describe "with mime type of JSON" do
127
127
  it "should render the requested lead as JSON" do
128
- Lead.stub_chain(:my, :find).and_return(lead = mock_model(Lead, :name => ''))
129
- lead.should_receive(:to_json).and_return("generated JSON")
128
+ @lead = FactoryGirl.create(:lead, :id => 42, :user => @current_user)
129
+ Lead.stub_chain(:my, :find).and_return(@lead)
130
+ @lead.should_receive(:to_json).and_return("generated JSON")
130
131
 
131
132
  request.env["HTTP_ACCEPT"] = "application/json"
132
133
  get :show, :id => 42
@@ -136,8 +137,9 @@ describe LeadsController do
136
137
 
137
138
  describe "with mime type of XML" do
138
139
  it "should render the requested lead as xml" do
139
- Lead.stub_chain(:my, :find).and_return(lead = mock_model(Lead, :name => ''))
140
- lead.should_receive(:to_xml).and_return("generated XML")
140
+ @lead = FactoryGirl.create(:lead, :id => 42, :user => @current_user)
141
+ Lead.stub_chain(:my, :find).and_return(@lead)
142
+ @lead.should_receive(:to_xml).and_return("generated XML")
141
143
 
142
144
  request.env["HTTP_ACCEPT"] = "application/xml"
143
145
  get :show, :id => 42
@@ -136,15 +136,16 @@ describe OpportunitiesController do
136
136
  end
137
137
 
138
138
  it "should update an activity when viewing the opportunity" do
139
- Activity.should_receive(:log).with(@current_user, @opportunity, :viewed).once
140
139
  get :show, :id => @opportunity.id
140
+ @opportunity.versions.last.event.should == 'view'
141
141
  end
142
142
  end
143
143
 
144
144
  describe "with mime type of JSON" do
145
145
  it "should render the requested opportunity as JSON" do
146
- Opportunity.stub_chain(:my, :find).and_return(opportunity = mock_model(Opportunity, :name => ''))
147
- opportunity.should_receive(:to_json).and_return("generated JSON")
146
+ @opportunity = FactoryGirl.create(:opportunity, :id => 42)
147
+ Opportunity.stub_chain(:my, :find).and_return(@opportunity)
148
+ @opportunity.should_receive(:to_json).and_return("generated JSON")
148
149
 
149
150
  request.env["HTTP_ACCEPT"] = "application/json"
150
151
  get :show, :id => 42
@@ -154,8 +155,9 @@ describe OpportunitiesController do
154
155
 
155
156
  describe "with mime type of XML" do
156
157
  it "should render the requested opportunity as xml" do
157
- Opportunity.stub_chain(:my, :find).and_return(opportunity = mock_model(Opportunity, :name => ''))
158
- opportunity.should_receive(:to_xml).and_return("generated XML")
158
+ @opportunity = FactoryGirl.create(:opportunity, :id => 42)
159
+ Opportunity.stub_chain(:my, :find).and_return(@opportunity)
160
+ @opportunity.should_receive(:to_xml).and_return("generated XML")
159
161
 
160
162
  request.env["HTTP_ACCEPT"] = "application/xml"
161
163
  get :show, :id => 42