alchemy_crm 2.0.1 → 2.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (123) hide show
  1. data/Gemfile +10 -11
  2. data/alchemy_crm.gemspec +21 -21
  3. data/app/assets/javascripts/alchemy_crm/alchemy_crm.base.js +54 -54
  4. data/app/assets/stylesheets/alchemy_crm/base.css.scss +199 -199
  5. data/app/controllers/alchemy_crm/admin/base_controller.rb +5 -5
  6. data/app/controllers/alchemy_crm/admin/contact_groups_controller.rb +15 -15
  7. data/app/controllers/alchemy_crm/admin/contacts_controller.rb +95 -95
  8. data/app/controllers/alchemy_crm/admin/deliveries_controller.rb +66 -66
  9. data/app/controllers/alchemy_crm/admin/elements_controller_extension.rb +23 -23
  10. data/app/controllers/alchemy_crm/admin/mailings_controller.rb +44 -44
  11. data/app/controllers/alchemy_crm/admin/newsletters_controller.rb +16 -16
  12. data/app/controllers/alchemy_crm/admin/tags_controller.rb +60 -59
  13. data/app/controllers/alchemy_crm/base_controller.rb +3 -3
  14. data/app/controllers/alchemy_crm/contacts_controller.rb +88 -88
  15. data/app/controllers/alchemy_crm/mailings_controller.rb +16 -16
  16. data/app/controllers/alchemy_crm/recipients_controller.rb +30 -30
  17. data/app/controllers/alchemy_crm/subscriptions_controller.rb +54 -54
  18. data/app/helpers/alchemy/pages_helper_extension.rb +14 -14
  19. data/app/helpers/alchemy_crm/admin/base_helper.rb +8 -8
  20. data/app/helpers/alchemy_crm/mailings_helper.rb +175 -175
  21. data/app/mailers/alchemy_crm/bounce_receiver.rb +9 -9
  22. data/app/mailers/alchemy_crm/contacts_mailer.rb +21 -21
  23. data/app/mailers/alchemy_crm/mailings_mailer.rb +46 -46
  24. data/app/mailers/alchemy_crm/subscriptions_mailer.rb +12 -12
  25. data/app/models/alchemy/essence_element_teaser.rb +14 -14
  26. data/app/models/alchemy_crm/contact.rb +260 -260
  27. data/app/models/alchemy_crm/contact_group.rb +15 -15
  28. data/app/models/alchemy_crm/contact_group_filter.rb +17 -17
  29. data/app/models/alchemy_crm/delivery.rb +54 -54
  30. data/app/models/alchemy_crm/element_extension.rb +23 -23
  31. data/app/models/alchemy_crm/mailing.rb +90 -90
  32. data/app/models/alchemy_crm/newsletter.rb +33 -33
  33. data/app/models/alchemy_crm/reaction.rb +5 -5
  34. data/app/models/alchemy_crm/recipient.rb +46 -46
  35. data/app/models/alchemy_crm/subscription.rb +4 -4
  36. data/app/views/alchemy/admin/elements/fill.js.erb +11 -11
  37. data/app/views/alchemy/elements/_newsletter_article_view.html.erb +14 -14
  38. data/app/views/alchemy/elements/_newsletter_greeting_view.html.erb +9 -9
  39. data/app/views/alchemy/elements/_newsletter_signout_form_view.html.erb +18 -18
  40. data/app/views/alchemy/elements/_newsletter_signup_form_view.html.erb +62 -62
  41. data/app/views/alchemy/essences/_essence_element_teaser_editor.html.erb +29 -29
  42. data/app/views/alchemy/newsletter_layouts/_standard.html.erb +37 -37
  43. data/app/views/alchemy_crm/admin/contact_groups/_contact_group.html.erb +30 -30
  44. data/app/views/alchemy_crm/admin/contact_groups/_filter.html.erb +28 -28
  45. data/app/views/alchemy_crm/admin/contact_groups/_form.html.erb +45 -45
  46. data/app/views/alchemy_crm/admin/contact_groups/_tag.html.erb +4 -4
  47. data/app/views/alchemy_crm/admin/contact_groups/add_filter.js.erb +7 -7
  48. data/app/views/alchemy_crm/admin/contact_groups/index.html.erb +28 -28
  49. data/app/views/alchemy_crm/admin/contacts/_contact.html.erb +42 -42
  50. data/app/views/alchemy_crm/admin/contacts/_form.html.erb +76 -76
  51. data/app/views/alchemy_crm/admin/contacts/import.html.erb +27 -27
  52. data/app/views/alchemy_crm/admin/contacts/index.html.erb +39 -39
  53. data/app/views/alchemy_crm/admin/contacts/vcf_import_result.html.erb +24 -24
  54. data/app/views/alchemy_crm/admin/deliveries/_delivery.html.erb +30 -30
  55. data/app/views/alchemy_crm/admin/deliveries/_form.html.erb +61 -61
  56. data/app/views/alchemy_crm/admin/deliveries/_recipient.html.erb +36 -36
  57. data/app/views/alchemy_crm/admin/deliveries/index.html.erb +21 -21
  58. data/app/views/alchemy_crm/admin/deliveries/show.html.erb +61 -61
  59. data/app/views/alchemy_crm/admin/elements/teasables.html.erb +53 -53
  60. data/app/views/alchemy_crm/admin/mailings/_form.html.erb +41 -41
  61. data/app/views/alchemy_crm/admin/mailings/_mailing.html.erb +73 -73
  62. data/app/views/alchemy_crm/admin/mailings/edit_content.html.erb +170 -170
  63. data/app/views/alchemy_crm/admin/mailings/import_result.html.erb +18 -18
  64. data/app/views/alchemy_crm/admin/mailings/index.html.erb +25 -25
  65. data/app/views/alchemy_crm/admin/newsletters/_form.html.erb +52 -52
  66. data/app/views/alchemy_crm/admin/newsletters/_tag_with_radiobutton.html.erb +5 -5
  67. data/app/views/alchemy_crm/admin/newsletters/index.html.erb +29 -29
  68. data/app/views/alchemy_crm/admin/newsletters/new.html.erb +4 -4
  69. data/app/views/alchemy_crm/admin/tags/_radio_tag.html.erb +4 -4
  70. data/app/views/alchemy_crm/admin/tags/_tag.html.erb +30 -30
  71. data/app/views/alchemy_crm/admin/tags/edit.html.erb +32 -32
  72. data/app/views/alchemy_crm/admin/tags/index.html.erb +23 -23
  73. data/app/views/alchemy_crm/admin/tags/new.html.erb +14 -14
  74. data/app/views/alchemy_crm/contacts_mailer/signout_mail.html.erb +6 -6
  75. data/app/views/alchemy_crm/contacts_mailer/signout_mail.text.erb +2 -2
  76. data/app/views/alchemy_crm/contacts_mailer/signup_mail.html.erb +9 -9
  77. data/app/views/alchemy_crm/contacts_mailer/signup_mail.text.erb +2 -2
  78. data/app/views/alchemy_crm/mailings_mailer/verification_mail.html.erb +9 -9
  79. data/app/views/alchemy_crm/subscriptions/index.html.erb +4 -4
  80. data/app/views/alchemy_crm/subscriptions_mailer/overview_mail.html.erb +25 -25
  81. data/app/views/alchemy_crm/subscriptions_mailer/overview_mail.text.erb +2 -2
  82. data/app/views/csv_magic/import_errors.html.erb +23 -23
  83. data/app/views/csv_magic/mapper.html.erb +46 -46
  84. data/app/views/layouts/alchemy_crm/mailings.html.erb +177 -177
  85. data/config/initializers/assets.rb +2 -2
  86. data/config/locales/alchemy_crm.de.yml +1 -1
  87. data/config/locales/alchemy_crm.en.yml +1 -0
  88. data/config/locales/localized_country_select.de.rb +260 -260
  89. data/config/locales/localized_country_select.en.rb +274 -274
  90. data/config/routes.rb +67 -67
  91. data/db/migrate/20111104125306_remove_sent_mailing_pdf_id_from_sent_mailings.rb +1 -1
  92. data/db/migrate/20111124145923_namespace_alchemy_crm_models.rb +13 -13
  93. data/db/migrate/20120307160721_rename_alchemy_crm_recipients_sent_mailing_id.rb +3 -3
  94. data/db/migrate/20120320103412_add_indexes_to_alchemy_crm_sha1_columns.rb +3 -3
  95. data/db/migrate/20120327174301_add_more_indexes_to_alchemy_crm_tables.rb +10 -10
  96. data/lib/alchemy_crm.rb +15 -15
  97. data/lib/alchemy_crm/bounced_delivery.rb +38 -38
  98. data/lib/alchemy_crm/config.rb +25 -25
  99. data/lib/alchemy_crm/engine.rb +31 -31
  100. data/lib/alchemy_crm/i18n_helpers.rb +28 -28
  101. data/lib/alchemy_crm/newsletter_layout.rb +28 -28
  102. data/lib/alchemy_crm/seeder.rb +26 -26
  103. data/lib/alchemy_crm/version.rb +1 -1
  104. data/lib/generators/alchemy_crm/scaffold/files/newsletters.html.erb +19 -19
  105. data/lib/generators/alchemy_crm/scaffold/scaffold_generator.rb +2 -2
  106. data/lib/tasks/alchemy_crm.rake +22 -22
  107. data/lib/tasks/routes.rake +25 -25
  108. data/spec/config_spec.rb +24 -24
  109. data/spec/controllers/alchemy_crm/contacts_controller_spec.rb +147 -147
  110. data/spec/controllers/alchemy_crm/mailings_controller_spec.rb +62 -62
  111. data/spec/controllers/alchemy_crm/recipients_controller_spec.rb +109 -109
  112. data/spec/helpers/alchemy_crm/mailings_helper_spec.rb +165 -165
  113. data/spec/mailers/alchemy_crm/contacts_mailer_spec.rb +84 -84
  114. data/spec/mailers/alchemy_crm/mailings_mailer_spec.rb +29 -29
  115. data/spec/models/alchemy_crm/contact_group_spec.rb +25 -25
  116. data/spec/models/alchemy_crm/contact_spec.rb +71 -71
  117. data/spec/models/alchemy_crm/delivery_spec.rb +43 -39
  118. data/spec/models/alchemy_crm/mailing_spec.rb +46 -42
  119. data/spec/models/alchemy_crm/newsletter_spec.rb +29 -29
  120. data/spec/spec_helper.rb +36 -36
  121. metadata +6 -8
  122. data/rails/init.rb +0 -1
  123. data/recipes/alchemy-mailings-capistrano-tasks.rb +0 -12
