refinerycms-contacts 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (72) hide show
  1. data/Gemfile +73 -0
  2. data/Guardfile +27 -0
  3. data/LICENSE.md +8 -0
  4. data/Rakefile +20 -0
  5. data/app/assets/javascripts/refinery/contacts/admin/contacts.js +17 -0
  6. data/app/assets/javascripts/refinery/contacts/admin/jquery.chosen.min.js +10 -0
  7. data/app/assets/javascripts/refinery/contacts/contacts.js +23 -0
  8. data/app/assets/stylesheets/refinery/contacts/admin/chosen.css.scss +396 -0
  9. data/app/assets/stylesheets/refinery/contacts/contacts.css.scss +79 -0
  10. data/app/controllers/refinery/contacts/admin/contacts_controller.rb +14 -0
  11. data/app/controllers/refinery/contacts/mail_messages_controller.rb +26 -0
  12. data/app/helpers/refinery/contacts/admin/contacts_helper.rb +18 -0
  13. data/app/mailers/refinery/contacts/contact_mailer.rb +15 -0
  14. data/app/models/refinery/contact_page.rb +11 -0
  15. data/app/models/refinery/contacts/contact.rb +18 -0
  16. data/app/models/refinery/contacts/mail.rb +13 -0
  17. data/app/models/refinery/contacts/mail_message.rb +15 -0
  18. data/app/models/refinery/contacts/table_less_model.rb +23 -0
  19. data/app/sweepers/refinery/contacts/admin/contact_sweeper.rb +22 -0
  20. data/app/views/refinery/admin/pages/tabs/contacts/_contacts.html.erb +12 -0
  21. data/app/views/refinery/admin/pages/tabs/contacts/_contacts_bar.html.erb +4 -0
  22. data/app/views/refinery/admin/pages/tabs/contacts/_form.html.erb +24 -0
  23. data/app/views/refinery/contacts/admin/contacts/_actions.html.erb +25 -0
  24. data/app/views/refinery/contacts/admin/contacts/_contact.html.erb +17 -0
  25. data/app/views/refinery/contacts/admin/contacts/_contacts.html.erb +2 -0
  26. data/app/views/refinery/contacts/admin/contacts/_form.html.erb +93 -0
  27. data/app/views/refinery/contacts/admin/contacts/_mail_fields.html.erb +7 -0
  28. data/app/views/refinery/contacts/admin/contacts/_records.html.erb +18 -0
  29. data/app/views/refinery/contacts/admin/contacts/_sortable_list.html.erb +5 -0
  30. data/app/views/refinery/contacts/admin/contacts/edit.html.erb +1 -0
  31. data/app/views/refinery/contacts/admin/contacts/index.html.erb +7 -0
  32. data/app/views/refinery/contacts/admin/contacts/new.html.erb +1 -0
  33. data/app/views/refinery/contacts/contact_mailer/contact_form.html.erb +1 -0
  34. data/app/views/refinery/contacts/contact_mailer/contact_form.text.erb +1 -0
  35. data/app/views/refinery/contacts/contacts/_error_info.html.erb +15 -0
  36. data/app/views/refinery/contacts/contacts/_form.html.erb +47 -0
  37. data/app/views/refinery/contacts/contacts/_show.html.erb +50 -0
  38. data/app/views/refinery/contacts/contacts/_success_info.html.erb +8 -0
  39. data/changelog.md +2 -0
  40. data/config/initializers/recaptcha.rb +5 -0
  41. data/config/initializers/refinery/core.rb +4 -0
  42. data/config/locales/en.yml +80 -0
  43. data/config/locales/sk.yml +80 -0
  44. data/config/routes.rb +23 -0
  45. data/db/migrate/1_create_contacts_contacts.rb +36 -0
  46. data/db/migrate/2_create_contacts_mails.rb +17 -0
  47. data/db/migrate/3_create_contact_pages.rb +20 -0
  48. data/db/migrate/4_add_homepage_to_contacts.rb +11 -0
  49. data/db/seeds.rb +13 -0
  50. data/lib/generators/refinery/contacts_generator.rb +28 -0
  51. data/lib/generators/refinery/templates/config/initializers/recaptcha.rb.erb +7 -0
  52. data/lib/generators/refinery/templates/config/initializers/refinery/contacts.rb.erb +4 -0
  53. data/lib/refinery/contacts.rb +23 -0
  54. data/lib/refinery/contacts/configuration.rb +10 -0
  55. data/lib/refinery/contacts/engine.rb +44 -0
  56. data/lib/refinery/contacts/extensions/pages_extension.rb +40 -0
  57. data/lib/refinery/contacts/version.rb +17 -0
  58. data/lib/refinerycms-contacts.rb +1 -0
  59. data/lib/tasks/refinery/contacts.rake +13 -0
  60. data/readme.md +170 -0
  61. data/refinerycms-contacts.gemspec +27 -0
  62. data/script/rails +10 -0
  63. data/spec/models/refinery/contacts/contact_spec.rb +18 -0
  64. data/spec/models/refinery/contacts/mail_spec.rb +18 -0
  65. data/spec/requests/refinery/contacts/admin/contacts_spec.rb +101 -0
  66. data/spec/requests/refinery/contacts/admin/mails_spec.rb +101 -0
  67. data/spec/spec_helper.rb +55 -0
  68. data/spec/support/factories/refinery/contacts.rb +7 -0
  69. data/spec/support/factories/refinery/mails.rb +7 -0
  70. data/tasks/rspec.rake +6 -0
  71. data/tasks/testing.rake +8 -0
  72. metadata +147 -0
