rails_page_comment 0.0.3 → 0.1.0

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.
Files changed (75) hide show
  1. checksums.yaml +4 -4
  2. data/MIT-LICENSE +20 -20
  3. data/Rakefile +34 -34
  4. data/app/assets/javascripts/rails_page_comment/application.js +13 -13
  5. data/app/assets/javascripts/rails_page_comment/page_comments.js +2 -2
  6. data/app/assets/stylesheets/rails_page_comment/application.css +15 -15
  7. data/app/assets/stylesheets/rails_page_comment/page_comments.css +4 -4
  8. data/app/assets/stylesheets/scaffold.css +56 -56
  9. data/app/controllers/rails_page_comment/application_controller.rb +11 -4
  10. data/app/controllers/rails_page_comment/page_comments_controller.rb +69 -62
  11. data/app/helpers/rails_page_comment/application_helper.rb +4 -4
  12. data/app/helpers/rails_page_comment/page_comments_helper.rb +4 -4
  13. data/app/mailers/rails_page_comment/notify_changes.rb +15 -0
  14. data/app/models/rails_page_comment/page_comment.rb +4 -4
  15. data/app/views/layouts/rails_page_comment/application.html.erb +14 -14
  16. data/app/views/rails_page_comment/notify_changes/notice_changes.html.erb +2 -0
  17. data/app/views/rails_page_comment/page_comments/_form.html.erb +13 -13
  18. data/app/views/rails_page_comment/page_comments/index.html.erb +27 -27
  19. data/app/views/rails_page_comment/page_comments/show.html.erb +14 -14
  20. data/config/routes.rb +5 -5
  21. data/db/migrate/20141105030748_create_rails_page_comment_page_comments.rb +10 -10
  22. data/lib/generators/rails_page_comment/install_generator.rb +51 -51
  23. data/lib/generators/rails_page_comment/mailer_views_generator.rb +36 -0
  24. data/lib/generators/rails_page_comment/templates/active_record/rails_page_comment/page_comment.rb +3 -3
  25. data/lib/generators/rails_page_comment/templates/mailer/notice_changes.html.erb +2 -0
  26. data/lib/generators/rails_page_comment/templates/rails_page_comment.rb +20 -7
  27. data/lib/rails_page_comment.rb +38 -20
  28. data/lib/rails_page_comment/controller_additions.rb +38 -34
  29. data/lib/rails_page_comment/controller_resource.rb +52 -52
  30. data/lib/rails_page_comment/engine.rb +10 -10
  31. data/lib/rails_page_comment/version.rb +3 -3
  32. data/lib/tasks/rails_page_comment_tasks.rake +4 -4
  33. data/test/controllers/rails_page_comment/page_comments_controller_test.rb +51 -51
  34. data/test/dummy/README.rdoc +28 -28
  35. data/test/dummy/Rakefile +6 -6
  36. data/test/dummy/app/assets/javascripts/application.js +13 -13
  37. data/test/dummy/app/assets/stylesheets/application.css +15 -15
  38. data/test/dummy/app/controllers/application_controller.rb +5 -5
  39. data/test/dummy/app/helpers/application_helper.rb +2 -2
  40. data/test/dummy/app/views/layouts/application.html.erb +14 -14
  41. data/test/dummy/bin/bundle +3 -3
  42. data/test/dummy/bin/rails +4 -4
  43. data/test/dummy/bin/rake +4 -4
  44. data/test/dummy/config.ru +4 -4
  45. data/test/dummy/config/application.rb +23 -23
  46. data/test/dummy/config/boot.rb +5 -5
  47. data/test/dummy/config/database.yml +25 -25
  48. data/test/dummy/config/environment.rb +5 -5
  49. data/test/dummy/config/environments/development.rb +37 -37
  50. data/test/dummy/config/environments/production.rb +82 -82
  51. data/test/dummy/config/environments/test.rb +39 -39
  52. data/test/dummy/config/initializers/assets.rb +8 -8
  53. data/test/dummy/config/initializers/backtrace_silencers.rb +7 -7
  54. data/test/dummy/config/initializers/cookies_serializer.rb +2 -2
  55. data/test/dummy/config/initializers/filter_parameter_logging.rb +4 -4
  56. data/test/dummy/config/initializers/inflections.rb +16 -16
  57. data/test/dummy/config/initializers/mime_types.rb +4 -4
  58. data/test/dummy/config/initializers/session_store.rb +3 -3
  59. data/test/dummy/config/initializers/wrap_parameters.rb +14 -14
  60. data/test/dummy/config/locales/en.yml +23 -23
  61. data/test/dummy/config/routes.rb +4 -4
  62. data/test/dummy/config/secrets.yml +22 -22
  63. data/test/dummy/public/404.html +67 -67
  64. data/test/dummy/public/422.html +67 -67
  65. data/test/dummy/public/500.html +66 -66
  66. data/test/fixtures/rails_page_comment/page_comments.yml +9 -9
  67. data/test/helpers/rails_page_comment/page_comments_helper_test.rb +6 -6
  68. data/test/integration/navigation_test.rb +10 -10
  69. data/test/mailers/previews/rails_page_comment/notify_changes_preview.rb +6 -0
  70. data/test/mailers/rails_page_comment/notify_changes_test.rb +9 -0
  71. data/test/models/rails_page_comment/page_comment_test.rb +9 -9
  72. data/test/rails_page_comment_test.rb +7 -7
  73. data/test/test_helper.rb +15 -15
  74. metadata +11 -4
  75. data/README.rdoc +0 -45
