rails-footnotes 3.7.9 → 4.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (44) hide show
  1. data/.gitignore +4 -3
  2. data/.travis.yml +10 -6
  3. data/CHANGELOG +13 -0
  4. data/README.rdoc +33 -46
  5. data/Rakefile +2 -2
  6. data/gemfiles/Gemfile.rails-3.2.x +5 -0
  7. data/gemfiles/Gemfile.rails-4.0.x +6 -0
  8. data/gemfiles/Gemfile.rails-4.1.x +5 -0
  9. data/gemfiles/Gemfile.rails-edge +5 -0
  10. data/lib/generators/rails_footnotes/install_generator.rb +1 -4
  11. data/lib/generators/templates/rails_footnotes.rb +19 -3
  12. data/lib/rails-footnotes.rb +41 -13
  13. data/lib/rails-footnotes/extension.rb +22 -3
  14. data/lib/rails-footnotes/filter.rb +9 -18
  15. data/lib/rails-footnotes/notes/log_note.rb +18 -25
  16. data/lib/rails-footnotes/notes/log_note/note_logger.rb +59 -0
  17. data/lib/rails-footnotes/notes/partials_note.rb +20 -38
  18. data/lib/rails-footnotes/notes/queries_note.rb +1 -1
  19. data/lib/rails-footnotes/notes/routes_note.rb +13 -14
  20. data/lib/rails-footnotes/version.rb +1 -1
  21. data/rails-footnotes.gemspec +5 -6
  22. data/spec/abstract_note_spec.rb +5 -0
  23. data/spec/controllers/footnotes_controller_spec.rb +113 -0
  24. data/spec/controllers/log_note_controller_spec.rb +45 -0
  25. data/spec/controllers/partials_note_controller_spec.rb +29 -0
  26. data/spec/fixtures/html_download.html +5 -0
  27. data/spec/footnotes_spec.rb +5 -8
  28. data/spec/notes/assigns_note_spec.rb +1 -1
  29. data/spec/notes/controller_note_spec.rb +1 -1
  30. data/spec/notes/files_note_spec.rb +1 -1
  31. data/spec/notes/javascripts_note_spec.rb +1 -1
  32. data/spec/notes/stylesheets_note_spec.rb +1 -1
  33. data/spec/spec_helper.rb +23 -12
  34. data/spec/views/partials/_foo.html.erb +1 -0
  35. data/spec/views/partials/index.html.erb +1 -0
  36. metadata +31 -22
  37. data/.watchr.example +0 -13
  38. data/lib/generators/templates/rails_footnotes +0 -3
  39. data/lib/rails-footnotes/after_filter.rb +0 -10
  40. data/lib/rails-footnotes/backtracer.rb +0 -32
  41. data/lib/rails-footnotes/before_filter.rb +0 -9
  42. data/lib/rails-footnotes/footnotes.rb +0 -7
  43. data/lib/rails-footnotes/notes/general_note.rb +0 -17
  44. data/spec/notes/partials_notes_spec.rb +0 -9
@@ -0,0 +1,29 @@
1
+ require 'spec_helper'
2
+
3
+ class PartialsController < ActionController::Base
4
+
5
+ def index
6
+ prepend_view_path "#{Rails.root.join('spec', 'views')}"
7
+ end
8
+
9
+ end
10
+
11
+ describe PartialsController do
12
+
13
+ render_views
14
+
15
+ before :all do
16
+ Footnotes.enabled = true
17
+ end
18
+
19
+ after :all do
20
+ Footnotes.enabled = false
21
+ end
22
+
23
+ it 'lists the rendered partials' do
24
+ get :index
25
+ response.body.should have_selector('#footnotes_debug #partials_debug_info table tr', :visible => false, :count => 2)
26
+ end
27
+
28
+
29
+ end
@@ -0,0 +1,5 @@
1
+ <html>
2
+ <body>
3
+ <p>Hello world</p>
4
+ </body>
5
+ </html>
@@ -56,12 +56,9 @@ describe "Footnotes" do
56
56
  end
57
57
  end
58
58
 