@@ -1,35 +1,35 @@
1
1
  module AlchemyCrm
2
- module I18nHelpers
2
+ module I18nHelpers
3
3
 
4
- def self.included(controller)
5
- controller.send(:helper_method, [:i18n_t, :translate_model_attribute, :alchemy_crm_t])
6
- end
4
+ def self.included(controller)
5
+ controller.send(:helper_method, [:i18n_t, :translate_model_attribute, :alchemy_crm_t])
6
+ end
7
7
 
8
- # This is a proxy to the ::I18n.t method with an alchem_crm scope.
9
- #
10
- # We can't use +t+ in views, because Alchemy overrides it and scopes everything into the +alchemy+ namespace.
11
- #
12
- # === NOTE:
13
- #
14
- # The keys are scoped into +alchemy_crm+ namespace.
15
- # Even if you pass a scope this is scoped under +alchemy_crm+.
16
- #
17
- def alchemy_crm_t(key, options={})
18
- scope = options[:scope].blank? ? 'alchemy_crm' : "alchemy_crm.#{options.delete(:scope)}"
19
- ::I18n.t(key, {:scope => scope, :default => key.to_s.humanize}.merge(options))
20
- end
8
+ # This is a proxy to the ::I18n.t method with an alchem_crm scope.
9
+ #
10
+ # We can't use +t+ in views, because Alchemy overrides it and scopes everything into the +alchemy+ namespace.
11
+ #
12
+ # === NOTE:
13
+ #
14
+ # The keys are scoped into +alchemy_crm+ namespace.
15
+ # Even if you pass a scope this is scoped under +alchemy_crm+.
16
+ #
17
+ def alchemy_crm_t(key, options={})
18
+ scope = options[:scope].blank? ? 'alchemy_crm' : "alchemy_crm.#{options.delete(:scope)}"
19
+ ::I18n.t(key, {:scope => scope, :default => key.to_s.humanize}.merge(options))
20
+ end
21
21
 
