flattened routes, lots of paths and arg changes

This commit is contained in:
Torsten 2022-11-30 16:22:11 +02:00
parent 1d91ff2fc6
commit df5713e6fe
31 changed files with 121 additions and 104 deletions

View File

@ -92,8 +92,19 @@ $ bundle
``` ```
Mount engine in routes for editing. Mount engine in routes for editing.
```ruby
mount Merged::Engine => "/merged"
```
Create route to serve content. Create route to serve content.
```ruby
get ":id" , to: "merged/view#view" , id: :id
```
If Merged served the root:
```ruby
root "merged/view#view" , id: 'index'
```
## Contributing ## Contributing
Ask first. Ask first.

View File

@ -1,9 +1,9 @@
module Merged module Merged
class CardsController < MergedController class CardsController < MergedController
before_action :set_page before_action :set_card , except: :index
def index def index
@section = Section.find(params[:section_id])
end end
private private

View File

@ -4,7 +4,7 @@ module Merged
# GET /merged/pages # GET /merged/pages
def index def index
@pages = Merged::Page.all @pages = Page.all.values
end end
# GET /merged/pages/1 # GET /merged/pages/1
@ -13,7 +13,6 @@ module Merged
# GET /merged/pages/new # GET /merged/pages/new
def new def new
@page = Merged::Page.new
end end
# GET /merged/pages/1/edit # GET /merged/pages/1/edit
@ -49,7 +48,7 @@ module Merged
private private
# Use callbacks to share common setup or constraints between actions. # Use callbacks to share common setup or constraints between actions.
def set_page def set_page
@page = Merged::Page.find(params[:id]) @page = Page.find(params[:id])
end end
# Only allow a list of trusted parameters through. # Only allow a list of trusted parameters through.

View File

@ -1,8 +1,11 @@
module Merged module Merged
class SectionsController < MergedController class SectionsController < MergedController
before_action :set_page before_action :set_section , except: :index
#, only: %i[ show edit update destroy set_image select_image] #, only: %i[ show edit update destroy set_image select_image]
def index
@page = Page.find(params[:page_id])
end
def select_image def select_image
@images = Image.all @images = Image.all
end end
@ -15,24 +18,24 @@ module Merged
def set_image def set_image
@section.content["image"] = params[:image] @section.content["image"] = params[:image]
@page.save @section.save
redirect_to page_section_url(@page.id,@section.id) redirect_to section_url(@section.id)
end end
def set_template def set_template
template = params[:template] template = params[:template]
raise "no template given" if template.blank? raise "no template given" if template.blank?
@section.content["template"] = template @section.content["template"] = template
@page.save @section.save
redirect_to page_section_url(@page.id,@section.id) redirect_to section_url(@section.id)
end end
def set_card_template def set_card_template
card_template = params[:card_template] card_template = params[:card_template]
raise "no card template given" if card_template.blank? raise "no card template given" if card_template.blank?
@section.content["card_template"] = card_template @section.content["card_template"] = card_template
@page.save @section.save
redirect_to page_section_url(@page.id,@section.id) redirect_to section_url(@section.id)
end end
def update def update
@ -43,15 +46,13 @@ module Merged
puts "updating:#{key}=#{params[key]}" puts "updating:#{key}=#{params[key]}"
end end
end end
@page.save @section.save
redirect_to :page_section redirect_to :section
end end
private private
def set_page def set_section
@page = Page.find(params[:page_id]) @section = Section.find( params[:id] || params[:section_id] )
section_id = params[:id] || params[:section_id]
@section = @page.find_section( section_id )
end end
end end

View File

@ -1,10 +0,0 @@
module Merged::SectionHelper
def section_form(options)
url = page_section_url( @page.id , @section.id)
puts "URL #{url}"
form_tag( url , {method: :patch}) do
yield
end
end
end

View File

@ -0,0 +1,17 @@
module Merged
module SectionsHelper
def section_form(options)
url = section_url( @section.id)
puts "URL #{url}"
form_tag( url , {method: :patch}) do
yield
end
end
def image_root
Image.image_root
end
end
end

View File