59
- #TODO doe's not pased with 1.8.7
60
- if RUBY_VERSION >= '1.9.0'
61
- it "foonotes_included" do
62
- footnotes_perform!
63
- @controller.response_body.should_not == HTML_DOCUMENT
64
- end
59
+ it "foonotes_included" do
60
+ footnotes_perform!
61
+ @controller.response_body.should_not == HTML_DOCUMENT
65
62
  end
66
63
 
67
64
  specify "footnotes_not_included_when_request_is_xhr" do
@@ -72,13 +69,13 @@ describe "Footnotes" do
72
69
  end
73
70
 
74
71
  specify "footnotes_not_included_when_content_type_is_javascript" do
75
- @controller.response.headers['Content-Type'] = 'text/javascript'
72
+ @controller.response.content_type = 'text/javascript'
76
73
  footnotes_perform!
77
74
  @controller.response.body.should eql HTML_DOCUMENT
78
75
  end
79
76
 
80
77
  specify "footnotes_included_when_content_type_is_html" do
81
- @controller.response.headers['Content-Type'] = 'text/html'
78
+ @controller.response.content_type = 'text/html'
82
79
  footnotes_perform!
83
80
  @controller.response.body.should_not eql HTML_DOCUMENT
84
81
  end
@@ -4,7 +4,7 @@ require "rails-footnotes/notes/assigns_note"
4
4
 
5
5
  describe Footnotes::Notes::AssignsNote do
6
6
  let(:note) do
7
- @controller = mock
7
+ @controller = double
8
8
  @controller.stub(:instance_variables).and_return([:@action_has_layout, :@status])
9
9
  @controller.instance_variable_set(:@action_has_layout, true)
10
10
  @controller.instance_variable_set(:@status, 200)
@@ -4,7 +4,7 @@ require "rails-footnotes/notes/controller_note"
4
4
  describe Footnotes::Notes::ControllerNote do
5
5
  # Issue #60
6
6
  it "should not be valid if conftroller file not exist" do
7
- note = Footnotes::Notes::ControllerNote.new(mock)
7
+ note = Footnotes::Notes::ControllerNote.new(double)
8
8
  note.stub(:controller_filename).and_return(nil)
9
9
 
10
10
  note.should_not be_valid
@@ -6,7 +6,7 @@ describe Footnotes::Notes::FilesNote do
6
6
 
7
7
  let(:note) do
8
8
  Rails.stub(:version).and_return('3.0.12');
9
- Footnotes::Notes::FilesNote.new(mock('controller', :response => mock('', :body => '')))
9
+ Footnotes::Notes::FilesNote.new(double('controller', :response => double('', :body => '')))
10
10
  end
11
11
 
12
12
  subject { note }
@@ -2,7 +2,7 @@ require 'spec_helper'
2
2
  require "rails-footnotes/notes/javascripts_note"
3
3
 
4
4
  describe Footnotes::Notes::JavascriptsNote do
5
- let(:note) {described_class.new(mock('controller', :response => mock('body', :body => '')))}
5
+ let(:note) {described_class.new(double('controller', :response => double('body', :body => '')))}
6
6
  subject {note}
7
7
 
8
8
  it {should be_valid}
@@ -3,7 +3,7 @@ require "rails-footnotes/notes/stylesheets_note"
3
3
 
4
4
  describe Footnotes::Notes::StylesheetsNote do
5
5
 
6
- let(:note) {described_class.new(mock('controller', :response => mock('body', :body => '')))}
6
+ let(:note) {described_class.new(double('controller', :response => double('body', :body => '')))}
7
7
  subject {note}
8
8
 
9
9
  it {should be_valid}
data/spec/spec_helper.rb CHANGED
@@ -3,22 +3,33 @@ begin
3
3
  SimpleCov.start
4
4
  rescue LoadError
5
5
  end
6
-
7
- require 'rubygems'
8
-
9
- ENV['RAILS_ENV'] = 'test'
10
-
11
- require 'active_support'
12
- require 'active_support/all' unless Class.respond_to?(:cattr_accessor)
13
- require 'rails-footnotes/footnotes'
14
- require 'rails-footnotes/abstract_note'
6
+ ENV["RAILS_ENV"] ||= 'test'
15
7
  require "rails-footnotes"
8
+ Rails.logger = Logger.new(STDOUT)
16
9
 