@@ -1,34 +1,38 @@
1
- module RailsPageComment
2
-
3
- # This module is automatically included into all controllers.
4
- module ControllerAdditions
5
- module ClassMethods
6
- # Sets up a before filter which loads and authorizes the current resource. This performs both
7
- #
8
- # class BooksController < ApplicationController
9
- # page_comment_resource
10
- # end
11
- #
12
- def page_comment_resource(*args)
13
- page_comment_resource_class.add_after_filter(self, :page_comment_resource, *args)
14
- end
15
-
16
- def page_comment_resource_class
17
- ControllerResource
18
- end
19
-
20
-
21
- end
22
-
23
- def self.included(base)
24
- base.extend ClassMethods
25
- end
26
-
27
- end
28
- end
29
-
30
- if defined? ActionController::Base
31
- ActionController::Base.class_eval do
32
- include RailsPageComment::ControllerAdditions
33
- end
34
- end
1
+ module RailsPageComment
2
+
3
+ # This module is automatically included into all controllers.
4
+ module ControllerAdditions
5
+ module ClassMethods
6
+ # Sets up a before filter which loads and authorizes the current resource. This performs both
7
+ #
8
+ # class BooksController < ApplicationController
9
+ # page_comment_resource
10
+ # end
11
+ #
12
+ def page_comment_resource(*args)
13
+ page_comment_resource_class.add_after_filter(self, :page_comment_resource, *args)
14
+ end
15
+
16
+ def page_comment_resource_class
17
+ ControllerResource
18
+ end
19
+
20
+
21
+ def notify_changes_class
22
+ RailsPageComment.notify_changes_class_name.to_s.camelize.constantize
23
+ end
24
+
25
+ end
26
+
27
+ def self.included(base)
28
+ base.extend ClassMethods
29
+ end
30
+
31
+ end
32
+ end
33
+
34
+ if defined? ActionController::Base
35
+ ActionController::Base.class_eval do
36
+ include RailsPageComment::ControllerAdditions
37
+ end
38
+ end
@@ -1,52 +1,52 @@
1
- module RailsPageComment
2
- # Handle the load and authorization controller logic so we don't clutter up all controllers with non-interface methods.
3
- # This class is used internally, so you do not need to call methods directly on it.
4
- class ControllerResource # :nodoc:
5
-
6
- ActionView::Base.send(:include, RailsPageComment::Engine.routes.url_helpers) # brings ActionDispatch::Routing::UrlFor
7
- ActionView::Base.send(:include, ActionView::Helpers::TagHelper)
8
- ActionView::Base.send(:include, ActiveSupport::Configurable)
9
- ActionView::Base.send(:include, ActionController::RequestForgeryProtection)
10
-
11
- def self.add_after_filter(controller_class, method, *args)
12
- if RailsPageComment.show_on_page
13
- options = args.extract_options!
14
- resource_name = args.first
15
- before_filter_method = options.delete(:prepend) ? :prepend_after_filter : :after_filter
16
- controller_class.send(before_filter_method, options.slice(:only, :except, :if, :unless)) do |controller|
17
- controller.class.page_comment_resource_class.new(controller, resource_name, options.except(:only, :except, :if, :unless)).send(method)
18
- end
19
- end
20
- end
21
-
22
- def initialize(controller, *args)
23
- @controller = controller
24
- @params = controller.params
25
- @options = args.extract_options!
26
- @name = args.first
27
- end
28
-
29
- def page_comment_resource
30
- if !@controller.request.xhr?
31
- page_controller = RailsPageComment::PageCommentsController.new
32
- page_controller.request = @controller.request
33
- av = ActionView::Base.new(File.join(Gem.loaded_specs['rails_page_comment'].full_gem_path, 'app', 'views', 'rails_page_comment', 'page_comments'), {}, )
34
- page_uri = [@controller.params[:controller], @controller.params[:action]].join("/")
35
- page_comment = RailsPageComment::PageComment.find_by(:page_uri => page_uri) || RailsPageComment::PageComment.new(:page_uri => page_uri)
36
- av.assign({
37
- :page_comment => page_comment,
38
- :_csrf_token => @controller.session[:_csrf_token]
39
- })
40
- if page_comment.new_record?
41
- html = av.render(:template => "new")
42
- else
43
- html = av.render(:template => "edit")
44
- end
45
-
46
- @controller.response.body = @controller.response.body.gsub('</body>',"#{html}</body>")
47
- end
48
- end
49
-
50
-
51
- end
52
- end
1
+ module RailsPageComment
2
+ # Handle the load and authorization controller logic so we don't clutter up all controllers with non-interface methods.
3
+ # This class is used internally, so you do not need to call methods directly on it.
4
+ class ControllerResource # :nodoc:
5
+
6
+ ActionView::Base.send(:include, RailsPageComment::Engine.routes.url_helpers) if defined? RailsPageComment::Engine # brings ActionDispatch::Routing::UrlFor
7
+ ActionView::Base.send(:include, ActionView::Helpers::TagHelper)
8
+ ActionView::Base.send(:include, ActiveSupport::Configurable)
9
+ ActionView::Base.send(:include, ActionController::RequestForgeryProtection)
10
+
11
+ def self.add_after_filter(controller_class, method, *args)
12
+ if RailsPageComment.show_on_page
13
+ options = args.extract_options!
14
+ resource_name = args.first
15
+ before_filter_method = options.delete(:prepend) ? :prepend_after_filter : :after_filter
16
+ controller_class.send(before_filter_method, options.slice(:only, :except, :if, :unless)) do |controller|
17
+ controller.class.page_comment_resource_class.new(controller, resource_name, options.except(:only, :except, :if, :unless)).send(method)
18
+ end
19
+ end
20
+ end
21
+
22
+ def initialize(controller, *args)
23
+ @controller = controller
24
+ @params = controller.params
25
+ @options = args.extract_options!
26
+ @name = args.first
27
+ end
28
+
29
+ def page_comment_resource
30
+ if !@controller.request.xhr?
31
+ page_controller = RailsPageComment::PageCommentsController.new
32
+ page_controller.request = @controller.request
33
+ av = ActionView::Base.new(File.join(Gem.loaded_specs['rails_page_comment'].full_gem_path, 'app', 'views', 'rails_page_comment', 'page_comments'), {}, )
34
+ page_uri = [@controller.params[:controller], @controller.params[:action]].join("/")
35
+ page_comment = RailsPageComment::PageComment.find_by(:page_uri => page_uri) || RailsPageComment::PageComment.new(:page_uri => page_uri)
36
+ av.assign({
37
+ :page_comment => page_comment,
38
+ :_csrf_token => @controller.session[:_csrf_token]
39
+ })
40
+ if page_comment.new_record?
41
+ html = av.render(:template => "new")
42
+ else
43
+ html = av.render(:template => "edit")
44
+ end
45
+
46
+ @controller.response.body = @controller.response.body.gsub('</body>',"#{html}</body>")
47
+ end
48
+ end
49
+
50
+
51
+ end
52
+ end
@@ -1,10 +1,10 @@
1
- require 'rails'
2
- require 'rails_page_comment'
3
-
4
- module RailsPageComment
5
- class Engine < ::Rails::Engine
6
-
7
- isolate_namespace RailsPageComment
8
-
9
- end
10
- end
1
+ require 'rails'
2
+ require 'rails_page_comment'
3
+
4
+ module RailsPageComment
5
+ class Engine < ::Rails::Engine
6
+
7
+ isolate_namespace RailsPageComment
8
+
9
+ end
10
+ end
@@ -1,3 +1,3 @@
1
- module RailsPageComment
2
- VERSION = "0.0.3"
3
- end
1
+ module RailsPageComment
2
+ VERSION = "0.1.0"
3
+ end
@@ -1,4 +1,4 @@
1
- # desc "Explaining what the task does"
2
- # task :rails_page_comment do
3
- # # Task goes here
4
- # end
1
+ # desc "Explaining what the task does"
2
+ # task :rails_page_comment do
3
+ # # Task goes here
4
+ # end
@@ -1,51 +1,51 @@
1
- require 'test_helper'
2
-
3
- module RailsPageComment
4
- class PageCommentsControllerTest < ActionController::TestCase
5
- setup do
6
- @page_comment = page_comments(:one)
7
- end
8
-
9
- test "should get index" do
10
- get :index
11
- assert_response :success
12
- assert_not_nil assigns(:page_comments)
13
- end
14
-
15
- test "should get new" do
16
- get :new
17
- assert_response :success
18
- end
19
-
20
- test "should create page_comment" do
21
- assert_difference('PageComment.count') do
22
- post :create, page_comment: { content: @page_comment.content, requst_uri: @page_comment.requst_uri }
23
- end
24
-
25
- assert_redirected_to page_comment_path(assigns(:page_comment))
26
- end
27
-
28
- test "should show page_comment" do
29
- get :show, id: @page_comment
30
- assert_response :success
31
- end
32
-
33
- test "should get edit" do
34
- get :edit, id: @page_comment
35
- assert_response :success
36
- end
37
-
38
- test "should update page_comment" do
39
- patch :update, id: @page_comment, page_comment: { content: @page_comment.content, requst_uri: @page_comment.requst_uri }
40
- assert_redirected_to page_comment_path(assigns(:page_comment))
41
- end
42
-
43
- test "should destroy page_comment" do
44
- assert_difference('PageComment.count', -1) do
45
- delete :destroy, id: @page_comment
46
- end
47
-
48
- assert_redirected_to page_comments_path
49
- end
50
- end
51
- end
1
+ require 'test_helper'
2
+
3
+ module RailsPageComment
4
+ class PageCommentsControllerTest < ActionController::TestCase
5
+ setup do
6
+ @page_comment = page_comments(:one)
7
+ end
8
+
9
+ test "should get index" do
10
+ get :index
11
+ assert_response :success
12
+ assert_not_nil assigns(:page_comments)
13
+ end
14
+
15
+ test "should get new" do
16
+ get :new
17
+ assert_response :success
18
+ end
19
+
20
+ test "should create page_comment" do
21
+ assert_difference('PageComment.count') do
22
+ post :create, page_comment: { content: @page_comment.content, requst_uri: @page_comment.requst_uri }
23
+ end
24
+
25
+ assert_redirected_to page_comment_path(assigns(:page_comment))
26
+ end
27
+
28
+ test "should show page_comment" do
29
+ get :show, id: @page_comment
30
+ assert_response :success
31
+ end
32
+
33
+ test "should get edit" do
34
+ get :edit, id: @page_comment
35
+ assert_response :success
36
+ end
37
+
38
+ test "should update page_comment" do
39
+ patch :update, id: @page_comment, page_comment: { content: @page_comment.content, requst_uri: @page_comment.requst_uri }
40
+ assert_redirected_to page_comment_path(assigns(:page_comment))
41
+ end
42
+
43
+ test "should destroy page_comment" do
44
+ assert_difference('PageComment.count', -1) do
45
+ delete :destroy, id: @page_comment
46
+ end
47
+
48
+ assert_redirected_to page_comments_path
49
+ end
50
+ end
51
+ end
@@ -1,28 +1,28 @@
1
- == README
2
-
3
- This README would normally document whatever steps are necessary to get the
4
- application up and running.
5
-
6
- Things you may want to cover:
7
-
8
- * Ruby version
9
-
10
- * System dependencies
11
-
12
- * Configuration
13
-
14
- * Database creation
15
-
16
- * Database initialization
17
-
18
- * How to run the test suite
19
-
20
- * Services (job queues, cache servers, search engines, etc.)
21
-
22
- * Deployment instructions
23
-
24
- * ...
25
-
26
-
27
- Please feel free to use a different markup language if you do not plan to run
28
- <tt>rake doc:app</tt>.
1
+ == README
2
+
3
+ This README would normally document whatever steps are necessary to get the
4
+ application up and running.
5
+
6
+ Things you may want to cover:
7
+
8
+ * Ruby version
9
+
10
+ * System dependencies
11
+
12
+ * Configuration
13
+
14
+ * Database creation
15
+
16
+ * Database initialization
17
+
18
+ * How to run the test suite
19
+
20
+ * Services (job queues, cache servers, search engines, etc.)
21
+
22
+ * Deployment instructions
23
+
24
+ * ...
25
+
26
+
27
+ Please feel free to use a different markup language if you do not plan to run
28
+ <tt>rake doc:app</tt>.
data/test/dummy/Rakefile CHANGED
@@ -1,6 +1,6 @@
1
- # Add your own tasks in files placed in lib/tasks ending in .rake,
2
- # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
3
-
4
- require File.expand_path('../config/application', __FILE__)
5
-
6
- Rails.application.load_tasks
1
+ # Add your own tasks in files placed in lib/tasks ending in .rake,
2
+ # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
3
+
4
+ require File.expand_path('../config/application', __FILE__)
5
+
6
+ Rails.application.load_tasks
@@ -1,13 +1,13 @@
1
- // This is a manifest file that'll be compiled into application.js, which will include all the files
2
- // listed below.
3
- //
4
- // Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
5
- // or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
6
- //
7
- // It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
8
- // compiled file.
9
- //
10
- // Read Sprockets README (https://github.com/sstephenson/sprockets#sprockets-directives) for details
11
- // about supported directives.
12
- //
13
- //= require_tree .
1
+ // This is a manifest file that'll be compiled into application.js, which will include all the files
2
+ // listed below.
3
+ //
4
+ // Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
5
+ // or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
6
+ //
7
+ // It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
8
+ // compiled file.
9
+ //
10
+ // Read Sprockets README (https://github.com/sstephenson/sprockets#sprockets-directives) for details
11
+ // about supported directives.
12
+ //
13
+ //= require_tree .
@@ -1,15 +1,15 @@
1
- /*
2
- * This is a manifest file that'll be compiled into application.css, which will include all the files
3
- * listed below.
4
- *
5
- * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
6
- * or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path.
7
- *
8
- * You're free to add application-wide styles to this file and they'll appear at the bottom of the
9
- * compiled file so the styles you add here take precedence over styles defined in any styles
10
- * defined in the other CSS/SCSS files in this directory. It is generally better to create a new
11
- * file per style scope.
12
- *
13
- *= require_tree .
14
- *= require_self
15
- */
1
+ /*
2
+ * This is a manifest file that'll be compiled into application.css, which will include all the files
3
+ * listed below.
4
+ *
5
+ * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
6
+ * or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path.
7
+ *
8
+ * You're free to add application-wide styles to this file and they'll appear at the bottom of the
9
+ * compiled file so the styles you add here take precedence over styles defined in any styles
10
+ * defined in the other CSS/SCSS files in this directory. It is generally better to create a new
11
+ * file per style scope.
12
+ *
13
+ *= require_tree .
14
+ *= require_self
15
+ */