rails-footnotes 7.1.0 → 7.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/rails-footnotes/notes/log_note/note_logger.rb +1 -0
- data/lib/rails-footnotes/version.rb +1 -1
- metadata +7 -71
- data/.github/dependabot.yml +0 -10
- data/.github/workflows/ci.yml +0 -19
- data/.github/workflows/merge-dependabot.yml +0 -33
- data/.gitignore +0 -10
- data/.rspec.example +0 -1
- data/.ruby-version +0 -1
- data/Gemfile +0 -15
- data/Gemfile.lock +0 -256
- data/Rakefile +0 -18
- data/bin/rake +0 -29
- data/bin/rspec +0 -29
- data/gemfiles/Gemfile.rails-3.2.22 +0 -5
- data/gemfiles/Gemfile.rails-4.0.x +0 -6
- data/gemfiles/Gemfile.rails-4.1.x +0 -5
- data/gemfiles/Gemfile.rails-4.2.x +0 -5
- data/gemfiles/Gemfile.rails-edge +0 -5
- data/rails-footnotes.gemspec +0 -19
- data/renovate.json +0 -5
- data/spec/abstract_note_spec.rb +0 -89
- data/spec/app/assets/config/manifest.js +0 -2
- data/spec/app/assets/javascripts/foobar.js +0 -1
- data/spec/app/assets/stylesheets/foobar.css +0 -0
- data/spec/app/views/files/index.html.erb +0 -1
- data/spec/app/views/layouts/application.html.erb +0 -12
- data/spec/app/views/partials/_foo.html.erb +0 -1
- data/spec/app/views/partials/index.html.erb +0 -1
- data/spec/controllers/files_note_controller_spec.rb +0 -38
- data/spec/controllers/footnotes_controller_spec.rb +0 -128
- data/spec/controllers/log_note_controller_spec.rb +0 -32
- data/spec/controllers/partials_note_controller_spec.rb +0 -28
- data/spec/env_note_spec.rb +0 -73
- data/spec/fixtures/html_download.html +0 -5
- data/spec/footnotes_spec.rb +0 -267
- data/spec/notes/assigns_note_spec.rb +0 -68
- data/spec/notes/controller_note_spec.rb +0 -12
- data/spec/notes/files_note_spec.rb +0 -26
- data/spec/notes/javascripts_note_spec.rb +0 -18
- data/spec/notes/stylesheets_note_spec.rb +0 -19
- data/spec/notes/view_note_spec.rb +0 -18
- data/spec/spec_helper.rb +0 -68
- data/spec/support/active_record.rb +0 -22
data/spec/abstract_note_spec.rb
DELETED
@@ -1,89 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
|
3
|
-
describe Footnotes::Notes::AbstractNote do
|
4
|
-
before do
|
5
|
-
@note = Footnotes::Notes::AbstractNote.new
|
6
|
-
@notes = Footnotes::Filter.notes
|
7
|
-
Footnotes::Filter.notes = [:abstract]
|
8
|
-
end
|
9
|
-
|
10
|
-
after do
|
11
|
-
Footnotes::Filter.notes = @notes
|
12
|
-
end
|
13
|
-
|
14
|
-
it {expect(described_class).to respond_to :start!}
|
15
|
-
it {expect(described_class).to respond_to :close!}
|
16
|
-
it {expect(described_class).to respond_to :title}
|
17
|
-
|
18
|
-
it {should respond_to :to_sym}
|
19
|
-
|
20
|
-
describe '#to_sym' do
|
21
|
-
subject { super().to_sym }
|
22
|
-
it {should eql :abstract}
|
23
|
-
end
|
24
|
-
|
25
|
-
it { expect(described_class).to be_included }
|
26
|
-
specify do
|
27
|
-
Footnotes::Filter.notes = []
|
28
|
-
expect(described_class).not_to be_included
|
29
|
-
end
|
30
|
-
|
31
|
-
it { should respond_to :row }
|
32
|
-
it { should respond_to :legend }
|
33
|
-
it { should respond_to :link }
|
34
|
-
it { should respond_to :onclick }
|
35
|
-
it { should respond_to :stylesheet }
|
36
|
-
it { should respond_to :javascript }
|
37
|
-
|
38
|
-
it { should respond_to :valid? }
|
39
|
-
it { should be_valid }
|
40
|
-
|
41
|
-
it { should respond_to :has_fieldset? }
|
42
|
-
it { should_not have_fieldset }
|
43
|
-
|
44
|
-
specify { Footnotes::Filter.prefix = ''; should_not be_prefix }
|
45
|
-
specify do
|
46
|
-
Footnotes::Filter.prefix = 'txmt://open?url=file://%s&line=%d&column=%d'
|
47
|
-
should be_prefix
|
48
|
-
end
|
49
|
-
|
50
|
-
#TODO should be moved to builder
|
51
|
-
#helpers
|
52
|
-
specify { expect(subject.escape('<')).to eql '<' }
|
53
|
-
specify { expect(subject.escape('&')).to eql '&' }
|
54
|
-
specify { expect(subject.escape('>')).to eql '>' }
|
55
|
-
|
56
|
-
specify { expect(subject.mount_table([])).to be_blank }
|
57
|
-
specify { expect(subject.mount_table([['h1', 'h2', 'h3']], :class => 'table')).to be_blank }
|
58
|
-
|
59
|
-
specify {
|
60
|
-
tab = <<-TABLE
|
61
|
-
<table class="table" >
|
62
|
-
<thead><tr><th>H1</th></tr></thead>
|
63
|
-
<tbody><tr><td>r1c1</td></tr></tbody>
|
64
|
-
</table>
|
65
|
-
TABLE
|
66
|
-
|
67
|
-
expect(subject.mount_table([['h1'],['r1c1']], :class => 'table')).to eql tab
|
68
|
-
}
|
69
|
-
|
70
|
-
specify {
|
71
|
-
tab = <<-TABLE
|
72
|
-
<table >
|
73
|
-
<thead><tr><th>H1</th><th>H2</th><th>H3</th></tr></thead>
|
74
|
-
<tbody><tr><td>r1c1</td><td>r1c2</td><td>r1c3</td></tr></tbody>
|
75
|
-
</table>
|
76
|
-
TABLE
|
77
|
-
expect(subject.mount_table([['h1', 'h2', 'h3'],['r1c1', 'r1c2', 'r1c3']])).to eql tab
|
78
|
-
}
|
79
|
-
|
80
|
-
specify {
|
81
|
-
tab = <<-TABLE
|
82
|
-
<table >
|
83
|
-
<thead><tr><th>H1</th><th>H2</th><th>H3</th></tr></thead>
|
84
|
-
<tbody><tr><td>r1c1</td><td>r1c2</td><td>r1c3</td></tr><tr><td>r2c1</td><td>r2c2</td><td>r2c3</td></tr></tbody>
|
85
|
-
</table>
|
86
|
-
TABLE
|
87
|
-
subject.mount_table([['h1', 'h2', 'h3'], ['r1c1', 'r1c2', 'r1c3'], ['r2c1', 'r2c2', 'r2c3']])
|
88
|
-
}
|
89
|
-
end
|
@@ -1 +0,0 @@
|
|
1
|
-
// Foobar
|
File without changes
|
@@ -1 +0,0 @@
|
|
1
|
-
FILES INDEX
|
@@ -1,12 +0,0 @@
|
|
1
|
-
<!doctype html>
|
2
|
-
<html>
|
3
|
-
<head>
|
4
|
-
<%= javascript_include_tag 'foobar' %>
|
5
|
-
<%= javascript_include_tag 'http://google.com/whatever.js' %>
|
6
|
-
<%= stylesheet_link_tag 'foobar' %>
|
7
|
-
<%= stylesheet_link_tag 'http://google.com/whatever.css' %>
|
8
|
-
</head>
|
9
|
-
<body>
|
10
|
-
<%= yield %>
|
11
|
-
</body>
|
12
|
-
</html>
|
@@ -1 +0,0 @@
|
|
1
|
-
bar
|
@@ -1 +0,0 @@
|
|
1
|
-
<%= render 'foo' %>
|
@@ -1,38 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
class FilesController < ApplicationController
|
4
|
-
def index
|
5
|
-
end
|
6
|
-
end
|
7
|
-
|
8
|
-
describe FilesController, type: :controller do
|
9
|
-
render_views
|
10
|
-
|
11
|
-
before :all do
|
12
|
-
Footnotes.enabled = true
|
13
|
-
end
|
14
|
-
|
15
|
-
after :all do
|
16
|
-
Footnotes.enabled = false
|
17
|
-
end
|
18
|
-
|
19
|
-
it 'includes stylesheets assets in the response' do
|
20
|
-
get :index
|
21
|
-
expect(response.body).to include("FILES INDEX")
|
22
|
-
js_debug = first('fieldset#javascripts_debug_info div', visible: false)
|
23
|
-
expect(js_debug).to have_selector('li a', visible: false, count: 1)
|
24
|
-
expect(js_debug).to have_selector('li a', text: /foobar\.js/, visible: false)
|
25
|
-
link = js_debug.first('a', visible: false)
|
26
|
-
expect(link['href']).to eq("txmt://open?url=file://#{Rails.root.join('app', 'assets', 'javascripts', 'foobar.js')}&line=1&column=1")
|
27
|
-
end
|
28
|
-
|
29
|
-
it 'includes css assets in the response' do
|
30
|
-
get :index
|
31
|
-
css_debug = first('fieldset#stylesheets_debug_info div', visible: false)
|
32
|
-
expect(css_debug).to have_selector('li a', visible: false, count: 1)
|
33
|
-
expect(css_debug).to have_selector('li a', text: /foobar\.css/, visible: false)
|
34
|
-
link = css_debug.first('a', visible: false)
|
35
|
-
expect(link['href']).to eq("txmt://open?url=file://#{Rails.root.join('app', 'assets', 'stylesheets', 'foobar.css')}&line=1&column=1")
|
36
|
-
end
|
37
|
-
|
38
|
-
end
|
@@ -1,128 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
class FootnotesController < ActionController::Base
|
4
|
-
|
5
|
-
def foo
|
6
|
-
render inline: HTML_DOCUMENT, content_type: 'text/html'
|
7
|
-
end
|
8
|
-
|
9
|
-
def foo_holder
|
10
|
-
render inline: '<html><body><div id="footnotes_holder"></div></body></html>'
|
11
|
-
end
|
12
|
-
|
13
|
-
def foo_js
|
14
|
-
render inline: '<script></script>', content_type: 'text/javascript'
|
15
|
-
end
|
16
|
-
|
17
|
-
def foo_download
|
18
|
-
send_file Rails.root.join('fixtures', 'html_download.html'), :disposition => 'attachment'
|
19
|
-
end
|
20
|
-
|
21
|
-
end
|
22
|
-
|
23
|
-
describe FootnotesController, type: :controller do
|
24
|
-
|
25
|
-
shared_examples 'has_footnotes' do
|
26
|
-
it 'includes footnotes' do
|
27
|
-
get :foo
|
28
|
-
expect(response.body).to have_selector('#footnotes_debug')
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
shared_examples 'has_no_footnotes' do
|
33
|
-
it 'does not include footnotes' do
|
34
|
-
expect(response.body).not_to have_selector('#footnotes_debug')
|
35
|
-
end
|
36
|
-
end
|
37
|
-
|
38
|
-
it 'does not alter the page by default' do
|
39
|
-
get :foo
|
40
|
-
expect(response.body).to eq(HTML_DOCUMENT)
|
41
|
-
end
|
42
|
-
|
43
|
-
context 'with footnotes' do
|
44
|
-
|
45
|
-
before :all do
|
46
|
-
Footnotes.enabled = true
|
47
|
-
end
|
48
|
-
|
49
|
-
after :all do
|
50
|
-
Footnotes.enabled = false
|
51
|
-
end
|
52
|
-
|
53
|
-
describe 'by default' do
|
54
|
-
include_context 'has_footnotes'
|
55
|
-
|
56
|
-
before do
|
57
|
-
get :foo
|
58
|
-
end
|
59
|
-
|
60
|
-
it 'includes footnotes in the last div in body' do
|
61
|
-
expect(all('body > :last-child')[0][:id]).to eq('footnotes_debug')
|
62
|
-
end
|
63
|
-
|
64
|
-
it 'includes footnotes in the footnoted_holder div if present' do
|
65
|
-
get :foo_holder
|
66
|
-
expect(response.body).to have_selector('#footnotes_holder > #footnotes_debug')
|
67
|
-
end
|
68
|
-
|
69
|
-
it 'does not alter a html file download' do
|
70
|
-
get :foo_download
|
71
|
-
expect(response.body).to eq(File.open(Rails.root.join('fixtures', 'html_download.html')).read)
|
72
|
-
end
|
73
|
-
end
|
74
|
-
|
75
|
-
describe 'when request is xhr' do
|
76
|
-
include_context 'has_no_footnotes'
|
77
|
-
before do
|
78
|
-
get :foo, xhr: true
|
79
|
-
end
|
80
|
-
end
|
81
|
-
|
82
|
-
describe 'when content type is javascript' do
|
83
|
-
include_context 'has_no_footnotes'
|
84
|
-
before do
|
85
|
-
get :foo_js
|
86
|
-
end
|
87
|
-
end
|
88
|
-
|
89
|
-
describe 'when footnotes is disabled' do
|
90
|
-
include_context 'has_no_footnotes'
|
91
|
-
before do
|
92
|
-
Footnotes.enabled = false
|
93
|
-
get :foo
|
94
|
-
end
|
95
|
-
end
|
96
|
-
|
97
|
-
describe 'with a proc' do
|
98
|
-
|
99
|
-
it 'yields the controller' do
|
100
|
-
c = nil
|
101
|
-
Footnotes.enabled = lambda { |controller| c = controller}
|
102
|
-
get :foo
|
103
|
-
expect(c).to be_kind_of(ActionController::Base)
|
104
|
-
end
|
105
|
-
|
106
|
-
context 'returning true' do
|
107
|
-
include_context 'has_footnotes'
|
108
|
-
|
109
|
-
before do
|
110
|
-
Footnotes.enabled = lambda { true }
|
111
|
-
get :foo
|
112
|
-
end
|
113
|
-
end
|
114
|
-
|
115
|
-
context 'returning false' do
|
116
|
-
include_context 'has_no_footnotes'
|
117
|
-
|
118
|
-
before do
|
119
|
-
Footnotes.enabled = lambda { false }
|
120
|
-
get :foo
|
121
|
-
end
|
122
|
-
end
|
123
|
-
|
124
|
-
end
|
125
|
-
|
126
|
-
end
|
127
|
-
|
128
|
-
end
|
@@ -1,32 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require 'stringio'
|
3
|
-
|
4
|
-
describe 'log note', type: :controller do
|
5
|
-
|
6
|
-
class ApplicationController < ActionController::Base
|
7
|
-
end
|
8
|
-
|
9
|
-
controller do
|
10
|
-
def index
|
11
|
-
Rails.logger.error 'foo'
|
12
|
-
Rails.logger.warn 'bar'
|
13
|
-
render inline: '<html><head></head><body></body></html>', content_type: 'text/html'
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
|
-
before :all do
|
18
|
-
Footnotes.enabled = true
|
19
|
-
end
|
20
|
-
|
21
|
-
after :all do
|
22
|
-
Footnotes.enabled = false
|
23
|
-
end
|
24
|
-
|
25
|
-
it 'Includes the log in the response' do
|
26
|
-
get :index
|
27
|
-
log_debug = first('fieldset#log_debug_info div', :visible => false)
|
28
|
-
expect(log_debug).to have_content('foo')
|
29
|
-
expect(log_debug).to have_content('bar')
|
30
|
-
end
|
31
|
-
|
32
|
-
end
|
@@ -1,28 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
class PartialsController < ActionController::Base
|
4
|
-
|
5
|
-
def index
|
6
|
-
end
|
7
|
-
|
8
|
-
end
|
9
|
-
|
10
|
-
describe PartialsController, type: :controller do
|
11
|
-
|
12
|
-
render_views
|
13
|
-
|
14
|
-
before :all do
|
15
|
-
Footnotes.enabled = true
|
16
|
-
end
|
17
|
-
|
18
|
-
after :all do
|
19
|
-
Footnotes.enabled = false
|
20
|
-
end
|
21
|
-
|
22
|
-
it 'lists the rendered partials' do
|
23
|
-
get :index
|
24
|
-
expect(response.body).to have_selector('#footnotes_debug #partials_debug_info table tr', :visible => false, :count => 2)
|
25
|
-
end
|
26
|
-
|
27
|
-
|
28
|
-
end
|
data/spec/env_note_spec.rb
DELETED
@@ -1,73 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require 'action_controller'
|
3
|
-
require 'action_controller/test_case'
|
4
|
-
|
5
|
-
class FootnotesEnvController < ActionController::Base
|
6
|
-
attr_accessor :template, :performed_render
|
7
|
-
end
|
8
|
-
|
9
|
-
describe Footnotes::Notes::EnvNote do
|
10
|
-
let(:controller) {
|
11
|
-
FootnotesEnvController.new.tap { |c|
|
12
|
-
c.template = Object.new
|
13
|
-
c.request = ActionDispatch::TestRequest.create
|
14
|
-
c.response = ActionDispatch::TestResponse.new
|
15
|
-
c.response_body = %Q(<html><body></body></html>)
|
16
|
-
c.params = {}
|
17
|
-
}
|
18
|
-
}
|
19
|
-
|
20
|
-
subject { described_class.new(controller) }
|
21
|
-
|
22
|
-
before do
|
23
|
-
@notes = Footnotes::Filter.notes
|
24
|
-
Footnotes::Filter.notes = [ :env ]
|
25
|
-
end
|
26
|
-
|
27
|
-
after do
|
28
|
-
Footnotes::Filter.notes = @notes
|
29
|
-
end
|
30
|
-
|
31
|
-
it '#to_sym is :env' do
|
32
|
-
expect(subject.to_sym).to eq(:env)
|
33
|
-
end
|
34
|
-
|
35
|
-
context 'with non-spec env keys' do
|
36
|
-
before :each do
|
37
|
-
controller.request.env.replace(:non_spec => 'symbol_env')
|
38
|
-
end
|
39
|
-
|
40
|
-
it 'does not raise an exception' do
|
41
|
-
expect { subject.content }.not_to raise_error
|
42
|
-
end
|
43
|
-
|
44
|
-
it 'includes the environment row' do
|
45
|
-
expect(subject).to receive(:mount_table).
|
46
|
-
with([ [ :key, 'value' ], [ 'non_spec', 'symbol_env' ] ])
|
47
|
-
subject.content
|
48
|
-
end
|
49
|
-
end
|
50
|
-
|
51
|
-
it 'includes values for all of the keys except HTTP_COOKIE' do
|
52
|
-
env = controller.request.env.dup
|
53
|
-
env.delete('HTTP_COOKIE')
|
54
|
-
|
55
|
-
env_data = env.map { |k, v| [ k.to_s, subject.escape(v.to_s) ] }.
|
56
|
-
sort.
|
57
|
-
unshift([ :key, 'value' ])
|
58
|
-
|
59
|
-
expect(subject).to receive(:mount_table).with(env_data)
|
60
|
-
subject.content
|
61
|
-
end
|
62
|
-
|
63
|
-
it 'gets a link for HTTP_COOKIE' do
|
64
|
-
controller.request.env.replace('HTTP_COOKIE' => 'foo')
|
65
|
-
expect(subject).to receive(:mount_table).
|
66
|
-
with([
|
67
|
-
[ :key, 'value' ],
|
68
|
-
[ 'HTTP_COOKIE',
|
69
|
-
'<a href="#" style="color:#009" onclick="Footnotes.hideAllAndToggle(\'cookies_debug_info\');return false;">See cookies on its tab</a>' ]
|
70
|
-
])
|
71
|
-
subject.content
|
72
|
-
end
|
73
|
-
end
|