@ -7,10 +7,11 @@ module Merged
cattr_reader :all cattr_reader :all
@@all = {} @@all = {}
attr_reader :content , :section attr_reader :content , :index , :section
def initialize(section , card_data) def initialize(section , index , card_data)
@section = section @section = section
@index = index
raise "No data #{card_data}" unless card_data.is_a?(Hash) raise "No data #{card_data}" unless card_data.is_a?(Hash)
@content = card_data @content = card_data
raise "No id #{card_data}" unless id.is_a?(String) raise "No id #{card_data}" unless id.is_a?(String)
@ -20,5 +21,16 @@ module Merged
def id def id
@content['id'] @content['id']
end end
def save
section.save
end
def self.find(id)
raise "nil given" if id.blank?
card = @@all[id]
raise "Section not found #{id}" unless card
return card
end
end end
end end

View File

@ -35,7 +35,7 @@ module Merged
File.open(Rails.root.join(Image.asset_root, full_filename), "wb") do |f| File.open(Rails.root.join(Image.asset_root, full_filename), "wb") do |f|
f.write( io.read ) f.write( io.read )
end end
self.add( full_filename ) Image.new( full_filename )
end end
def self.asset_root def self.asset_root

View File

@ -26,22 +26,14 @@ module Merged
def initialize( file_name ) def initialize( file_name )
@name = file_name.split(".").first @name = file_name.split(".").first
@content = YAML.load_file(Rails.root.join(Page.cms_root , file_name)) @content = YAML.load_file(Rails.root.join(Page.cms_root , file_name))
@sections = {} @sections = []
@content.each_with_index do |section_data, index| @content.each_with_index do |section_data, index|
section = Section.new(self , index, section_data) section = Section.new(self , index, section_data)
@sections[ section.id] = section @sections << section
end end
@@all[@name] = self @@all[@name] = self
end end
def find_section(section_id)
@content.each_with_index do |section , index|
next unless section["id"] == section_id
return Section.new(self , index , section)
end
raise "Page #{name} as no section #{section_id}"
end
def first_template def first_template
@content[0]["template"] @content[0]["template"]
end end
@ -59,7 +51,11 @@ module Merged
end end
def self.find(name) def self.find(name)
@@all[name] raise "nil given" if name.blank?
page = @@all[name]
raise "Page not found #{name}" unless page
return page
end end
end end

View File

@ -16,12 +16,11 @@ module Merged
@index = index @index = index
@content = section_data @content = section_data
@@all[self.id] = self @@all[self.id] = self
@cards = {} @cards = []
element = @content["cards"] element = @content["cards"]
return if element.nil? return if element.nil?
element.each do|card_content| element.each_with_index do|card_content , index|
card = Card.new(self , card_content) @cards << Card.new(self , index , card_content)
@cards[card.id] = card
end end
end end
@ -48,12 +47,14 @@ module Merged
end end
def save def save
raise "Called" page.save
end end
def self.find(page_name , section_id) def self.find(section_id)
raise "buggy" raise "nil given" if section_id.blank?
Page.new(name + ".yaml") section = @@all[section_id]
raise "Section not found #{section_id}" unless section
return section
end end
end end

View File

@ -4,8 +4,8 @@
%p #{section.content['cards'].length} cards %p #{section.content['cards'].length} cards
%p view cards (index) %p view cards (index)
%button.ml-3.inline-block.rounded-lg.bg-blue-500.px-5.py-3.text-md.font-medium.text-white %button.ml-3.inline-block.rounded-lg.bg-blue-500.px-5.py-3.text-md.font-medium.text-white
=link_to "View and Edit Cards" , page_section_card_url(@page.name,@section.id) =link_to "View and Edit Cards" , section_card_url(@page.name,@section.id)
%button.ml-3.inline-block.rounded-lg.bg-blue-500.px-5.py-3.text-md.font-medium.text-white %button.ml-3.inline-block.rounded-lg.bg-blue-500.px-5.py-3.text-md.font-medium.text-white
=link_to "Change Card Template" , page_section_select_card_template_url(@page.name,@section.id) =link_to "Change Card Template" , section_select_card_template_url(@page.name,@section.id)
.relative.block.border.border-gray-100 .relative.block.border.border-gray-100
=image_tag("merged/card_preview/#{value}" , class: "w-full object-contain") =image_tag("merged/card_preview/#{value}" , class: "w-full object-contain")

View File