17
- class Rails
18
- def self.logger; end
10
+ module FooBar
11
+ class Application < Rails::Application
12
+ config.secret_key_base = 'foobar'
13
+ config.root = Dir.new('.')
14
+ end
15
+ end
19
16
 
20
- def self.version; '3.0.12'; end
17
+ ActionController::Base.class_eval do
18
+ include Rails.application.routes.url_helpers
21
19
  end
22
20
 
23
21
  RSpec.configure do |config|
22
+
23
+ Rails.application.routes.draw do
24
+ get 'footnotes/foo'
25
+ get 'footnotes/foo_holder'
26
+ get 'footnotes/foo_js'
27
+ get 'footnotes/foo_download'
28
+ get 'partials/index'
29
+ end
30
+
24
31
  end
32
+
33
+ require 'rspec/rails'
34
+ require 'capybara/rspec'
35
+ require 'capybara/rails'
@@ -0,0 +1 @@
1
+ bar
@@ -0,0 +1 @@
1
+ <%= render 'foo' %>
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails-footnotes
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.7.9
4
+ version: 4.0.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,10 +9,11 @@ authors:
9
9
  - José Valim
10
10
  - Keenan Brock
11
11
  - Duane Johnson
12
+ - Adrien Siami
12
13
  autorequire:
13
14
  bindir: bin
14
15
  cert_chain: []
15
- date: 2012-10-27 00:00:00.000000000 Z
16
+ date: 2014-03-23 00:00:00.000000000 Z
16
17
  dependencies:
17
18
  - !ruby/object:Gem::Dependency
18
19
  name: rails
@@ -21,7 +22,7 @@ dependencies:
21
22
  requirements:
22
23
  - - ! '>='
23
24
  - !ruby/object:Gem::Version
24
- version: 3.0.0
25
+ version: '3.2'
25
26
  type: :runtime
26
27
  prerelease: false
27
28
  version_requirements: !ruby/object:Gem::Requirement
@@ -29,15 +30,15 @@ dependencies:
29
30
  requirements:
30
31
  - - ! '>='
31
32
  - !ruby/object:Gem::Version
32
- version: 3.0.0
33
+ version: '3.2'
33
34
  - !ruby/object:Gem::Dependency
34
- name: rails
35
+ name: rspec-rails
35
36
  requirement: !ruby/object:Gem::Requirement
36
37
  none: false
37
38
  requirements:
38
39
  - - ! '>='
39
40
  - !ruby/object:Gem::Version
40
- version: 3.0.0
41
+ version: '0'
41
42
  type: :development
42
43
  prerelease: false
43
44
  version_requirements: !ruby/object:Gem::Requirement
@@ -45,23 +46,23 @@ dependencies:
45
46
  requirements:
46
47
  - - ! '>='
47
48
  - !ruby/object:Gem::Version
48
- version: 3.0.0
49
+ version: '0'
49
50
  - !ruby/object:Gem::Dependency
50
- name: rspec
51
+ name: capybara
51
52
  requirement: !ruby/object:Gem::Requirement
52
53
  none: false
53
54
  requirements:
54
- - - ~>
55
+ - - ! '>='
55
56
  - !ruby/object:Gem::Version
56
- version: 2.9.0
57
+ version: '0'
57
58
  type: :development
58
59
  prerelease: false
59
60
  version_requirements: !ruby/object:Gem::Requirement
60
61
  none: false
61
62
  requirements:
62
- - - ~>
63
+ - - ! '>='
63
64
  - !ruby/object:Gem::Version
64
- version: 2.9.0
65
+ version: '0'
65
66
  description: Every Rails page has footnotes that gives information about your application
66
67
  and links back to your editor.
67
68
  email:
@@ -73,25 +74,23 @@ files:
73
74
  - .gitignore
74
75
  - .rspec.example
75
76
  - .travis.yml
76
- - .watchr.example
77
77
  - CHANGELOG
78
78
  - Gemfile
79
79
  - Gemfile.lock
80
80
  - MIT-LICENSE
81
81
  - README.rdoc
82
82
  - Rakefile
83
+ - gemfiles/Gemfile.rails-3.2.x
84
+ - gemfiles/Gemfile.rails-4.0.x
85
+ - gemfiles/Gemfile.rails-4.1.x
86
+ - gemfiles/Gemfile.rails-edge
83
87
  - lib/generators/rails_footnotes/install_generator.rb