22
- # This is a proxy to the ::I18n.t method without any scope.
23
- #
24
- # We can't use +t+ in views, because Alchemy overrides it and scopes everything into the +alchemy+ namespace.
25
- #
26
- def i18n_t(key, options={})
27
- ::I18n.t(key, options.merge(:default => key.to_s.humanize))
28
- end
22
+ # This is a proxy to the ::I18n.t method without any scope.
23
+ #
24
+ # We can't use +t+ in views, because Alchemy overrides it and scopes everything into the +alchemy+ namespace.
25
+ #
26
+ def i18n_t(key, options={})
27
+ ::I18n.t(key, options.merge(:default => key.to_s.humanize))
28
+ end
29
29
 
30
- def translate_model_attribute(model, key)
31
- "alchemy_crm/#{model.to_s.underscore}".classify.constantize.human_attribute_name(key)
32
- end
30
+ def translate_model_attribute(model, key)
31
+ "alchemy_crm/#{model.to_s.underscore}".classify.constantize.human_attribute_name(key)
32
+ end
33
33
 
34
- end
34
+ end
35
35
  end
@@ -1,40 +1,40 @@
1
1
  module AlchemyCrm
2
- class NewsletterLayout
2
+ class NewsletterLayout
3
3
 
4
- def self.get_layouts_for_select()
5
- all
6
- @@newsletter_layouts.map do |l|
7
- [display_name_for(l["name"]), l["name"]]
8
- end
9
- end
4
+ def self.get_layouts_for_select()
5
+ all
6
+ @@newsletter_layouts.map do |l|
7
+ [display_name_for(l["name"]), l["name"]]
8
+ end
9
+ end
10
10
 
11
- def self.all
12
- @@newsletter_layouts ||= Alchemy::PageLayout.get_all_by_attributes(:newsletter => true)
13
- end
11
+ def self.all
12
+ @@newsletter_layouts ||= Alchemy::PageLayout.get_all_by_attributes(:newsletter => true)
13
+ end
14
14
 
15
- def self.get(name)
16
- all
17
- @@newsletter_layouts.detect { |l| l['name'] == name.to_s }
18
- end
15
+ def self.get(name)
16
+ all
17
+ @@newsletter_layouts.detect { |l| l['name'] == name.to_s }
18
+ end
19
19
 
20
- def self.display_name_for(name)
21
- Alchemy::I18n.t(name, :scope => :page_layout_names, :default => name.to_s.camelcase)
22
- end
20
+ def self.display_name_for(name)
21
+ Alchemy::I18n.t(name, :scope => :page_layout_names, :default => name.to_s.camelcase)
22
+ end
23
23
 
24
- end
24
+ end
25
25
  end
26
26
 
27
27
  Alchemy::PageLayout.class_eval do
28
28
 
29
- def self.selectable_layouts(language_id, layoutpage = false)
30
- class_variable_get('@@definitions').select do |layout|
31
- used = layout["unique"] && has_a_page_this_layout?(layout["name"], language_id)
32
- if layoutpage
33
- layout["layoutpage"] == true && !used && layout["newsletter"] != true
34
- else
35
- layout["layoutpage"] != true && !used && layout["newsletter"] != true
36
- end
37
- end
38
- end
29
+ def self.selectable_layouts(language_id, layoutpage = false)
30
+ class_variable_get('@@definitions').select do |layout|
31
+ used = layout["unique"] && has_a_page_this_layout?(layout["name"], language_id)
32
+ if layoutpage
33
+ layout["layoutpage"] == true && !used && layout["newsletter"] != true
34
+ else
35
+ layout["layoutpage"] != true && !used && layout["newsletter"] != true
36
+ end
37
+ end
38
+ end
39
39
 
40
40
  end
@@ -1,30 +1,30 @@
1
1
  module AlchemyCrm
2
- class Seeder
2
+ class Seeder
3
3
 