@ -1,9 +1,9 @@
.relative.block.border.border-gray-100 .relative.block.border.border-gray-100
%h3.mt-4.text-lg.font-bold= key.upcase %h3.mt-4.text-lg.font-bold= key.upcase
%button.ml-3.inline-block.rounded-lg.bg-blue-500.px-5.py-3.text-md.font-medium.text-white %button.ml-3.inline-block.rounded-lg.bg-blue-500.px-5.py-3.text-md.font-medium.text-white
=link_to "Change Image" , page_section_select_image_url(@page.name,@section.id) =link_to "Change Image" , section_select_image_url(@page.name,@section.id)
%button.ml-3.inline-block.rounded-lg.bg-red-500.px-5.py-3.text-md.font-medium.text-white %button.ml-3.inline-block.rounded-lg.bg-red-500.px-5.py-3.text-md.font-medium.text-white
= link_to( "Remove image" , page_section_set_image_path( @page.name, @section.id , image: "")) = link_to( "Remove image" , section_set_image_path( @page.name, @section.id , image: ""))
.relative.block.border.border-gray-100 .relative.block.border.border-gray-100

View File

@ -1,6 +1,6 @@
.relative.block.border.border-gray-100 .relative.block.border.border-gray-100
%h3.mt-4.text-lg.font-bold= key.upcase + " : " + value %h3.mt-4.text-lg.font-bold= key.upcase + " : " + value
%button.ml-3.inline-block.rounded-lg.bg-blue-500.px-5.py-3.text-md.font-medium.text-white %button.ml-3.inline-block.rounded-lg.bg-blue-500.px-5.py-3.text-md.font-medium.text-white
=link_to "Change Template" , page_section_select_template_url(@page.name,@section.id) =link_to "Change Template" , section_select_template_url(@section.id)
.relative.block.border.border-gray-100 .relative.block.border.border-gray-100
=image_tag("merged/section_preview/#{section.template}" , class: "w-full object-contain") =image_tag("merged/section_preview/#{section.template}" , class: "w-full object-contain")

View File

@ -4,10 +4,10 @@
.flex.items-center.justify-center.flex-1 .flex.items-center.justify-center.flex-1
.max-w-xl.px-4.py-8.mx-auto.text-center .max-w-xl.px-4.py-8.mx-auto.text-center
%h1.text-2xl.font-bold.tracking-tight.text-gray-900 %h1.text-2xl.font-bold.tracking-tight.text-gray-900
Page #{@page.name} Page #{@section.page.name}
.flex.items-center.justify-center.flex-1 .flex.items-center.justify-center.flex-1
%h3.text-xl.font-bold.tracking-tight.text-gray-900 %h3.text-xl.font-bold.tracking-tight.text-gray-900
Cards for Section #{@section.id} Cards for Section #{@section.index + 1}
.grid.grid-cols-4.gap-2.m-8 .grid.grid-cols-4.gap-2.m-8
- @section.cards.each_with_index do |card , index| - @section.cards.each_with_index do |card , index|
@ -19,7 +19,7 @@
%button.mt-4.rounded-lg.bg-yellow-500.p-4 %button.mt-4.rounded-lg.bg-yellow-500.p-4
=link_to "Down" , "/index" =link_to "Down" , "/index"
%button.mt-4.rounded-lg.bg-blue-400.p-4 %button.mt-4.rounded-lg.bg-blue-400.p-4
=link_to "Edit" , page_section_path(@page.name , @section.id) =link_to "Edit" , card_path( @section.id)
%button.mt-4.rounded-lg.bg-cyan-400.p-4 %button.mt-4.rounded-lg.bg-cyan-400.p-4
=link_to "New" , "/index" =link_to "New" , "/index"
%button.mt-4.rounded-lg.bg-red-400.p-4 %button.mt-4.rounded-lg.bg-red-400.p-4

View File

@ -1,10 +0,0 @@
= form_for @merged_page do |f|
- if @merged_page.errors.any?
#error_explanation
%h2= "#{pluralize(@merged_page.errors.count, "error")} prohibited this merged_page from being saved:"
%ul
- @merged_page.errors.full_messages.each do |message|
%li= message
.actions
= f.submit 'Save'

View File

@ -1,7 +0,0 @@
%h1 Editing #{@merged_page.name}
= render 'form'
= link_to 'Show', page_url(@merged_page.name)
\|
= link_to 'Back', pages_path

View File