84
- - lib/generators/templates/rails_footnotes
85
88
  - lib/generators/templates/rails_footnotes.rb
86
89
  - lib/rails-footnotes.rb
87
90
  - lib/rails-footnotes/abstract_note.rb
88
- - lib/rails-footnotes/after_filter.rb
89
- - lib/rails-footnotes/backtracer.rb
90
- - lib/rails-footnotes/before_filter.rb
91
91
  - lib/rails-footnotes/each_with_rescue.rb
92
92
  - lib/rails-footnotes/extension.rb
93
93
  - lib/rails-footnotes/filter.rb
94
- - lib/rails-footnotes/footnotes.rb
95
94
  - lib/rails-footnotes/notes/all.rb
96
95
  - lib/rails-footnotes/notes/assigns_note.rb
97
96
  - lib/rails-footnotes/notes/controller_note.rb
@@ -99,10 +98,10 @@ files:
99
98
  - lib/rails-footnotes/notes/env_note.rb
100
99
  - lib/rails-footnotes/notes/files_note.rb
101
100
  - lib/rails-footnotes/notes/filters_note.rb
102
- - lib/rails-footnotes/notes/general_note.rb
103
101
  - lib/rails-footnotes/notes/javascripts_note.rb
104
102
  - lib/rails-footnotes/notes/layout_note.rb
105
103
  - lib/rails-footnotes/notes/log_note.rb
104
+ - lib/rails-footnotes/notes/log_note/note_logger.rb
106
105
  - lib/rails-footnotes/notes/params_note.rb
107
106
  - lib/rails-footnotes/notes/partials_note.rb
108
107
  - lib/rails-footnotes/notes/queries_note.rb
@@ -113,14 +112,19 @@ files:
113
112
  - lib/rails-footnotes/version.rb
114
113
  - rails-footnotes.gemspec
115
114
  - spec/abstract_note_spec.rb
115
+ - spec/controllers/footnotes_controller_spec.rb
116
+ - spec/controllers/log_note_controller_spec.rb
117
+ - spec/controllers/partials_note_controller_spec.rb
118
+ - spec/fixtures/html_download.html
116
119
  - spec/footnotes_spec.rb
117
120
  - spec/notes/assigns_note_spec.rb
118
121
  - spec/notes/controller_note_spec.rb
119
122
  - spec/notes/files_note_spec.rb
120
123
  - spec/notes/javascripts_note_spec.rb
121
- - spec/notes/partials_notes_spec.rb
122
124
  - spec/notes/stylesheets_note_spec.rb
123
125
  - spec/spec_helper.rb
126
+ - spec/views/partials/_foo.html.erb
127
+ - spec/views/partials/index.html.erb
124
128
  homepage: http://github.com/josevalim/rails-footnotes
125
129
  licenses: []
126
130
  post_install_message:
@@ -141,18 +145,23 @@ required_rubygems_version: !ruby/object:Gem::Requirement
141
145
  version: '0'
142
146
  requirements: []
143
147
  rubyforge_project: rails-footnotes
144
- rubygems_version: 1.8.24
148
+ rubygems_version: 1.8.23
145
149
  signing_key:
146
150
  specification_version: 3
147
151
  summary: Every Rails page has footnotes that gives information about your application
148
152
  and links back to your editor.
149
153
  test_files:
150
154
  - spec/abstract_note_spec.rb
155
+ - spec/controllers/footnotes_controller_spec.rb
156
+ - spec/controllers/log_note_controller_spec.rb
157
+ - spec/controllers/partials_note_controller_spec.rb
158
+ - spec/fixtures/html_download.html
151
159
  - spec/footnotes_spec.rb
152
160
  - spec/notes/assigns_note_spec.rb
153
161
  - spec/notes/controller_note_spec.rb
154
162
  - spec/notes/files_note_spec.rb
155
163
  - spec/notes/javascripts_note_spec.rb
156
- - spec/notes/partials_notes_spec.rb
157
164
  - spec/notes/stylesheets_note_spec.rb
158
165
  - spec/spec_helper.rb