4
- def self.seed!
5
- puts "Seeding database for Alchemy Mailing Module"
6
- root = Alchemy::Page.root
7
- lang = Alchemy::Language.get_default
8
- if root.nil? || lang.nil?
9
- puts "== Aborting! Not all dependencies found. Did you ran the Alchemy seeder?"
10
- else
11
- mailing_root = Alchemy::Page.find_or_create_by_name(
12
- :name => "Alchemy CRM Rootpage",
13
- :page_layout => 'alchemy_crm_rootpage',
14
- :do_not_autogenerate => true,
15
- :do_not_sweep => true,
16
- :language => lang,
17
- :parent_id => root.id
18
- )
19
- if mailing_root.new_record?
20
- mailing_root.save!
21
- mailing_root.move_to_child_of root
22
- puts "== Success! Mailing root page created"
23
- else
24
- puts "== Skipping! Already created mailing root page."
25
- end
26
- end
27
- end
4
+ def self.seed!
5
+ puts "Seeding database for Alchemy Mailing Module"
6
+ root = Alchemy::Page.root
7
+ lang = Alchemy::Language.get_default
8
+ if root.nil? || lang.nil?
9
+ puts "== Aborting! Not all dependencies found. Did you ran the Alchemy seeder?"
10
+ else
11
+ mailing_root = Alchemy::Page.find_or_create_by_name(
12
+ :name => "Alchemy CRM Rootpage",
13
+ :page_layout => 'alchemy_crm_rootpage',
14
+ :do_not_autogenerate => true,
15
+ :do_not_sweep => true,
16
+ :language => lang,
17
+ :parent_id => root.id
18
+ )
19
+ if mailing_root.new_record?
20
+ mailing_root.save!
21
+ mailing_root.move_to_child_of root
22
+ puts "== Success! Mailing root page created"
23
+ else
24
+ puts "== Skipping! Already created mailing root page."
25
+ end
26
+ end
27
+ end
28
28
 
29
- end
29
+ end
30
30
  end
@@ -1,3 +1,3 @@
1
1
  module AlchemyCrm
2
- VERSION = "2.0.1"
2
+ VERSION = "2.0.2"
3
3
  end
@@ -1,22 +1,22 @@
1
1
  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
2
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
2
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3
3
  <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
4
- <head>
5
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
6
- <title>Newsletter</title>
7
- <style type="text/css" media="screen">
8
- /* Put styles styles here */
9
- </style>
10
- </head>
11
- <body alink="#000" vlink="#000" link="#000" bgcolor="#fff">
12
- <%# This image is used for tracking %>
13
- <%- unless @preview_mode -%>
14
- <img src="<%= recipient_reads_url(:id => @recipient.id || 1, :host => @server) %>" style="width: 0; height: 0; display: none" width="0" height="0"/>
15
- <%- end -%>
16
- <%# end tracking image %>
17
-
18
- <%= render_newsletter_layout %>
19
-
20
- <%= alchemy_preview_mode_code %>
21
- </body>
4
+ <head>
5
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
6
+ <title>Newsletter</title>
7
+ <style type="text/css" media="screen">
8
+ /* Put styles styles here */
9
+ </style>
10
+ </head>
11
+ <body alink="#000" vlink="#000" link="#000" bgcolor="#fff">
12
+ <%# This image is used for tracking %>
13
+ <%- unless @preview_mode -%>
14
+ <img src="<%= recipient_reads_url(:id => @recipient.id || 1, :host => @server) %>" style="width: 0; height: 0; display: none" width="0" height="0"/>
15
+ <%- end -%>
16
+ <%# end tracking image %>
17
+
18
+ <%= render_newsletter_layout %>
19
+
20
+ <%= alchemy_preview_mode_code %>
21
+ </body>
22
22
  </html>
@@ -5,7 +5,7 @@ module AlchemyCrm
5
5
  class ScaffoldGenerator < ::Rails::Generators::Base
6
6
  desc "This generator generates the Alchemy CRM scaffold."
7
7
  source_root File.expand_path('files', File.dirname(__FILE__))
8
-
8
+
9
9
  def create_newsletter_scaffold
10
10
 
11
11
  empty_directory "#{Rails.root}/app/views/alchemy/newsletter_layouts"
@@ -20,7 +20,7 @@ module AlchemyCrm
20
20
  append_file "#{Rails.root}/config/alchemy/page_layouts.yml", YAML.load_file(File.expand_path('files/page_layouts.yml', File.dirname(__FILE__))).to_yaml.gsub(/^^-{3}\s{2}/, "\n# These page layouts are added by the Alchemy CRM module.\n\n")
21
21
 
22
22
  end
23
-
23
+
24
24
  end
25
25
  end
26
26
  end
@@ -1,28 +1,28 @@
1
1
  namespace 'alchemy_crm' do
2
2
 
3
- desc "Migrates the database, inserts essential data into the database and copies all assets."
4
- task :prepare do
5
- Rake::Task['alchemy_crm:install:migrations'].invoke
6
- Rake::Task['alchemy_crm:seeder:copy'].invoke
7
- end
3
+ desc "Migrates the database, inserts essential data into the database and copies all assets."
4
+ task :prepare do
5
+ Rake::Task['alchemy_crm:install:migrations'].invoke
6
+ Rake::Task['alchemy_crm:seeder:copy'].invoke
7
+ end
8
8
 