@ -17,14 +17,14 @@
- @pages.each do |merged_page| - @pages.each do |merged_page|
%tr %tr
%td.whitespace-nowrap.px-4.py-2.text-gray-700 %td.whitespace-nowrap.px-4.py-2.text-gray-700
= link_to merged_page.name , page_path(merged_page.name) = link_to merged_page.name , page_sections_path(merged_page.name)
%td.whitespace-nowrap.px-4.py-2.text-gray-700 %td.whitespace-nowrap.px-4.py-2.text-gray-700
= merged_page.first_template = merged_page.first_template
%td.whitespace-nowrap.px-4.py-2.text-gray-700 %td.whitespace-nowrap.px-4.py-2.text-gray-700
= merged_page.content.length = merged_page.content.length
%td.whitespace-nowrap.px-4.py-2 %td.whitespace-nowrap.px-4.py-2
%strong.rounded.bg-green-100.px-3.text-xs.font-medium.text-green-700{:class => "py-1.5"} %strong.rounded.bg-green-100.px-3.text-xs.font-medium.text-green-700{:class => "py-1.5"}
= link_to 'Show', page_path(merged_page.name) = link_to 'Sections', page_sections_path(merged_page.name)
%strong.rounded.bg-amber-100.px-3.text-xs.font-medium.text-amber-700{:class => "py-1.5"} %strong.rounded.bg-amber-100.px-3.text-xs.font-medium.text-amber-700{:class => "py-1.5"}
= link_to 'Edit', edit_page_path(merged_page.name) = link_to 'Edit', edit_page_path(merged_page.name)

View File

@ -1,5 +0,0 @@
%h1 New merged_page
= render 'form'
= link_to 'Back', pages_path

View File

@ -5,17 +5,17 @@
%h1.text-2xl.font-bold.tracking-tight.text-gray-900.sm:text-4xl %h1.text-2xl.font-bold.tracking-tight.text-gray-900.sm:text-4xl
Page #{@page.name} Page #{@page.name}
-@page.sections.each_with_index do |section , index| -@page.sections.each do |section |
.grid.grid-cols-6.gap-2.m-8{class: (index%2)==1 ? 'bg-cyan-50' : 'bg-red-50' } .grid.grid-cols-6.gap-2.m-8{class: (section.index%2)==1 ? 'bg-cyan-50' : 'bg-red-50' }
.relative.block.border.border-gray-100 .relative.block.border.border-gray-100
.p-4 .p-4
%h3.mt-4.text-lg.font-bold Section #{index + 1} %h3.mt-4.text-lg.font-bold Section #{section.index + 1}
%button.mt-4.rounded-lg.bg-yellow-500.p-4 %button.mt-4.rounded-lg.bg-yellow-500.p-4
=link_to( "Up" , "/index") =link_to( "Up" , "/index")
%button.mt-4.rounded-lg.bg-yellow-500.p-4 %button.mt-4.rounded-lg.bg-yellow-500.p-4
=link_to "Down" , "/index" =link_to "Down" , "/index"
%button.mt-4.rounded-lg.bg-blue-400.p-4 %button.mt-4.rounded-lg.bg-blue-400.p-4
=link_to "Edit" , page_section_path(@page.name , section.id) =link_to "Edit" , section_path(section.id)
%button.mt-4.rounded-lg.bg-cyan-400.p-4 %button.mt-4.rounded-lg.bg-cyan-400.p-4
=link_to "New" , "/index" =link_to "New" , "/index"
%button.mt-4.rounded-lg.bg-red-400.p-4 %button.mt-4.rounded-lg.bg-red-400.p-4

View File

@ -4,8 +4,8 @@
%p #{section.content['cards'].length} cards %p #{section.content['cards'].length} cards
%p view cards (index) %p view cards (index)
%button.ml-3.inline-block.rounded-lg.bg-blue-500.px-5.py-3.text-md.font-medium.text-white %button.ml-3.inline-block.rounded-lg.bg-blue-500.px-5.py-3.text-md.font-medium.text-white
=link_to "View and Edit Cards" , page_section_card_url(@page.name,@section.id) =link_to "View and Edit Cards" , section_cards_url(@section.id)
%button.ml-3.inline-block.rounded-lg.bg-blue-500.px-5.py-3.text-md.font-medium.text-white %button.ml-3.inline-block.rounded-lg.bg-blue-500.px-5.py-3.text-md.font-medium.text-white
=link_to "Change Card Template" , page_section_select_card_template_url(@page.name,@section.id) =link_to "Change Card Template" , section_select_card_template_url(@section.id)
.relative.block.border.border-gray-100 .relative.block.border.border-gray-100
=image_tag("merged/card_preview/#{value}" , class: "w-full object-contain") =image_tag("merged/card_preview/#{value}" , class: "w-full object-contain")