data/script/rails ADDED
@@ -0,0 +1,10 @@
1
+ #!/usr/bin/env ruby
2
+ # This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application.
3
+
4
+ ENGINE_PATH = File.expand_path('../..', __FILE__)
5
+ dummy_rails_path = File.expand_path('../../spec/dummy/script/rails', __FILE__)
6
+ if File.exist?(dummy_rails_path)
7
+ load dummy_rails_path
8
+ else
9
+ puts "Please first run 'rake refinery:testing:dummy_app' to create a dummy Refinery CMS application."
10
+ end
@@ -0,0 +1,18 @@
1
+ require 'spec_helper'
2
+
3
+ module Refinery
4
+ module Contacts
5
+ describe Contact do
6
+ describe "validations" do
7
+ subject do
8
+ FactoryGirl.create(:contact,
9
+ :title => "Refinery CMS")
10
+ end
11
+
12
+ it { should be_valid }
13
+ its(:errors) { should be_empty }
14
+ its(:title) { should == "Refinery CMS" }
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,18 @@
1
+ require 'spec_helper'
2
+
3
+ module Refinery
4
+ module Contacts
5
+ describe Mail do
6
+ describe "validations" do
7
+ subject do
8
+ FactoryGirl.create(:mail,
9
+ :mail => "Refinery CMS")
10
+ end
11
+
12
+ it { should be_valid }
13
+ its(:errors) { should be_empty }
14
+ its(:mail) { should == "Refinery CMS" }
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,101 @@
1
+ # encoding: utf-8
2
+ require "spec_helper"
3
+
4
+ describe Refinery do
5
+ describe "Contacts" do
6
+ describe "Admin" do
7
+ describe "contacts" do
8
+ login_refinery_user
9
+
10
+ describe "contacts list" do
11
+ before do
12
+ FactoryGirl.create(:contact, :title => "UniqueTitleOne")
13
+ FactoryGirl.create(:contact, :title => "UniqueTitleTwo")
14
+ end
15
+
16
+ it "shows two items" do
17
+ visit refinery.contacts_admin_contacts_path
18
+ page.should have_content("UniqueTitleOne")
19
+ page.should have_content("UniqueTitleTwo")
20
+ end
21
+ end
22
+
23
+ describe "create" do
24
+ before do
25
+ visit refinery.contacts_admin_contacts_path
26
+
27
+ click_link "Add New Contact"
28
+ end
29
+
30
+ context "valid data" do
31
+ it "should succeed" do
32
+ fill_in "Title", :with => "This is a test of the first string field"
33
+ click_button "Save"
34
+
35
+ page.should have_content("'This is a test of the first string field' was successfully added.")
36
+ Refinery::Contacts::Contact.count.should == 1
37
+ end
38
+ end
39
+
40
+ context "invalid data" do
41
+ it "should fail" do
42
+ click_button "Save"
43
+
44
+ page.should have_content("Title can't be blank")
45
+ Refinery::Contacts::Contact.count.should == 0
46
+ end
47
+ end
48
+
49
+ context "duplicate" do
50
+ before { FactoryGirl.create(:contact, :title => "UniqueTitle") }
51
+
52
+ it "should fail" do
53
+ visit refinery.contacts_admin_contacts_path
54
+
55
+ click_link "Add New Contact"
56
+
57
+ fill_in "Title", :with => "UniqueTitle"
58
+ click_button "Save"
59
+
60
+ page.should have_content("There were problems")
61
+ Refinery::Contacts::Contact.count.should == 1
62
+ end
63
+ end
64
+
65
+ end
66
+
67
+ describe "edit" do
68
+ before { FactoryGirl.create(:contact, :title => "A title") }
69
+
70
+ it "should succeed" do
71
+ visit refinery.contacts_admin_contacts_path
72
+
73
+ within ".actions" do
74
+ click_link "Edit this contact"
75
+ end
76
+
77
+ fill_in "Title", :with => "A different title"
78
+ click_button "Save"
79
+
80
+ page.should have_content("'A different title' was successfully updated.")
81
+ page.should have_no_content("A title")
82
+ end
83
+ end
84
+
85
+ describe "destroy" do
86
+ before { FactoryGirl.create(:contact, :title => "UniqueTitleOne") }
87
+
88
+ it "should succeed" do
89
+ visit refinery.contacts_admin_contacts_path
90
+
91
+ click_link "Remove this contact forever"
92
+
93
+ page.should have_content("'UniqueTitleOne' was successfully removed.")
94
+ Refinery::Contacts::Contact.count.should == 0
95
+ end
96
+ end
97
+
98
+ end
99
+ end
100
+ end
101
+ end
@@ -0,0 +1,101 @@
1
+ # encoding: utf-8
2
+ require "spec_helper"
3
+
4
+ describe Refinery do
5
+ describe "Contacts" do
6
+ describe "Admin" do
7
+ describe "mails" do
8
+ login_refinery_user
9
+
10
+ describe "mails list" do
11
+ before do
12
+ FactoryGirl.create(:mail, :mail => "UniqueTitleOne")
13
+ FactoryGirl.create(:mail, :mail => "UniqueTitleTwo")
14
+ end
15
+
16
+ it "shows two items" do
17
+ visit refinery.contacts_admin_mails_path
18
+ page.should have_content("UniqueTitleOne")
19
+ page.should have_content("UniqueTitleTwo")
20
+ end
21
+ end
22
+
23
+ describe "create" do
24
+ before do
25
+ visit refinery.contacts_admin_mails_path
26
+
27
+ click_link "Add New Mail"
28
+ end
29
+
30
+ context "valid data" do
31
+ it "should succeed" do
32
+ fill_in "Mail", :with => "This is a test of the first string field"
33
+ click_button "Save"
34
+
35
+ page.should have_content("'This is a test of the first string field' was successfully added.")
36
+ Refinery::Contacts::Mail.count.should == 1
37
+ end
38
+ end
39
+
40
+ context "invalid data" do
41
+ it "should fail" do
42
+ click_button "Save"
43
+
44
+ page.should have_content("Mail can't be blank")
45
+ Refinery::Contacts::Mail.count.should == 0
46
+ end
47
+ end
48
+
49
+ context "duplicate" do
50
+ before { FactoryGirl.create(:mail, :mail => "UniqueTitle") }
51
+
52
+ it "should fail" do
53
+ visit refinery.contacts_admin_mails_path
54
+
55
+ click_link "Add New Mail"
56
+
57
+ fill_in "Mail", :with => "UniqueTitle"
58
+ click_button "Save"
59
+
60
+ page.should have_content("There were problems")
61
+ Refinery::Contacts::Mail.count.should == 1
62
+ end
63
+ end
64
+
65
+ end
66
+
67
+ describe "edit" do
68
+ before { FactoryGirl.create(:mail, :mail => "A mail") }
69
+
70
+ it "should succeed" do
71
+ visit refinery.contacts_admin_mails_path
72
+
73
+ within ".actions" do
74
+ click_link "Edit this mail"
75
+ end
76
+
77
+ fill_in "Mail", :with => "A different mail"
78
+ click_button "Save"
79
+
80
+ page.should have_content("'A different mail' was successfully updated.")
81
+ page.should have_no_content("A mail")
82
+ end
83
+ end
84
+
85
+ describe "destroy" do
86
+ before { FactoryGirl.create(:mail, :mail => "UniqueTitleOne") }
87
+
88
+ it "should succeed" do
89
+ visit refinery.contacts_admin_mails_path
90
+
91
+ click_link "Remove this mail forever"
92
+
93
+ page.should have_content("'UniqueTitleOne' was successfully removed.")
94
+ Refinery::Contacts::Mail.count.should == 0
95
+ end
96
+ end
97
+
98
+ end
99
+ end
100
+ end
101
+ end
@@ -0,0 +1,55 @@
1
+ def setup_environment
2
+ # Configure Rails Environment
3
+ ENV["RAILS_ENV"] ||= 'test'
4
+
5
+ if File.exist?(dummy_path = File.expand_path('../dummy/config/environment.rb', __FILE__))
6
+ require dummy_path
7
+ elsif File.dirname(__FILE__) =~ %r{vendor/extensions}
8
+ # Require the path to the refinerycms application this is vendored inside.
9
+ require File.expand_path('../../../../../config/environment', __FILE__)
10
+ end
11
+
12
+ require 'rspec/rails'
13
+ require 'capybara/rspec'
14
+
15
+ Rails.backtrace_cleaner.remove_silencers!
16
+
17
+ RSpec.configure do |config|
18
+ config.mock_with :rspec
19
+ config.treat_symbols_as_metadata_keys_with_true_values = true
20
+ config.filter_run :focus => true
21
+ config.run_all_when_everything_filtered = true
22
+ end
23
+ end
24
+
25
+ def each_run
26
+ Rails.cache.clear
27
+ ActiveSupport::Dependencies.clear
28
+ FactoryGirl.reload
29
+
30
+ # Requires supporting files with custom matchers and macros, etc,
31
+ # in ./support/ and its subdirectories including factories.
32
+ ([Rails.root.to_s] | ::Refinery::Plugins.registered.pathnames).map{|p|
33
+ Dir[File.join(p, 'spec', 'support', '**', '*.rb').to_s]
34
+ }.flatten.sort.each do |support_file|
35
+ require support_file
36
+ end
37
+ end
38
+
39
+ # If spork is available in the Gemfile it'll be used but we don't force it.
40
+ unless (begin; require 'spork'; rescue LoadError; nil end).nil?
41
+ Spork.prefork do
42
+ # Loading more in this block will cause your tests to run faster. However,
43
+ # if you change any configuration or code from libraries loaded here, you'll
44
+ # need to restart spork for it take effect.
45
+ setup_environment
46
+ end
47
+
48
+ Spork.each_run do
49
+ # This code will be run each time you run your specs.
50
+ each_run
51
+ end
52
+ else
53
+ setup_environment
54
+ each_run
55
+ end
@@ -0,0 +1,7 @@
1
+
2
+ FactoryGirl.define do
3
+ factory :contact, :class => Refinery::Contacts::Contact do
4
+ sequence(:title) { |n| "refinery#{n}" }
5
+ end
6
+ end
7
+
@@ -0,0 +1,7 @@
1
+
2
+ FactoryGirl.define do
3
+ factory :mail, :class => Refinery::Contacts::Mail do
4
+ sequence(:mail) { |n| "refinery#{n}" }
5
+ end
6
+ end
7
+
data/tasks/rspec.rake ADDED
@@ -0,0 +1,6 @@
1
+ require 'rspec/core/rake_task'
2
+
3
+ desc "Run specs"
4
+ RSpec::Core::RakeTask.new do |t|
5
+ t.pattern = "./spec"
6
+ end
@@ -0,0 +1,8 @@
1
+ namespace :refinery do
2
+ namespace :testing do
3
+ # Put any code in here that you want run when you test this extension against a dummy app.
4
+ # For example, the call to require your gem and start your generator.
5
+ task :setup_extension do
6
+ end
7
+ end
8
+ end
metadata ADDED
@@ -0,0 +1,147 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: refinerycms-contacts
3
+ version: !ruby/object:Gem::Version
4
+ prerelease:
5
+ version: 0.1.0
6
+ platform: ruby
7
+ authors:
8
+ - Martin Markech
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-12-22 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ type: :runtime
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: 2.0.9
22
+ prerelease: false
23
+ version_requirements: !ruby/object:Gem::Requirement
24
+ none: false
25
+ requirements:
26
+ - - ~>
27
+ - !ruby/object:Gem::Version
28
+ version: 2.0.9
29
+ name: refinerycms-core
30
+ - !ruby/object:Gem::Dependency
31
+ type: :runtime
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ prerelease: false
39
+ version_requirements: !ruby/object:Gem::Requirement
40
+ none: false
41
+ requirements:
42
+ - - ! '>='
43
+ - !ruby/object:Gem::Version
44
+ version: '0'
45
+ name: recaptcha
46
+ description: Ruby on Rails Contacts extension for Refinery CMS
47
+ email: martin.markech@matho.sk
48
+ executables: []
49
+ extensions: []
50
+ extra_rdoc_files: []
51
+ files:
52
+ - Gemfile
53
+ - Guardfile
54
+ - LICENSE.md
55
+ - Rakefile
56
+ - app/assets/javascripts/refinery/contacts/admin/contacts.js
57
+ - app/assets/javascripts/refinery/contacts/admin/jquery.chosen.min.js
58
+ - app/assets/javascripts/refinery/contacts/contacts.js
59
+ - app/assets/stylesheets/refinery/contacts/admin/chosen.css.scss
60
+ - app/assets/stylesheets/refinery/contacts/contacts.css.scss
61
+ - app/controllers/refinery/contacts/admin/contacts_controller.rb
62
+ - app/controllers/refinery/contacts/mail_messages_controller.rb
63
+ - app/helpers/refinery/contacts/admin/contacts_helper.rb
64
+ - app/mailers/refinery/contacts/contact_mailer.rb
65
+ - app/models/refinery/contact_page.rb
66
+ - app/models/refinery/contacts/contact.rb
67
+ - app/models/refinery/contacts/mail.rb
68
+ - app/models/refinery/contacts/mail_message.rb
69
+ - app/models/refinery/contacts/table_less_model.rb
70
+ - app/sweepers/refinery/contacts/admin/contact_sweeper.rb
71
+ - app/views/refinery/admin/pages/tabs/contacts/_contacts.html.erb
72
+ - app/views/refinery/admin/pages/tabs/contacts/_contacts_bar.html.erb
73
+ - app/views/refinery/admin/pages/tabs/contacts/_form.html.erb
74
+ - app/views/refinery/contacts/admin/contacts/_actions.html.erb
75
+ - app/views/refinery/contacts/admin/contacts/_contact.html.erb
76
+ - app/views/refinery/contacts/admin/contacts/_contacts.html.erb
77
+ - app/views/refinery/contacts/admin/contacts/_form.html.erb
78
+ - app/views/refinery/contacts/admin/contacts/_mail_fields.html.erb
79
+ - app/views/refinery/contacts/admin/contacts/_records.html.erb
80
+ - app/views/refinery/contacts/admin/contacts/_sortable_list.html.erb
81
+ - app/views/refinery/contacts/admin/contacts/edit.html.erb
82
+ - app/views/refinery/contacts/admin/contacts/index.html.erb
83
+ - app/views/refinery/contacts/admin/contacts/new.html.erb
84
+ - app/views/refinery/contacts/contact_mailer/contact_form.html.erb
85
+ - app/views/refinery/contacts/contact_mailer/contact_form.text.erb
86
+ - app/views/refinery/contacts/contacts/_error_info.html.erb
87
+ - app/views/refinery/contacts/contacts/_form.html.erb
88
+ - app/views/refinery/contacts/contacts/_show.html.erb
89
+ - app/views/refinery/contacts/contacts/_success_info.html.erb
90
+ - changelog.md
91
+ - config/initializers/recaptcha.rb
92
+ - config/initializers/refinery/core.rb
93
+ - config/locales/en.yml
94
+ - config/locales/sk.yml
95
+ - config/routes.rb
96
+ - db/migrate/1_create_contacts_contacts.rb
97
+ - db/migrate/2_create_contacts_mails.rb
98
+ - db/migrate/3_create_contact_pages.rb
99
+ - db/migrate/4_add_homepage_to_contacts.rb
100
+ - db/seeds.rb
101
+ - lib/generators/refinery/contacts_generator.rb
102
+ - lib/generators/refinery/templates/config/initializers/recaptcha.rb.erb
103
+ - lib/generators/refinery/templates/config/initializers/refinery/contacts.rb.erb
104
+ - lib/refinery/contacts.rb
105
+ - lib/refinery/contacts/configuration.rb
106
+ - lib/refinery/contacts/engine.rb
107
+ - lib/refinery/contacts/extensions/pages_extension.rb
108
+ - lib/refinery/contacts/version.rb
109
+ - lib/refinerycms-contacts.rb
110
+ - lib/tasks/refinery/contacts.rake
111
+ - readme.md
112
+ - refinerycms-contacts.gemspec
113
+ - script/rails
114
+ - spec/models/refinery/contacts/contact_spec.rb
115
+ - spec/models/refinery/contacts/mail_spec.rb
116
+ - spec/requests/refinery/contacts/admin/contacts_spec.rb
117
+ - spec/requests/refinery/contacts/admin/mails_spec.rb
118
+ - spec/spec_helper.rb
119
+ - spec/support/factories/refinery/contacts.rb
120
+ - spec/support/factories/refinery/mails.rb
121
+ - tasks/rspec.rake
122
+ - tasks/testing.rake
123
+ homepage: http://github.com/Matho/refinerycms-contacts
124
+ licenses: []
125
+ post_install_message:
126
+ rdoc_options: []
127
+ require_paths:
128
+ - lib
129
+ required_ruby_version: !ruby/object:Gem::Requirement
130
+ none: false
131
+ requirements:
132
+ - - ! '>='
133
+ - !ruby/object:Gem::Version
134
+ version: '0'
135
+ required_rubygems_version: !ruby/object:Gem::Requirement
136
+ none: false
137
+ requirements:
138
+ - - ! '>='
139
+ - !ruby/object:Gem::Version
140
+ version: '0'
141
+ requirements: []
142
+ rubyforge_project:
143
+ rubygems_version: 1.8.24
144
+ signing_key:
145
+ specification_version: 3
146
+ summary: Attach contact form to any page in Refinery CMS
147
+ test_files: []