9
- namespace 'seeder' do
10
- desc "Copy a line of code into the seeds.rb file"
11
- task :copy do
12
- File.open("./db/seeds.rb", "a") do |f|
13
- f.puts "\n# Seeding Alchemy CRM data"
14
- f.puts "AlchemyCrm::Seeder.seed!\n"
15
- end
16
- end
17
- end
9
+ namespace 'seeder' do
10
+ desc "Copy a line of code into the seeds.rb file"
11
+ task :copy do
12
+ File.open("./db/seeds.rb", "a") do |f|
13
+ f.puts "\n# Seeding Alchemy CRM data"
14
+ f.puts "AlchemyCrm::Seeder.seed!\n"
15
+ end
16
+ end
17
+ end
18
18
 
19
- namespace 'elements' do
20
- desc "Copy all crm elements into app"
21
- task :copy do
22
- Dir.glob(File.expand_path('../../app/views/alchemy/elements/*', File.dirname(__FILE__))).each do |file|
23
- FileUtils.cp(file, Rails.root.join('app/views/alchemy/elements/'))
24
- end
25
- end
26
- end
19
+ namespace 'elements' do
20
+ desc "Copy all crm elements into app"
21
+ task :copy do
22
+ Dir.glob(File.expand_path('../../app/views/alchemy/elements/*', File.dirname(__FILE__))).each do |file|
23
+ FileUtils.cp(file, Rails.root.join('app/views/alchemy/elements/'))
24
+ end
25
+ end
26
+ end
27
27
 
28
28
  end
@@ -1,29 +1,29 @@
1
1
  desc 'Print out all defined routes in match order, with names. Target specific controller with CONTROLLER=x.'
2
2
  task :routes => :environment do
3
- Rails.application.reload_routes!
4
- all_routes = AlchemyCrm::Engine.routes.routes
5
-
6
- if ENV['CONTROLLER']
7
- all_routes = all_routes.select{ |route| route.defaults[:controller] == ENV['CONTROLLER'] }
8
- end
3
+ Rails.application.reload_routes!
4
+ all_routes = AlchemyCrm::Engine.routes.routes
9
5
 
10
- routes = all_routes.collect do |route|
11
-
12
- reqs = route.requirements.dup
13
- reqs[:to] = route.app unless route.app.class.name.to_s =~ /^ActionDispatch::Routing/
14
- reqs = reqs.empty? ? "" : reqs.inspect
15
-
16
- {:name => route.name.to_s, :verb => route.verb.to_s, :path => route.path, :reqs => reqs}
17
- end
18
-
19
- # Skip the route if it's internal info route
20
- routes.reject! { |r| r[:path] =~ %r{/rails/info/properties|^/assets} }
21
-
22
- name_width = routes.map{ |r| r[:name].length }.max
23
- verb_width = routes.map{ |r| r[:verb].length }.max
24
- path_width = routes.map{ |r| r[:path].length }.max
25
-
26
- routes.each do |r|
27
- puts "#{r[:name].rjust(name_width)} #{r[:verb].ljust(verb_width)} #{r[:path].ljust(path_width)} #{r[:reqs]}"
28
- end
6
+ if ENV['CONTROLLER']
7
+ all_routes = all_routes.select{ |route| route.defaults[:controller] == ENV['CONTROLLER'] }
8
+ end
9
+
10
+ routes = all_routes.collect do |route|
11
+
12
+ reqs = route.requirements.dup
13
+ reqs[:to] = route.app unless route.app.class.name.to_s =~ /^ActionDispatch::Routing/
14
+ reqs = reqs.empty? ? "" : reqs.inspect
15
+
16
+ {:name => route.name.to_s, :verb => route.verb.to_s, :path => route.path, :reqs => reqs}
17
+ end
18
+
19
+ # Skip the route if it's internal info route
20
+ routes.reject! { |r| r[:path] =~ %r{/rails/info/properties|^/assets} }
21
+
22
+ name_width = routes.map{ |r| r[:name].length }.max
23
+ verb_width = routes.map{ |r| r[:verb].length }.max
24
+ path_width = routes.map{ |r| r[:path].length }.max
25
+
26
+ routes.each do |r|
27
+ puts "#{r[:name].rjust(name_width)} #{r[:verb].ljust(verb_width)} #{r[:path].ljust(path_width)} #{r[:reqs]}"
28
+ end
29
29
  end
@@ -1,28 +1,28 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  module AlchemyCrm
4
- describe 'Configuration' do
5
- describe 'file' do
6
- context 'is present in host application' do
7
- before(:each) do
8
- @config_file = Rails.root.join('config', 'alchemy_crm.config.yml')
9
- File.open(@config_file, 'w') do |file|
10
- file.puts({'mail_from' => 'jon@doe.com'}.to_yaml)
11
- end
12
- end
13
- it "should load the app config" do
14
- Config.show.should == {'mail_from' => 'jon@doe.com'}
15
- end
16
- after(:each) do
17
- FileUtils.rm_f @config_file
18
- end
19
- end
20
- context 'is not present in application' do
21
- it 'should load the default config' do
22
- default_config = File.join(File.dirname(__FILE__), '..', 'config/alchemy_crm.config.yml')
23
- Config.show.should == YAML.load_file(default_config)
24
- end
25
- end
26
- end
27
- end
4
+ describe 'Configuration' do
5
+ describe 'file' do
6
+ context 'is present in host application' do
7
+ before(:each) do
8
+ @config_file = Rails.root.join('config', 'alchemy_crm.config.yml')
9
+ File.open(@config_file, 'w') do |file|
10
+ file.puts({'mail_from' => 'jon@doe.com'}.to_yaml)
11
+ end
12
+ end
13
+ it "should load the app config" do
14
+ Config.show.should == {'mail_from' => 'jon@doe.com'}
15
+ end
16
+ after(:each) do
17
+ FileUtils.rm_f @config_file
18
+ end
19
+ end
20
+ context 'is not present in application' do
21
+ it 'should load the default config' do
22
+ default_config = File.join(File.dirname(__FILE__), '..', 'config/alchemy_crm.config.yml')
23
+ Config.show.should == YAML.load_file(default_config)
24
+ end
25
+ end
26
+ end
27
+ end
28
28
  end