View File

@ -1,9 +1,9 @@
.relative.block.border.border-gray-100 .relative.block.border.border-gray-100
%h3.mt-4.text-lg.font-bold= key.upcase %h3.mt-4.text-lg.font-bold= key.upcase
%button.ml-3.inline-block.rounded-lg.bg-blue-500.px-5.py-3.text-md.font-medium.text-white %button.ml-3.inline-block.rounded-lg.bg-blue-500.px-5.py-3.text-md.font-medium.text-white
=link_to "Change Image" , page_section_select_image_url(@page.name,@section.id) =link_to "Change Image" , section_select_image_url(@section.id)
%button.ml-3.inline-block.rounded-lg.bg-red-500.px-5.py-3.text-md.font-medium.text-white %button.ml-3.inline-block.rounded-lg.bg-red-500.px-5.py-3.text-md.font-medium.text-white
= link_to( "Remove image" , page_section_set_image_path( @page.name, @section.id , image: "")) = link_to( "Remove image" , section_set_image_path( @section.id , image: ""))
.relative.block.border.border-gray-100 .relative.block.border.border-gray-100

View File

@ -1,6 +1,6 @@
.relative.block.border.border-gray-100 .relative.block.border.border-gray-100
%h3.mt-4.text-lg.font-bold= key.upcase + " : " + value %h3.mt-4.text-lg.font-bold= key.upcase + " : " + value
%button.ml-3.inline-block.rounded-lg.bg-blue-500.px-5.py-3.text-md.font-medium.text-white %button.ml-3.inline-block.rounded-lg.bg-blue-500.px-5.py-3.text-md.font-medium.text-white
=link_to "Change Template" , page_section_select_template_url(@page.name,@section.id) =link_to "Change Template" , section_select_template_url(@section.id)
.relative.block.border.border-gray-100 .relative.block.border.border-gray-100
=image_tag("merged/section_preview/#{section.template}" , class: "w-full object-contain") =image_tag("merged/section_preview/#{section.template}" , class: "w-full object-contain")

View File

@ -5,17 +5,17 @@
%h1.text-2xl.font-bold.tracking-tight.text-gray-900.sm:text-4xl %h1.text-2xl.font-bold.tracking-tight.text-gray-900.sm:text-4xl
Page #{@page.name} Page #{@page.name}
-@page.sections.each_with_index do |section , index| -@page.sections.each do |section |
.grid.grid-cols-6.gap-2.m-8{class: (index%2)==1 ? 'bg-cyan-50' : 'bg-red-50' } .grid.grid-cols-6.gap-2.m-8{class: (section.index%2)==1 ? 'bg-cyan-50' : 'bg-red-50' }
.relative.block.border.border-gray-100 .relative.block.border.border-gray-100
.p-4 .p-4
%h3.mt-4.text-lg.font-bold Section #{index + 1} %h3.mt-4.text-lg.font-bold Section #{section.index + 1}
%button.mt-4.rounded-lg.bg-yellow-500.p-4 %button.mt-4.rounded-lg.bg-yellow-500.p-4
=link_to( "Up" , "/index") =link_to( "Up" , "/index")
%button.mt-4.rounded-lg.bg-yellow-500.p-4 %button.mt-4.rounded-lg.bg-yellow-500.p-4
=link_to "Down" , "/index" =link_to "Down" , "/index"
%button.mt-4.rounded-lg.bg-blue-400.p-4 %button.mt-4.rounded-lg.bg-blue-400.p-4
=link_to "Edit" , page_section_path(@page.name , section.id) =link_to "Edit" , section_path(section.id)
%button.mt-4.rounded-lg.bg-cyan-400.p-4 %button.mt-4.rounded-lg.bg-cyan-400.p-4
=link_to "New" , "/index" =link_to "New" , "/index"
%button.mt-4.rounded-lg.bg-red-400.p-4 %button.mt-4.rounded-lg.bg-red-400.p-4

View File

@ -1,6 +1,6 @@
.grid.grid-cols-4.gap-2.m-8 .grid.grid-cols-4.gap-2.m-8
- @cards.each do |style| - @cards.each do |style|
.relative.block.border.border-gray-100 .relative.block.border.border-gray-100
= link_to( page_section_set_card_template_path( card_template: style.template )) do = link_to( section_set_card_template_path( card_template: style.template )) do
=image_tag(style.card_preview , class: "h-56 w-full object-contain lg:h-72") =image_tag(style.card_preview , class: "h-56 w-full object-contain lg:h-72")
= style.header = style.header

