twitter-bootstrap-rails 5.4.0 → 5.5.1
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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +68 -0
- data/README.md +104 -1
- data/app/helpers/badge_label_helper.rb +5 -6
- data/app/helpers/bootstrap_flash_helper.rb +10 -5
- data/app/helpers/flash_block_helper.rb +6 -4
- data/app/helpers/form_errors_helper.rb +3 -2
- data/app/helpers/modal_helper.rb +13 -13
- data/app/helpers/navbar_helper.rb +54 -47
- data/app/helpers/twitter_breadcrumbs_helper.rb +2 -2
- data/app/views/twitter-bootstrap/_breadcrumbs.html.erb +11 -11
- data/lib/generators/bootstrap/agent/agent_generator.rb +86 -0
- data/lib/generators/bootstrap/agent/templates/guide.md.erb +73 -0
- data/lib/generators/bootstrap/doctor/doctor_generator.rb +49 -0
- data/lib/generators/bootstrap/partial/templates/_login.html.erb +11 -15
- data/lib/generators/bootstrap/snippets/snippet_base.rb +23 -4
- data/lib/generators/bootstrap/themed/templates/_form.html.haml +7 -9
- data/lib/generators/bootstrap/themed/templates/_form.html.slim +8 -10
- data/lib/generators/bootstrap/themed/templates/edit.html.erb +1 -1
- data/lib/generators/bootstrap/themed/templates/edit.html.haml +1 -1
- data/lib/generators/bootstrap/themed/templates/edit.html.slim +1 -1
- data/lib/generators/bootstrap/themed/templates/index.html.haml +4 -4
- data/lib/generators/bootstrap/themed/templates/index.html.slim +4 -4
- data/lib/generators/bootstrap/themed/templates/new.html.erb +1 -1
- data/lib/generators/bootstrap/themed/templates/new.html.haml +1 -1
- data/lib/generators/bootstrap/themed/templates/new.html.slim +1 -1
- data/lib/generators/bootstrap/themed/templates/show.html.erb +1 -1
- data/lib/generators/bootstrap/themed/templates/show.html.haml +3 -3
- data/lib/generators/bootstrap/themed/templates/show.html.slim +3 -3
- data/lib/generators/bootstrap/themed/templates/simple_form/_form.html.erb +1 -1
- data/lib/generators/bootstrap/themed/templates/simple_form/_form.html.haml +2 -2
- data/lib/generators/bootstrap/themed/templates/simple_form/_form.html.slim +2 -2
- data/lib/twitter/bootstrap/rails/doctor.rb +238 -0
- data/lib/twitter/bootstrap/rails/legacy_markup.rb +119 -0
- data/lib/twitter/bootstrap/rails/v6_migration.rb +156 -0
- data/lib/twitter/bootstrap/rails/version.rb +1 -1
- data/spec/lib/breadcrumbs_spec.rb +8 -2
- data/spec/lib/generators/agent_generator_spec.rb +120 -0
- data/spec/lib/generators/doctor_generator_spec.rb +272 -0
- data/spec/lib/generators/snippet_generators_spec.rb +23 -0
- data/spec/lib/twitter_bootstrap_rails/badge_label_helper_spec.rb +7 -3
- data/spec/lib/twitter_bootstrap_rails/bootstrap_flash_helper_spec.rb +23 -45
- data/spec/lib/twitter_bootstrap_rails/breadcrumbs_view_spec.rb +35 -0
- data/spec/lib/twitter_bootstrap_rails/flash_block_helper_spec.rb +26 -0
- data/spec/lib/twitter_bootstrap_rails/form_errors_helper_spec.rb +2 -2
- data/spec/lib/twitter_bootstrap_rails/legacy_markup_spec.rb +74 -0
- data/spec/lib/twitter_bootstrap_rails/modal_helper_spec.rb +21 -8
- data/spec/lib/twitter_bootstrap_rails/navbar_helper_spec.rb +94 -92
- data/spec/lib/twitter_bootstrap_rails/v6_migration_spec.rb +98 -0
- data/spec/spec_helper.rb +0 -1
- data/spec/support/generator_spec_helper.rb +2 -0
- metadata +24 -3
|
@@ -40,6 +40,10 @@ describe NavbarHelper, :type => :helper do
|
|
|
40
40
|
.to eql(INVERSE_NAVBAR.gsub(/\s/, '').downcase)
|
|
41
41
|
end
|
|
42
42
|
|
|
43
|
+
it "should mark an inverse navbar as dark" do
|
|
44
|
+
expect(nav_bar(:inverse => true)).to have_tag(:nav, with: { 'data-bs-theme' => 'dark' })
|
|
45
|
+
end
|
|
46
|
+
|
|
43
47
|
it "should add the brand name and link it to the home page" do
|
|
44
48
|
expect(nav_bar(:brand => "Ninety Ten").gsub(/\s/, '').downcase)
|
|
45
49
|
.to eql(NAVBAR_WITH_BRAND.gsub(/\s/, '').downcase)
|
|
@@ -86,7 +90,7 @@ describe NavbarHelper, :type => :helper do
|
|
|
86
90
|
menu_item("Home", "/") + menu_item("Products", "/products")
|
|
87
91
|
end
|
|
88
92
|
|
|
89
|
-
expect(element).to have_tag(:ul, with: {class: "
|
|
93
|
+
expect(element).to have_tag(:ul, with: {class: "navbar-nav"}) {
|
|
90
94
|
with_tag(:li) {
|
|
91
95
|
with_tag(:a, text: "Home", with: {href: "/"})
|
|
92
96
|
}
|
|
@@ -96,12 +100,12 @@ describe NavbarHelper, :type => :helper do
|
|
|
96
100
|
}
|
|
97
101
|
end
|
|
98
102
|
|
|
99
|
-
it "should return a ul with class .
|
|
103
|
+
it "should return a ul with class .me-auto when passed the {pull: :left} option" do
|
|
100
104
|
element = menu_group(pull: :left) do
|
|
101
105
|
menu_item("Home", "/")
|
|
102
106
|
end
|
|
103
107
|
|
|
104
|
-
expect(element).to have_tag(:ul, with: {class: "
|
|
108
|
+
expect(element).to have_tag(:ul, with: {class: "navbar-nav me-auto"}) {
|
|
105
109
|
with_tag(:li) {
|
|
106
110
|
with_tag(:a, text: "Home", with: {href: "/"})
|
|
107
111
|
}
|
|
@@ -114,28 +118,30 @@ describe NavbarHelper, :type => :helper do
|
|
|
114
118
|
allow(self).to receive(:current_page?) { false }
|
|
115
119
|
|
|
116
120
|
element = menu_item("Home", "/")
|
|
117
|
-
expect(element).to have_tag(:li) {
|
|
118
|
-
with_tag(:a, text: "Home", with: { href: "/" })
|
|
121
|
+
expect(element).to have_tag(:li, with: {class: "nav-item"}) {
|
|
122
|
+
with_tag(:a, text: "Home", with: { href: "/", class: "nav-link" })
|
|
119
123
|
}
|
|
124
|
+
expect(element).not_to have_tag(:a, with: {class: "active"})
|
|
120
125
|
end
|
|
121
126
|
|
|
122
|
-
it "should
|
|
127
|
+
it "should mark the link, not the li, as active on the current page" do
|
|
123
128
|
allow(self).to receive(:uri_state) { :active }
|
|
124
129
|
|
|
125
130
|
element = menu_item("Home", "/")
|
|
126
|
-
expect(element).to have_tag(:li, with: {class: "
|
|
127
|
-
with_tag(:a, text: "Home", with: { href: "/" })
|
|
131
|
+
expect(element).to have_tag(:li, with: {class: "nav-item"}) {
|
|
132
|
+
with_tag(:a, text: "Home", with: { href: "/", class: "nav-link active", "aria-current" => "page" })
|
|
128
133
|
}
|
|
134
|
+
expect(element).not_to have_tag(:li, with: {class: "active"})
|
|
129
135
|
end
|
|
130
136
|
|
|
131
137
|
it "should pass any other options through to the link_to method" do
|
|
132
138
|
allow(self).to receive_message_chain("uri_state").and_return(:active)
|
|
133
139
|
|
|
134
140
|
element = menu_item("Log out", "/users/sign_out", class: "home_link", method: :delete)
|
|
135
|
-
expect(element).to have_tag(:li
|
|
141
|
+
expect(element).to have_tag(:li) {
|
|
136
142
|
with_tag(:a, text: "Log out", with: {
|
|
137
143
|
href: "/users/sign_out",
|
|
138
|
-
class: "home_link",
|
|
144
|
+
class: "nav-link active home_link",
|
|
139
145
|
rel: "nofollow",
|
|
140
146
|
"data-method" => "delete"
|
|
141
147
|
})
|
|
@@ -166,9 +172,8 @@ describe NavbarHelper, :type => :helper do
|
|
|
166
172
|
allow(self).to receive(:uri_state) { :active }
|
|
167
173
|
|
|
168
174
|
element = menu_item("/"){ content_tag("i", "", :class => "icon-home") + " Home" }
|
|
169
|
-
expect(element).to have_tag(:
|
|
175
|
+
expect(element).to have_tag(:a, with: { href: "/", class: "nav-link active" }) {
|
|
170
176
|
with_tag(:i, with: { class: "icon-home"})
|
|
171
|
-
with_tag(:a, text: " Home", with: { href: "/"})
|
|
172
177
|
}
|
|
173
178
|
end
|
|
174
179
|
end
|
|
@@ -178,8 +183,34 @@ describe NavbarHelper, :type => :helper do
|
|
|
178
183
|
ele = drop_down "Products" do
|
|
179
184
|
menu_item "Latest", "/"
|
|
180
185
|
end
|
|
181
|
-
expect(ele).to have_tag(:li, with: {class: 'dropdown'})
|
|
182
|
-
expect(ele).to have_tag(:a, with: {class: 'dropdown-toggle'})
|
|
186
|
+
expect(ele).to have_tag(:li, with: {class: 'nav-item dropdown'})
|
|
187
|
+
expect(ele).to have_tag(:a, with: {class: 'nav-link dropdown-toggle', role: 'button', 'data-bs-toggle' => 'dropdown', 'aria-expanded' => 'false'})
|
|
188
|
+
expect(ele).not_to have_tag(:b, with: {class: 'caret'})
|
|
189
|
+
end
|
|
190
|
+
|
|
191
|
+
it "should render items inside it as dropdown items, not nav links" do
|
|
192
|
+
ele = drop_down "Products" do
|
|
193
|
+
menu_item "Latest", "/"
|
|
194
|
+
end
|
|
195
|
+
expect(ele).to have_tag(:a, text: "Latest", with: {class: 'dropdown-item'})
|
|
196
|
+
expect(ele).not_to have_tag(:a, text: "Latest", with: {class: 'nav-link'})
|
|
197
|
+
end
|
|
198
|
+
|
|
199
|
+
it "should render items after it as nav links again" do
|
|
200
|
+
drop_down("Products") { menu_item "Latest", "/" }
|
|
201
|
+
expect(menu_item("Home", "/")).to have_tag(:a, with: {class: 'nav-link'})
|
|
202
|
+
end
|
|
203
|
+
end
|
|
204
|
+
|
|
205
|
+
describe "drop_down_divider" do
|
|
206
|
+
it "should render a dropdown divider" do
|
|
207
|
+
expect(drop_down_divider).to have_tag(:li) { with_tag(:hr, with: {class: 'dropdown-divider'}) }
|
|
208
|
+
end
|
|
209
|
+
end
|
|
210
|
+
|
|
211
|
+
describe "drop_down_header" do
|
|
212
|
+
it "should render a dropdown header" do
|
|
213
|
+
expect(drop_down_header("Fruit")).to have_tag(:li) { with_tag(:h6, text: "Fruit", with: {class: 'dropdown-header'}) }
|
|
183
214
|
end
|
|
184
215
|
end
|
|
185
216
|
|
|
@@ -194,30 +225,42 @@ describe NavbarHelper, :type => :helper do
|
|
|
194
225
|
expect(ele).to have_tag(:a, with: {class: 'dropdown-toggle'})
|
|
195
226
|
expect(ele).to have_tag(:ul, with: {class: 'dropdown-menu'})
|
|
196
227
|
end
|
|
228
|
+
|
|
229
|
+
# Bootstrap 5 has no nested dropdowns, so a submenu becomes a labelled group.
|
|
230
|
+
it "should render the submenu as a header followed by its items" do
|
|
231
|
+
ele = drop_down_with_submenu "Products" do
|
|
232
|
+
drop_down_submenu "Latest" do
|
|
233
|
+
menu_item "Option1", "/"
|
|
234
|
+
end
|
|
235
|
+
end
|
|
236
|
+
expect(ele).to have_tag(:h6, text: "Latest", with: {class: 'dropdown-header'})
|
|
237
|
+
expect(ele).to have_tag(:a, text: "Option1", with: {class: 'dropdown-item'})
|
|
238
|
+
expect(ele).not_to have_tag(:li, with: {class: 'dropdown-submenu'})
|
|
239
|
+
end
|
|
197
240
|
end
|
|
198
241
|
|
|
199
242
|
describe "menu_divider" do
|
|
200
|
-
it "should render
|
|
201
|
-
expect(menu_divider).to
|
|
243
|
+
it "should render a vertical rule" do
|
|
244
|
+
expect(menu_divider).to have_tag(:li, with: {class: 'nav-item'}) { with_tag(:div, with: {class: 'vr'}) }
|
|
202
245
|
end
|
|
203
246
|
end
|
|
204
247
|
|
|
205
248
|
describe "menu_text" do
|
|
206
|
-
it "should render text within
|
|
207
|
-
expect(menu_text("Strapline!")).to match("<
|
|
249
|
+
it "should render text within span tags with class 'navbar-text" do
|
|
250
|
+
expect(menu_text("Strapline!")).to match("<span class=\"navbar-text\">Strapline!</span>")
|
|
208
251
|
end
|
|
209
252
|
|
|
210
253
|
it "should be able to be pulled right or left" do
|
|
211
|
-
expect(menu_text("I am being pulled right", :pull => :right)).to match("<
|
|
254
|
+
expect(menu_text("I am being pulled right", :pull => :right)).to match("<span class=\"ms-auto navbar-text\">I am being pulled right</span>")
|
|
212
255
|
end
|
|
213
256
|
|
|
214
|
-
it "should be able to cope with arbitrary options being passed to the
|
|
215
|
-
expect(menu_text("I am classy!", :class => "classy", :id => "classy_text")).to match("<
|
|
257
|
+
it "should be able to cope with arbitrary options being passed to the span tag" do
|
|
258
|
+
expect(menu_text("I am classy!", :class => "classy", :id => "classy_text")).to match("<span class=\"classy navbar-text\" id=\"classy_text\">I am classy!</span>")
|
|
216
259
|
end
|
|
217
260
|
|
|
218
261
|
it "should be able to cope with a block too" do
|
|
219
262
|
ele = menu_text("I have been rendered programmatically!")
|
|
220
|
-
expect(ele).to have_tag(:
|
|
263
|
+
expect(ele).to have_tag(:span, with: {class: "navbar-text"})
|
|
221
264
|
expect(ele).to match "I have been rendered programmatically!"
|
|
222
265
|
end
|
|
223
266
|
end
|
|
@@ -236,7 +279,7 @@ describe NavbarHelper, :type => :helper do
|
|
|
236
279
|
|
|
237
280
|
describe "default navbar" do
|
|
238
281
|
it "renders a navbar" do
|
|
239
|
-
expect(nav_bar { 'foo' }).to have_tag(:nav, with: { class: 'navbar navbar-
|
|
282
|
+
expect(nav_bar { 'foo' }).to have_tag(:nav, with: { class: 'navbar navbar-expand bg-body-tertiary', role: 'navigation' }, text: /foo/)
|
|
240
283
|
end
|
|
241
284
|
end
|
|
242
285
|
|
|
@@ -245,42 +288,42 @@ end
|
|
|
245
288
|
# HTML output
|
|
246
289
|
|
|
247
290
|
BASIC_NAVBAR = <<-HTML
|
|
248
|
-
<nav class="navbar navbar-
|
|
291
|
+
<nav class="navbar navbar-expand bg-body-tertiary" role="navigation">
|
|
249
292
|
<div class="container">
|
|
250
293
|
</div>
|
|
251
294
|
</nav>
|
|
252
295
|
HTML
|
|
253
296
|
|
|
254
297
|
FIXED_TOP_NAVBAR = <<-HTML
|
|
255
|
-
<nav class="navbar navbar-
|
|
298
|
+
<nav class="navbar navbar-expand bg-body-tertiary fixed-top" role="navigation">
|
|
256
299
|
<div class="container">
|
|
257
300
|
</div>
|
|
258
301
|
</nav>
|
|
259
302
|
HTML
|
|
260
303
|
|
|
261
304
|
STATIC_TOP_NAVBAR = <<-HTML
|
|
262
|
-
<nav class="navbar navbar-
|
|
305
|
+
<nav class="navbar navbar-expand bg-body-tertiary" role="navigation">
|
|
263
306
|
<div class="container">
|
|
264
307
|
</div>
|
|
265
308
|
</nav>
|
|
266
309
|
HTML
|
|
267
310
|
|
|
268
311
|
FIXED_BOTTOM_NAVBAR = <<-HTML
|
|
269
|
-
<nav class="navbar navbar-
|
|
312
|
+
<nav class="navbar navbar-expand bg-body-tertiary fixed-bottom" role="navigation">
|
|
270
313
|
<div class="container">
|
|
271
314
|
</div>
|
|
272
315
|
</nav>
|
|
273
316
|
HTML
|
|
274
317
|
|
|
275
318
|
INVERSE_NAVBAR = <<-HTML
|
|
276
|
-
<nav class="navbar navbar-
|
|
319
|
+
<nav class="navbar navbar-expand bg-dark" data-bs-theme="dark" role="navigation">
|
|
277
320
|
<div class="container">
|
|
278
321
|
</div>
|
|
279
322
|
</nav>
|
|
280
323
|
HTML
|
|
281
324
|
|
|
282
325
|
NAVBAR_WITH_BRAND = <<-HTML
|
|
283
|
-
<nav class="navbar navbar-
|
|
326
|
+
<nav class="navbar navbar-expand bg-body-tertiary" role="navigation">
|
|
284
327
|
<div class="container">
|
|
285
328
|
<a class="navbar-brand" href="/">
|
|
286
329
|
Ninety Ten
|
|
@@ -290,7 +333,7 @@ NAVBAR_WITH_BRAND = <<-HTML
|
|
|
290
333
|
HTML
|
|
291
334
|
|
|
292
335
|
NAVBAR_WITH_BRAND_AND_LINK = <<-HTML
|
|
293
|
-
<nav class="navbar navbar-
|
|
336
|
+
<nav class="navbar navbar-expand bg-body-tertiary" role="navigation">
|
|
294
337
|
<div class="container">
|
|
295
338
|
<a class="navbar-brand" href="http://www.ninetyten.com">
|
|
296
339
|
Ninety Ten
|
|
@@ -300,49 +343,39 @@ NAVBAR_WITH_BRAND_AND_LINK = <<-HTML
|
|
|
300
343
|
HTML
|
|
301
344
|
|
|
302
345
|
RESPONSIVE_NAVBAR = <<-HTML
|
|
303
|
-
<nav class="navbar navbar-
|
|
346
|
+
<nav class="navbar navbar-expand-lg bg-body-tertiary" role="navigation">
|
|
304
347
|
<div class="container">
|
|
305
|
-
<
|
|
306
|
-
<
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
<span class="icon-bar"></span>
|
|
310
|
-
<span class="icon-bar"></span>
|
|
311
|
-
</button>
|
|
312
|
-
</div>
|
|
313
|
-
<div class="navbar-collapse collapse">
|
|
348
|
+
<button type="button" class="navbar-toggler" data-bs-toggle="collapse" data-bs-target=".navbar-collapse" aria-label="Toggle navigation">
|
|
349
|
+
<span class="navbar-toggler-icon"></span>
|
|
350
|
+
</button>
|
|
351
|
+
<div class="collapse navbar-collapse">
|
|
314
352
|
</div>
|
|
315
353
|
</div>
|
|
316
354
|
</nav>
|
|
317
355
|
HTML
|
|
318
356
|
|
|
319
357
|
RESPONSIVE_NAVBAR_WITH_BLOCK = <<-HTML
|
|
320
|
-
<nav class="navbar navbar-
|
|
358
|
+
<nav class="navbar navbar-expand-lg bg-body-tertiary" role="navigation">
|
|
321
359
|
<div class="container">
|
|
322
|
-
<
|
|
323
|
-
<
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
<span class="icon-bar"></span>
|
|
328
|
-
</button>
|
|
329
|
-
</div>
|
|
330
|
-
<div class="navbar-collapse collapse">
|
|
331
|
-
<p>Passing a block</p>
|
|
360
|
+
<button type="button" class="navbar-toggler" data-bs-toggle="collapse" data-bs-target=".navbar-collapse" aria-label="Toggle navigation">
|
|
361
|
+
<span class="navbar-toggler-icon"></span>
|
|
362
|
+
</button>
|
|
363
|
+
<div class="collapse navbar-collapse">
|
|
364
|
+
<p>Passing a block</p>
|
|
332
365
|
</div>
|
|
333
366
|
</div>
|
|
334
367
|
</nav>
|
|
335
368
|
HTML
|
|
336
369
|
|
|
337
370
|
PLAIN_NAVBAR_WITH_ITEM = <<-HTML
|
|
338
|
-
<nav class="navbar navbar-
|
|
371
|
+
<nav class="navbar navbar-expand bg-body-tertiary" role="navigation">
|
|
339
372
|
<div class="container">
|
|
340
|
-
<ul class="
|
|
341
|
-
<li>
|
|
342
|
-
<a href="/">Home</a>
|
|
373
|
+
<ul class="navbar-nav">
|
|
374
|
+
<li class="nav-item">
|
|
375
|
+
<a class="nav-link" href="/">Home</a>
|
|
343
376
|
</li>
|
|
344
|
-
<li>
|
|
345
|
-
<a href="/products">Products</a>
|
|
377
|
+
<li class="nav-item">
|
|
378
|
+
<a class="nav-link" href="/products">Products</a>
|
|
346
379
|
</li>
|
|
347
380
|
</ul>
|
|
348
381
|
</div>
|
|
@@ -350,47 +383,16 @@ PLAIN_NAVBAR_WITH_ITEM = <<-HTML
|
|
|
350
383
|
HTML
|
|
351
384
|
|
|
352
385
|
BRANDED_NAVBAR_WITH_ITEM = <<-HTML
|
|
353
|
-
<nav class="navbar navbar-
|
|
386
|
+
<nav class="navbar navbar-expand bg-body-tertiary" role="navigation">
|
|
354
387
|
<div class="container">
|
|
355
388
|
<a class="navbar-brand" href="/">
|
|
356
389
|
Something
|
|
357
390
|
</a>
|
|
358
|
-
<ul class="
|
|
359
|
-
<li>
|
|
360
|
-
<a href="/">Home</a>
|
|
391
|
+
<ul class="navbar-nav">
|
|
392
|
+
<li class="nav-item">
|
|
393
|
+
<a class="nav-link" href="/">Home</a>
|
|
361
394
|
</li>
|
|
362
395
|
</ul>
|
|
363
396
|
</div>
|
|
364
397
|
</nav>
|
|
365
398
|
HTML
|
|
366
|
-
|
|
367
|
-
DROPDOWN_MENU = <<-HTML
|
|
368
|
-
<li class="dropdown"> <a class="dropdown-toggle"data-toggle="dropdown"href="#"> Products <b class="caret"></b> </a> <ul class="dropdown-menu"> <li><a href="/">Latest</a></li> </ul> </li>
|
|
369
|
-
HTML
|
|
370
|
-
|
|
371
|
-
DROPDOWN_MENU_WITH_SUBMENU = <<-HTML
|
|
372
|
-
<li class="dropdown">
|
|
373
|
-
<a class="dropdown-toggle" data-toggle="dropdown" href="#">Products <b class="caret"></b></a>
|
|
374
|
-
<ul class="dropdown-menu">
|
|
375
|
-
<li class="dropdown-submenu">
|
|
376
|
-
<a href="">Latest</a>
|
|
377
|
-
<ul class="dropdown-menu">
|
|
378
|
-
<li><a href="/">Option1</a></li>
|
|
379
|
-
</ul>
|
|
380
|
-
</li>
|
|
381
|
-
</ul>
|
|
382
|
-
</li>
|
|
383
|
-
HTML
|
|
384
|
-
|
|
385
|
-
PLAIN_NAVBAR_WITH_FORM = <<-HTML
|
|
386
|
-
<nav class=\"navbar navbar-default\"role=\"navigation\">
|
|
387
|
-
<div class=\"container\">
|
|
388
|
-
<form accept-charset=\"utf-8\" action=\"/\" method=\"get\">
|
|
389
|
-
<div style=\"display:none\">
|
|
390
|
-
<input name=\"utf8\" type=\"hidden\" value=\"✓\"/>
|
|
391
|
-
</div>
|
|
392
|
-
<input id=\"search_stub\" name=\"search[stub]\" type=\"text\"/>
|
|
393
|
-
</form>
|
|
394
|
-
</div>
|
|
395
|
-
</nav>
|
|
396
|
-
HTML
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
require 'twitter/bootstrap/rails/v6_migration'
|
|
3
|
+
|
|
4
|
+
describe Twitter::Bootstrap::Rails::V6Migration do
|
|
5
|
+
def scan(text, extension = ".erb")
|
|
6
|
+
described_class.scan(text, extension)
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
def found(text, extension = ".erb")
|
|
10
|
+
scan(text, extension).map { |f| f[:found] }
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def replacements(text, extension = ".erb")
|
|
14
|
+
scan(text, extension).map { |f| f[:replacement] }
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
it "reports the line and the replacement" do
|
|
18
|
+
finding = scan(%{<p>ok</p>\n<div class="modal-body">x</div>}).first
|
|
19
|
+
|
|
20
|
+
expect(finding).to include(:line => 2, :found => "modal-body", :replacement => "dialog-body")
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
it "renames modal, offcanvas and dropdown classes" do
|
|
24
|
+
expect(replacements(%{<div class="offcanvas offcanvas-start dropdown-menu dropdown-item"></div>}))
|
|
25
|
+
.to eq(["drawer on a <dialog> element", "drawer-start", "menu", "menu-item"])
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
it "renames components under a breakpoint prefix" do
|
|
29
|
+
expect(replacements(%{<div class="offcanvas-lg dropdown-menu-md-end"></div>})).to eq(%w[lg:drawer md:menu-end])
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
it "moves breakpoints to a prefix" do
|
|
33
|
+
expect(replacements(%{<div class="col-md-6 d-lg-none p-sm-3 offset-xxl-2 sticky-md-top"></div>}))
|
|
34
|
+
.to eq(%w[md:col-6 lg:d-none sm:p-3 2xl:offset-2 md:sticky-top])
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
it "moves breakpoint suffixes to a prefix" do
|
|
38
|
+
expect(replacements(%{<nav class="navbar navbar-expand-lg"><div class="container-xxl table-responsive-sm"></div></nav>}))
|
|
39
|
+
.to eq(%w[lg:navbar-expand 2xl:container sm:table-responsive])
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
it "moves hover and print states to a prefix" do
|
|
43
|
+
expect(replacements(%{<a class="opacity-50-hover link-underline-opacity-75-hover d-print-none"></a>}))
|
|
44
|
+
.to eq(%w[hover:opacity-50 hover:underline-opacity-75 print:d-none])
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
it "replaces colour variants with theme classes" do
|
|
48
|
+
expect(replacements(%{<a class="btn btn-primary btn-outline-danger alert-info text-muted text-success"></a>}))
|
|
49
|
+
.to eq(["btn-solid theme-primary", "btn-outline theme-danger", "alert theme-info", "fg-secondary", "fg-success"])
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
it "maps font sizes to the t-shirt scale" do
|
|
53
|
+
expect(replacements(%{<p class="fs-1 fs-6"></p>})).to eq(%w[fs-4xl fs-md])
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
it "finds renamed toggle values in HTML and Ruby" do
|
|
57
|
+
expect(replacements(%{<button data-bs-toggle="modal" data-bs-dismiss='offcanvas'></button>}))
|
|
58
|
+
.to eq([%{data-bs-toggle="dialog"}, %{data-bs-dismiss="drawer"}])
|
|
59
|
+
expect(replacements(%{<%= link_to "x", "#", data: { bs_toggle: "dropdown" } %>}))
|
|
60
|
+
.to eq([%{data-bs-toggle="menu"}])
|
|
61
|
+
expect(replacements(%{<%= button_tag "x", data: { "bs-dismiss" => "modal" } %>}))
|
|
62
|
+
.to eq([%{data-bs-dismiss="dialog"}])
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
it "finds carousel autoplay" do
|
|
66
|
+
expect(found(%{<div class="carousel" data-bs-ride="carousel"></div>})).to eq(%w[data-bs-ride])
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
it "finds Sass and JavaScript that changed" do
|
|
70
|
+
expect(found(%{@import "bootstrap/scss/bootstrap";}, ".scss")).to eq([%{@import "bootstrap}])
|
|
71
|
+
expect(found("new bootstrap.Modal(el, { popperConfig: {} })", ".js")).to eq(%w[bootstrap.Modal popperConfig])
|
|
72
|
+
expect(found("color: rgba(var(--bs-primary-rgb), .5);", ".css")).to eq(%w[--bs-primary-rgb])
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
it "only reads class names in markup and Ruby files" do
|
|
76
|
+
expect(found(%{const html = '<div class="modal-body">'}, ".js")).to be_empty
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
it "finds class shorthand in Haml and Slim" do
|
|
80
|
+
expect(found("%button.btn.btn-primary Save", ".haml")).to eq(%w[btn-primary])
|
|
81
|
+
expect(found(".modal-dialog\n .modal-content", ".slim")).to eq(%w[modal-dialog modal-content])
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
it "leaves Bootstrap 6 markup alone" do
|
|
85
|
+
v6 = %{<dialog class="dialog"><div class="dialog-body md:col-6 btn-solid theme-primary fg-secondary fs-4xl"></div></dialog>}
|
|
86
|
+
|
|
87
|
+
expect(found(v6)).to be_empty
|
|
88
|
+
expect(found(%{<button data-bs-toggle="dialog"></button>})).to be_empty
|
|
89
|
+
end
|
|
90
|
+
|
|
91
|
+
it "matches whole class names only" do
|
|
92
|
+
expect(found(%{<div class="my-modal modal-bodywork"></div>})).to be_empty
|
|
93
|
+
end
|
|
94
|
+
|
|
95
|
+
it "has an example for every pattern, for the agent guide" do
|
|
96
|
+
expect(described_class::CLASS_PATTERNS.map(&:last)).to all(match(/ becomes? /))
|
|
97
|
+
end
|
|
98
|
+
end
|
data/spec/spec_helper.rb
CHANGED
|
@@ -8,6 +8,8 @@ require 'generators/bootstrap/install/install_generator'
|
|
|
8
8
|
require 'generators/bootstrap/layout/layout_generator'
|
|
9
9
|
require 'generators/bootstrap/starter/starter_generator'
|
|
10
10
|
require 'generators/bootstrap/cdn/cdn_generator'
|
|
11
|
+
require 'generators/bootstrap/doctor/doctor_generator'
|
|
12
|
+
require 'generators/bootstrap/agent/agent_generator'
|
|
11
13
|
require 'generators/bootstrap/snippets/snippet_catalog'
|
|
12
14
|
|
|
13
15
|
Bootstrap::Generators::SnippetCatalog::GENERATORS.each_key do |name|
|
metadata
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: twitter-bootstrap-rails
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 5.
|
|
4
|
+
version: 5.5.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Seyhun Akyurek
|
|
8
|
+
autorequire:
|
|
8
9
|
bindir: bin
|
|
9
10
|
cert_chain: []
|
|
10
|
-
date:
|
|
11
|
+
date: 2026-11-09 00:00:00.000000000 Z
|
|
11
12
|
dependencies:
|
|
12
13
|
- !ruby/object:Gem::Dependency
|
|
13
14
|
name: railties
|
|
@@ -71,11 +72,14 @@ files:
|
|
|
71
72
|
- app/helpers/navbar_helper.rb
|
|
72
73
|
- app/helpers/twitter_breadcrumbs_helper.rb
|
|
73
74
|
- app/views/twitter-bootstrap/_breadcrumbs.html.erb
|
|
75
|
+
- lib/generators/bootstrap/agent/agent_generator.rb
|
|
76
|
+
- lib/generators/bootstrap/agent/templates/guide.md.erb
|
|
74
77
|
- lib/generators/bootstrap/badge/badge_generator.rb
|
|
75
78
|
- lib/generators/bootstrap/breadcrumb/breadcrumb_generator.rb
|
|
76
79
|
- lib/generators/bootstrap/button/button_generator.rb
|
|
77
80
|
- lib/generators/bootstrap/cdn/cdn_generator.rb
|
|
78
81
|
- lib/generators/bootstrap/cdn_tags.rb
|
|
82
|
+
- lib/generators/bootstrap/doctor/doctor_generator.rb
|
|
79
83
|
- lib/generators/bootstrap/dropdown/dropdown_generator.rb
|
|
80
84
|
- lib/generators/bootstrap/features/features_generator.rb
|
|
81
85
|
- lib/generators/bootstrap/footer/footer_generator.rb
|
|
@@ -189,10 +193,15 @@ files:
|
|
|
189
193
|
- lib/twitter/bootstrap/rails/bootstrap.rb
|
|
190
194
|
- lib/twitter/bootstrap/rails/breadcrumbs.rb
|
|
191
195
|
- lib/twitter/bootstrap/rails/config.rb
|
|
196
|
+
- lib/twitter/bootstrap/rails/doctor.rb
|
|
192
197
|
- lib/twitter/bootstrap/rails/engine.rb
|
|
198
|
+
- lib/twitter/bootstrap/rails/legacy_markup.rb
|
|
199
|
+
- lib/twitter/bootstrap/rails/v6_migration.rb
|
|
193
200
|
- lib/twitter/bootstrap/rails/version.rb
|
|
194
201
|
- spec/lib/breadcrumbs_spec.rb
|
|
202
|
+
- spec/lib/generators/agent_generator_spec.rb
|
|
195
203
|
- spec/lib/generators/cdn_generator_spec.rb
|
|
204
|
+
- spec/lib/generators/doctor_generator_spec.rb
|
|
196
205
|
- spec/lib/generators/install_generator_spec.rb
|
|
197
206
|
- spec/lib/generators/layout_generator_spec.rb
|
|
198
207
|
- spec/lib/generators/no_hardcoded_versions_spec.rb
|
|
@@ -200,10 +209,14 @@ files:
|
|
|
200
209
|
- spec/lib/generators/starter_generator_spec.rb
|
|
201
210
|
- spec/lib/twitter_bootstrap_rails/badge_label_helper_spec.rb
|
|
202
211
|
- spec/lib/twitter_bootstrap_rails/bootstrap_flash_helper_spec.rb
|
|
212
|
+
- spec/lib/twitter_bootstrap_rails/breadcrumbs_view_spec.rb
|
|
213
|
+
- spec/lib/twitter_bootstrap_rails/flash_block_helper_spec.rb
|
|
203
214
|
- spec/lib/twitter_bootstrap_rails/form_errors_helper_spec.rb
|
|
215
|
+
- spec/lib/twitter_bootstrap_rails/legacy_markup_spec.rb
|
|
204
216
|
- spec/lib/twitter_bootstrap_rails/modal_helper_spec.rb
|
|
205
217
|
- spec/lib/twitter_bootstrap_rails/navbar_helper_spec.rb
|
|
206
218
|
- spec/lib/twitter_bootstrap_rails/uri_state_spec.rb
|
|
219
|
+
- spec/lib/twitter_bootstrap_rails/v6_migration_spec.rb
|
|
207
220
|
- spec/spec_helper.rb
|
|
208
221
|
- spec/support/generator_spec_helper.rb
|
|
209
222
|
- vendor/assets/javascripts/twitter/bootstrap/bootstrap.bundle.min.js
|
|
@@ -212,6 +225,7 @@ homepage: https://github.com/seyhunak/twitter-bootstrap-rails
|
|
|
212
225
|
licenses:
|
|
213
226
|
- MIT
|
|
214
227
|
metadata: {}
|
|
228
|
+
post_install_message:
|
|
215
229
|
rdoc_options: []
|
|
216
230
|
require_paths:
|
|
217
231
|
- lib
|
|
@@ -226,12 +240,15 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
226
240
|
- !ruby/object:Gem::Version
|
|
227
241
|
version: '0'
|
|
228
242
|
requirements: []
|
|
229
|
-
rubygems_version:
|
|
243
|
+
rubygems_version: 3.5.16
|
|
244
|
+
signing_key:
|
|
230
245
|
specification_version: 4
|
|
231
246
|
summary: Bootstrap 5 CSS toolkit for Rails 8, 7, 6, 5 Asset Pipeline
|
|
232
247
|
test_files:
|
|
233
248
|
- spec/lib/breadcrumbs_spec.rb
|
|
249
|
+
- spec/lib/generators/agent_generator_spec.rb
|
|
234
250
|
- spec/lib/generators/cdn_generator_spec.rb
|
|
251
|
+
- spec/lib/generators/doctor_generator_spec.rb
|
|
235
252
|
- spec/lib/generators/install_generator_spec.rb
|
|
236
253
|
- spec/lib/generators/layout_generator_spec.rb
|
|
237
254
|
- spec/lib/generators/no_hardcoded_versions_spec.rb
|
|
@@ -239,9 +256,13 @@ test_files:
|
|
|
239
256
|
- spec/lib/generators/starter_generator_spec.rb
|
|
240
257
|
- spec/lib/twitter_bootstrap_rails/badge_label_helper_spec.rb
|
|
241
258
|
- spec/lib/twitter_bootstrap_rails/bootstrap_flash_helper_spec.rb
|
|
259
|
+
- spec/lib/twitter_bootstrap_rails/breadcrumbs_view_spec.rb
|
|
260
|
+
- spec/lib/twitter_bootstrap_rails/flash_block_helper_spec.rb
|
|
242
261
|
- spec/lib/twitter_bootstrap_rails/form_errors_helper_spec.rb
|
|
262
|
+
- spec/lib/twitter_bootstrap_rails/legacy_markup_spec.rb
|
|
243
263
|
- spec/lib/twitter_bootstrap_rails/modal_helper_spec.rb
|
|
244
264
|
- spec/lib/twitter_bootstrap_rails/navbar_helper_spec.rb
|
|
245
265
|
- spec/lib/twitter_bootstrap_rails/uri_state_spec.rb
|
|
266
|
+
- spec/lib/twitter_bootstrap_rails/v6_migration_spec.rb
|
|
246
267
|
- spec/spec_helper.rb
|
|
247
268
|
- spec/support/generator_spec_helper.rb
|