@@ -1,210 +1,210 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  module AlchemyCrm
4
- describe ContactsController do
4
+ describe ContactsController do
5
5
 
6
- before(:all) do
7
- Alchemy::PageLayout.add([
8
- {"name" => 'newsletter_signup', "elements" => ['newsletter_signup_form'], "autogenerate" => ["newsletter_signup_form"]},
9
- {"name" => 'newsletter_signout', "elements" => ['newsletter_signout_form'], "autogenerate" => ["newsletter_signout_form"]},
10
- {"name" => 'newsletter_mails', "elements" => ['newsletter_signup_mail', 'newsletter_signout_mail'], "autogenerate" => ["newsletter_signup_mail", "newsletter_signout_mail"]}
11
- ])
12
- @language_root = Alchemy::Page.create!(:name => 'Language Root', :page_layout => 'standard', :parent_id => Alchemy::Page.root.id, :language => Alchemy::Language.get_default)
13
- @signup_page = Alchemy::Page.create!(:name => 'Newsletter Signup', :page_layout => 'newsletter_signup', :parent_id => @language_root.id, :language => @language_root.language, :public => true)
14
- @signout_page = Alchemy::Page.create!(:name => 'Newsletter Signout', :page_layout => 'newsletter_signout', :parent_id => @language_root.id, :language => @language_root.language, :public => true)
15
- @mail_page = Alchemy::Page.create!(:name => 'Newsletter Mails', :page_layout => 'newsletter_mails', :parent_id => @language_root.id, :language => @language_root.language)
16
- @contact_params = {:email => 'jon@doe.com', :firstname => 'Jon', :lastname => 'Doe', :salutation => 'mr'}
17
- @newsletter = Newsletter.create!(:name => 'Newsletter', :layout => 'standard')
18
- end
6
+ before(:all) do
7
+ Alchemy::PageLayout.add([
8
+ {"name" => 'newsletter_signup', "elements" => ['newsletter_signup_form'], "autogenerate" => ["newsletter_signup_form"]},
9
+ {"name" => 'newsletter_signout', "elements" => ['newsletter_signout_form'], "autogenerate" => ["newsletter_signout_form"]},
10
+ {"name" => 'newsletter_mails', "elements" => ['newsletter_signup_mail', 'newsletter_signout_mail'], "autogenerate" => ["newsletter_signup_mail", "newsletter_signout_mail"]}
11
+ ])
12
+ @language_root = Alchemy::Page.create!(:name => 'Language Root', :page_layout => 'standard', :parent_id => Alchemy::Page.root.id, :language => Alchemy::Language.get_default)
13
+ @signup_page = Alchemy::Page.create!(:name => 'Newsletter Signup', :page_layout => 'newsletter_signup', :parent_id => @language_root.id, :language => @language_root.language, :public => true)
14
+ @signout_page = Alchemy::Page.create!(:name => 'Newsletter Signout', :page_layout => 'newsletter_signout', :parent_id => @language_root.id, :language => @language_root.language, :public => true)
15
+ @mail_page = Alchemy::Page.create!(:name => 'Newsletter Mails', :page_layout => 'newsletter_mails', :parent_id => @language_root.id, :language => @language_root.language)
16
+ @contact_params = {:email => 'jon@doe.com', :firstname => 'Jon', :lastname => 'Doe', :salutation => 'mr'}
17
+ @newsletter = Newsletter.create!(:name => 'Newsletter', :layout => 'standard')
18
+ end
19
19
 
20
- describe '#signup' do
20
+ describe '#signup' do
21
21
 
22
- before(:each) do
23
- post :signup, {:contact => @contact_params, :use_route => :alchemy_crm}
24
- end
22
+ before(:each) do
23
+ post :signup, {:contact => @contact_params, :use_route => :alchemy_crm}
24
+ end
25
25
 
26
- it "should create the contact from params." do
27
- Contact.find_by_email('jon@doe.com').should_not be_nil
28
- end
26
+ it "should create the contact from params." do
27
+ Contact.find_by_email('jon@doe.com').should_not be_nil
28
+ end
29
29
 
30
- it "should deliver the signup mail." do
31
- ActionMailer::Base.deliveries.collect(&:subject).should include("Signup mail")
32
- end
30
+ it "should deliver the signup mail." do
31
+ ActionMailer::Base.deliveries.collect(&:subject).should include("Signup mail")
32
+ end
33
33
 
34
- end
34
+ end
35
35
 
36
- describe '#verify' do
36
+ describe '#verify' do
37
37
 
38
- before(:all) do
39
- @contact = Contact.create!({:email => 'jon@doe.com', :firstname => 'Jon', :lastname => 'Doe', :salutation => 'mr'})
40
- end
38
+ before(:all) do
39
+ @contact = Contact.create!({:email => 'jon@doe.com', :firstname => 'Jon', :lastname => 'Doe', :salutation => 'mr'})
40
+ end
41
41
 
42
- context "receiving hash from existing contact" do
42
+ context "receiving hash from existing contact" do
43
43
 
44
- render_views
44
+ render_views
45
45
 