View File

@ -5,11 +5,11 @@
= text_field_tag 'filename' = text_field_tag 'filename'
%h5.mt-4.text-lg.font-bold Name is optional %h5.mt-4.text-lg.font-bold Name is optional
%p will be taken from uploaded file %p will be taken from uploaded file
= hidden_field_tag :redirect , page_section_set_image_url(@page.name,@section.id,image: "NEW") = hidden_field_tag :redirect , section_set_image_url(@section.id,image: "NEW")
= file_field_tag 'image_file' = file_field_tag 'image_file'
.inline-block.rounded.border.border-indigo-600.bg-indigo-600.px-12.py-3.text-sm.font-medium.text-white.hover:bg-transparent.hover:text-indigo-600.focus:outline-none.focus:ring.active:text-indigo-500{:href => merged.new_image_path} .inline-block.rounded.border.border-indigo-600.bg-indigo-600.px-12.py-3.text-sm.font-medium.text-white.hover:bg-transparent.hover:text-indigo-600.focus:outline-none.focus:ring.active:text-indigo-500{:href => merged.new_image_path}
= submit_tag 'Submit' = submit_tag 'Submit'
-@images.each do |name , image| -@images.each do |name , image|
.relative.block.border.border-gray-100 .relative.block.border.border-gray-100
= link_to( page_section_set_image_path( image: name)) do = link_to( section_set_image_path( image: name)) do
=image_tag("cms/#{name}" , class: "h-56 w-full object-contain lg:h-72") =image_tag("#{image_root}/#{name}" , class: "h-56 w-full object-contain lg:h-72")

View File

@ -1,6 +1,6 @@
.grid.grid-cols-4.gap-2.m-8 .grid.grid-cols-4.gap-2.m-8
- @sections.each do |style| - @sections.each do |style|
.relative.block.border.border-gray-100 .relative.block.border.border-gray-100
= link_to( page_section_set_template_path( template: style.template )) do = link_to( section_set_template_path( template: style.template )) do
=image_tag(style.section_preview , class: "h-56 w-full object-contain lg:h-72") =image_tag(style.section_preview , class: "h-56 w-full object-contain lg:h-72")
= style.header = style.header

View File

@ -4,7 +4,7 @@
.flex.items-center.justify-center.flex-1 .flex.items-center.justify-center.flex-1
.max-w-xl.px-4.py-8.mx-auto.text-center .max-w-xl.px-4.py-8.mx-auto.text-center
%h1.text-2xl.font-bold.tracking-tight.text-gray-900 %h1.text-2xl.font-bold.tracking-tight.text-gray-900
Page #{@page.name} Page #{@section.page.name}
.flex.items-center.justify-center.flex-1 .flex.items-center.justify-center.flex-1
%h3.text-xl.font-bold.tracking-tight.text-gray-900 %h3.text-xl.font-bold.tracking-tight.text-gray-900
Section #{@section.id} Section #{@section.id}

View File

@ -1,7 +1,7 @@
Merged::Engine.routes.draw do Merged::Engine.routes.draw do
get "/styles/index" , to: "styles#index" get "/styles/index" , to: "styles#index"
resources :pages do resources :pages , shallow: true do
resources :sections do resources :sections do
get :select_image get :select_image
get :set_image get :set_image

View File

@ -10,5 +10,8 @@ module Merged
it "has cards" do it "has cards" do
expect(first.class).to be Card expect(first.class).to be Card
end end
it "has index" do
expect(first.index).to eq 0
end
end end
end end

View File

@ -13,5 +13,8 @@ module Merged
it "has sections" do it "has sections" do
expect(index.sections.length).to be 1 expect(index.sections.length).to be 1
end end
it "has section array" do
expect(index.sections.class).to be Array
end
end end
end end

View File

@ -10,8 +10,14 @@ module Merged
it "has index page" do it "has index page" do
expect(first.class).to be Section expect(first.class).to be Section
end end
it "has sections" do it "has index" do
expect(first.cards.length).to be 2 expect(first.index).to eq 0
end
it "has cards" do
expect(first.cards.length).to eq 2
end
it "has cards array" do
expect(first.cards.class).to be Array
end end
end end
end end