166
+ - spec/views/partials/_foo.html.erb
167
+ - spec/views/partials/index.html.erb
data/.watchr.example DELETED
@@ -1,13 +0,0 @@
1
- ROOT_PATH = File.dirname(__FILE__)
2
-
3
- def run_spec(file)
4
- system "rspec #{file}" if File.exist?(File.join(ROOT_PATH, file))
5
- end
6
-
7
- watch('spec/.*_spec\.rb') {|m| run_spec m[0] }
8
- watch('spec/notes/.*_spec\.rb') {|m| run_spec m[0] }
9
-
10
- watch('lib/rails-footnotes/(.*)\.rb') {|m| run_spec("spec/#{m[1]}_spec.rb") }
11
- watch('lib/rails-footnotes/notes/.*_note\.rb') {|m| run_spec("spec/notes/#{m[1]}") }
12
-
13
- watch('Gemfile') {|m| run_spec("spec") }
@@ -1,3 +0,0 @@
1
- #this code temporarily disables notes for all controllers
2
- # Footnotes::Filter.notes = []
3
-
@@ -1,10 +0,0 @@
1
- module Footnotes
2
- class AfterFilter
3
- # Method that calls Footnotes to attach its contents
4
- def self.filter(controller)
5
- filter = Footnotes::Filter.new(controller)
6
- filter.add_footnotes!
7
- filter.close!(controller)
8
- end
9
- end
10
- end
@@ -1,32 +0,0 @@
1
- require 'rails/backtrace_cleaner'
2
- class Rails::BacktraceCleaner
3
- def replace_filter(index, &block)
4
- @filters[index] = block
5
- end
6
-
7
- def clean(backtrace, kind = :silent)
8
- safe = super.map {|l| l.html_safe}
9
- def safe.join(*args)
10
- (joined = super).html_safe
11
- end
12
- safe
13
- end
14
- end
15
-
16
- backtrace_cleaner = Rails.backtrace_cleaner
17
- backtrace_cleaner.replace_filter(0) do |line|
18
- if match = line.match(/^(.+):(\d+):in/) || match = line.match(/^(.+):(\d+)\s*$/)
19
- file, line_number = match[1], match[2]
20
- %[<a href="#{Footnotes::Filter.prefix(file, line_number, 1).html_safe}">#{line.sub("#{Rails.root.to_s}/",'').html_safe}</a>].html_safe
21
- else
22
- line
23
- end
24
- end
25
-
26
- gems_paths = (Gem.path + [Gem.default_dir]).uniq.map!{ |p| Regexp.escape(p) }
27
- unless gems_paths.empty?
28
- gems_regexp = %r{\>#{gems_paths.join('|')}/gems/}
29
- backtrace_cleaner.replace_filter(3) {|line| line.sub(gems_regexp, '>') }
30
- end
31
- backtrace_cleaner.remove_silencers!
32
- backtrace_cleaner.add_silencer { |line| line !~ /\>\/?(app|config|lib|test)/ }
@@ -1,9 +0,0 @@
1
- module Footnotes
2
- class BeforeFilter
3
- # Method called to start the notes
4
- # It's a before filter prepend in the controller
5
- def self.filter(controller)
6
- Footnotes::Filter.start!(controller)
7
- end
8
- end
9
- end
@@ -1,7 +0,0 @@
1
- module Footnotes
2
- autoload :EachWithRescue, 'rails-footnotes/each_with_rescue'
3
-
4
- autoload :BeforeFilter, 'rails-footnotes/before_filter'
5
- autoload :AfterFilter, 'rails-footnotes/after_filter'
6
- autoload :Filter, 'rails-footnotes/filter'
7
- end
@@ -1,17 +0,0 @@
1
- module Footnotes
2
- module Notes
3
- class GeneralNote < AbstractNote
4
- def title
5
- 'General Debug'
6
- end
7
-
8
- def legend
9
- 'General (id="general_debug_info")'
10
- end
11
-
12
- def content
13
- 'You can use this tab to debug other parts of your application, for example Javascript.'
14
- end
15
- end
16
- end
17
- end
@@ -1,9 +0,0 @@
1
- require "spec_helper"
2
- require "rails-footnotes/notes/partials_note"
3
-
4
- describe Footnotes::Notes::PartialsNote do
5
- let(:note) {described_class.new(mock())}
6
- subject {note}
7
-
8
- it {should be_valid}
9
- end