46
- before(:each) do
47
- @element = @signup_page.elements.find_by_name(:newsletter_signup_form)
48
- @element.content_by_name('verified_text').essence.update_attribute(:body, 'you are now verified')
49
- post :verify, {:token => @contact.email_sha1, :use_route => :alchemy_crm}
50
- end
46
+ before(:each) do
47
+ @element = @signup_page.elements.find_by_name(:newsletter_signup_form)
48
+ @element.content_by_name('verified_text').essence.update_attribute(:body, 'you are now verified')
49
+ post :verify, {:token => @contact.email_sha1, :use_route => :alchemy_crm}
50
+ end
51
51
 
52
- it "should verify the contact." do
53
- @contact.reload
54
- @contact.verified.should be(true)
55
- end
52
+ it "should verify the contact." do
53
+ @contact.reload
54
+ @contact.verified.should be(true)
55
+ end
56
56
 
57
- it "should display custom 'verified' text." do
58
- verified_text = Regexp.new(Regexp.escape(@element.ingredient('verified_text')))
59
- response.body.should match(verified_text)
60
- end
57
+ it "should display custom 'verified' text." do
58
+ verified_text = Regexp.new(Regexp.escape(@element.ingredient('verified_text')))
59
+ response.body.should match(verified_text)
60
+ end
61
61
 
62
- end
62
+ end
63
63
 
64
- context "receiving hash from existing contact and newsletter ids" do
64
+ context "receiving hash from existing contact and newsletter ids" do
65
65
 
66
- before(:each) do
67
- @subscription = Subscription.create!(:contact => @contact, :newsletter => @newsletter)
68
- @newsletter_ids = @contact.subscriptions.collect(&:newsletter_id)
69
- post :verify, {:token => @contact.email_sha1, :newsletter_ids => @newsletter_ids, :use_route => :alchemy_crm}
70
- end
66
+ before(:each) do
67
+ @subscription = Subscription.create!(:contact => @contact, :newsletter => @newsletter)
68
+ @newsletter_ids = @contact.subscriptions.collect(&:newsletter_id)
69
+ post :verify, {:token => @contact.email_sha1, :newsletter_ids => @newsletter_ids, :use_route => :alchemy_crm}
70
+ end
71
71
 
72
- it "should verify all subscriptions from contact." do
73
- @contact.subscriptions.where(:verified => true).collect(&:newsletter_id).should == @newsletter_ids
74
- end
72
+ it "should verify all subscriptions from contact." do
73
+ @contact.subscriptions.where(:verified => true).collect(&:newsletter_id).should == @newsletter_ids
74
+ end
75
75
 
76
- end
76
+ end
77
77
 
78
- context "receiving hash from not existing contact" do
78
+ context "receiving hash from not existing contact" do
79
79
 
80
- it "should raise routing error." do
81
- lambda {
82
- post :verify, {:token => 'f4k3h4ckh4sh', :use_route => :alchemy_crm}
83
- }.should raise_error(ActionController::RoutingError)
84
- end
80
+ it "should raise routing error." do
81
+ lambda {
82
+ post :verify, {:token => 'f4k3h4ckh4sh', :use_route => :alchemy_crm}
83
+ }.should raise_error(ActionController::RoutingError)
84
+ end
85
85
 
86
- end
86
+ end
87
87
 
88
- context "not receiving any newsletter_ids" do
88
+ context "not receiving any newsletter_ids" do
89
89
 
90
- before(:each) do
91
- @subscription = Subscription.create!(:contact => @contact, :newsletter => @newsletter)
92
- post :verify, {:token => @contact.email_sha1, :use_route => :alchemy_crm}
93
- end
90
+ before(:each) do
91
+ @subscription = Subscription.create!(:contact => @contact, :newsletter => @newsletter)
92
+ post :verify, {:token => @contact.email_sha1, :use_route => :alchemy_crm}
93
+ end
94
94
 
95
- it "should verify all subscriptions from contact." do
96
- @contact.subscriptions.where(:verified => true).count.should == @contact.subscriptions.count
97
- end
95
+ it "should verify all subscriptions from contact." do
96
+ @contact.subscriptions.where(:verified => true).count.should == @contact.subscriptions.count
97
+ end
98
98
 
99
- end
99
+ end
100
100
 
101
- after(:all) do
102
- @contact.destroy
103
- end
101
+ after(:all) do
102
+ @contact.destroy
103
+ end
104
104
 
105
- end
105
+ end
106
106
 
107
- describe '#signout' do
107
+ describe '#signout' do
108
108
 
109
- context "receiving an unknown email" do
109
+ context "receiving an unknown email" do
110
110
 
111
- it "should display error notice." do
112
- post :signout, {:email => 'not@know.com', :use_route => :alchemy_crm}
113
- flash[:notice].should match(/contact could not be found/)
114
- end
111
+ it "should display error notice." do
112
+ post :signout, {:email => 'not@know.com', :use_route => :alchemy_crm}
113
+ flash[:notice].should match(/contact could not be found/)
114
+ end
115
115
 
116
- end
116
+ end
117
117
 
118
- context "receiving an email for verified contact" do
118
+ context "receiving an email for verified contact" do
119
119
 
120
- before(:each) do
121
- @contact = Contact.create!({:email => 'jon@doe.com', :firstname => 'Jon', :lastname => 'Doe', :salutation => 'mr', :verified => true}, :as => :admin)
122
- end
120
+ before(:each) do
121
+ @contact = Contact.create!({:email => 'jon@doe.com', :firstname => 'Jon', :lastname => 'Doe', :salutation => 'mr', :verified => true}, :as => :admin)
122
+ end
123
123
 
124
- it "should deliver signout mail." do
125
- post :signout, {:email => 'jon@doe.com', :use_route => :alchemy_crm}
126
- ActionMailer::Base.deliveries.collect(&:subject).should include("Signout mail")
127
- end
124
+ it "should deliver signout mail." do
125
+ post :signout, {:email => 'jon@doe.com', :use_route => :alchemy_crm}
126
+ ActionMailer::Base.deliveries.collect(&:subject).should include("Signout mail")
127
+ end
128
128
 
129
- end
129
+ end
130
130
 
131
- context "receiving an email for known, but not verified contact" do
131
+ context "receiving an email for known, but not verified contact" do
132
132
 
133
- before(:each) do
134
- @contact = Contact.create!({:email => 'jon@doe.com', :firstname => 'Jon', :lastname => 'Doe', :salutation => 'mr'})
135
- end
133
+ before(:each) do
134
+ @contact = Contact.create!({:email => 'jon@doe.com', :firstname => 'Jon', :lastname => 'Doe', :salutation => 'mr'})
135
+ end
136
136
 
137
- it "should display error notice." do
138
- post :signout, {:email => @contact.email, :use_route => :alchemy_crm}
139
- flash[:notice].should match(/contact could not be found/)
140
- end
137
+ it "should display error notice." do
138
+ post :signout, {:email => @contact.email, :use_route => :alchemy_crm}
139
+ flash[:notice].should match(/contact could not be found/)
140
+ end
141
141
 
142
- end
142
+ end
143
143
 
144
- end
144
+ end
145
145
 
146
- describe '#disable' do
146
+ describe '#disable' do
147
147
 
148
- before(:all) do
149
- @contact = Contact.create!({:email => 'jon@doe.com', :firstname => 'Jon', :lastname => 'Doe', :salutation => 'mr', :verified => true}, :as => :admin)
150
- end
148
+ before(:all) do
149
+ @contact = Contact.create!({:email => 'jon@doe.com', :firstname => 'Jon', :lastname => 'Doe', :salutation => 'mr', :verified => true}, :as => :admin)
150
+ end
151
151
 
152
- context "receiving hash from existing contact" do
152
+ context "receiving hash from existing contact" do
153
153
 
154
- render_views
154
+ render_views
155
155
 
156
- before(:each) do
157
- @element = @signout_page.elements.find_by_name(:newsletter_signout_form)
158
- @element.content_by_name('disabled_text').essence.update_attribute(:body, 'you are now disabled')
159
- post :disable, {:token => @contact.email_sha1, :use_route => :alchemy_crm}
160
- end
156
+ before(:each) do
157
+ @element = @signout_page.elements.find_by_name(:newsletter_signout_form)
158
+ @element.content_by_name('disabled_text').essence.update_attribute(:body, 'you are now disabled')
159
+ post :disable, {:token => @contact.email_sha1, :use_route => :alchemy_crm}
160
+ end
161
161
 
162
- it "should disable the contact." do
163
- @contact.reload
164
- @contact.disabled.should be(true)
165
- @contact.verified.should be(false)
166
- end
162
+ it "should disable the contact." do
163
+ @contact.reload
164
+ @contact.disabled.should be(true)
165
+ @contact.verified.should be(false)
166
+ end
167
167
 
168
- it "should display custom 'disabled' text." do
169
- disabled_text = Regexp.new(Regexp.escape(@element.ingredient('disabled_text')))
170
- response.body.should match(disabled_text)
171
- end
168
+ it "should display custom 'disabled' text." do
169
+ disabled_text = Regexp.new(Regexp.escape(@element.ingredient('disabled_text')))
170
+ response.body.should match(disabled_text)
171
+ end
172
172
 
173
- end
173
+ end
174
174
 
175
- context "receiving hash from existing contact" do
175
+ context "receiving hash from existing contact" do
176
176
 
177
- before(:each) do
178
- @subscription = Subscription.create!(:contact => @contact, :newsletter => @newsletter)
179
- post :disable, {:token => @contact.email_sha1, :use_route => :alchemy_crm}
180
- end
177
+ before(:each) do
178
+ @subscription = Subscription.create!(:contact => @contact, :newsletter => @newsletter)
179
+ post :disable, {:token => @contact.email_sha1, :use_route => :alchemy_crm}
180
+ end
181
181
 
182
- it "should delete all subscriptions from contact." do
183
- @contact.subscriptions.should be_empty
184
- end
182
+ it "should delete all subscriptions from contact." do
183
+ @contact.subscriptions.should be_empty
184
+ end
185
185
 
186
- end
186
+ end
187
187
 
188
- context "receiving hash from not existing contact" do
188
+ context "receiving hash from not existing contact" do
189
189
 
190
- it "should raise routing error." do
191
- lambda {
192
- post :disable, {:token => 'f4k3h4ckh4sh', :use_route => :alchemy_crm}
193
- }.should raise_error(ActionController::RoutingError)
194
- end
190
+ it "should raise routing error." do
191
+ lambda {
192
+ post :disable, {:token => 'f4k3h4ckh4sh', :use_route => :alchemy_crm}
193
+ }.should raise_error(ActionController::RoutingError)
194
+ end
195
195
 
196
- end
196
+ end
197
197
 
198
- after(:all) do
199
- @contact.destroy
200
- end
198
+ after(:all) do
199
+ @contact.destroy
200
+ end
201
201
 
202
- end
202
+ end
203
203
 
204
- after(:all) do
205
- @language_root.destroy
206
- Contact.destroy_all
207
- end
204
+ after(:all) do
205
+ @language_root.destroy
206
+ Contact.destroy_all
207
+ end
208
208
 
209
- end
209
+ end
210
210
  end