File tree Expand file tree Collapse file tree 6 files changed +20
-20
lines changed
Expand file tree Collapse file tree 6 files changed +20
-20
lines changed Original file line number Diff line number Diff line change @@ -15,7 +15,7 @@ def kata
1515
1616 def show
1717 @doc = Document . new ( params [ :id ] )
18- redirect_to root_url unless @doc . exists ?
18+ redirect_to root_url unless @doc . exist ?
1919
2020 if @doc . content . include? "NUM_OF_"
2121 @doc . content . gsub! "{{ NUM_OF_JAPAN_DOJOS }}" , Dojo . active_dojos_count . to_s
Original file line number Diff line number Diff line change @@ -55,21 +55,21 @@ def url
5555 "#{ URL_PATH } /#{ self . filename } "
5656 end
5757
58- def exists ?
58+ def exist ?
5959 return false if path . include? "\u0000 "
6060 Document . all . map ( &:filename ) . include? ( filename )
6161 end
6262
6363 def title
64- return '' unless self . exists ?
64+ return '' unless self . exist ?
6565 @title ||=
6666 ActionController ::Base . helpers . strip_tags (
6767 Kramdown ::Document . new ( self . get_first_paragraph , input : 'GFM' ) . to_html
6868 ) . strip
6969 end
7070
7171 def description
72- return '' unless self . exists ?
72+ return '' unless self . exist ?
7373 @desc ||=
7474 ActionController ::Base . helpers . strip_tags (
7575 Kramdown ::Document . new ( self . get_second_paragraph , input : 'GFM' ) . to_html
@@ -80,7 +80,7 @@ def description=(text)
8080 end
8181
8282 def content
83- @content ||= self . exists ? ? File . read ( self . path ) : ''
83+ @content ||= self . exist ? ? File . read ( self . path ) : ''
8484 end
8585
8686 private
Original file line number Diff line number Diff line change @@ -18,7 +18,7 @@ def path
1818 "#{ DIR_PATH } /#{ id } .md"
1919 end
2020
21- def exists ?( offset : 0 )
21+ def exist ?( offset : 0 )
2222 return false if self . path . include? ( "\u0000 " )
2323 return false if ( self . id + offset ) . zero?
2424 File . exist? ( "#{ DIR_PATH } /#{ id + offset } .md" )
@@ -30,6 +30,6 @@ def cover
3030 end
3131
3232 def content
33- exists ? ? File . read ( path ) : ''
33+ exist ? ? File . read ( path ) : ''
3434 end
3535end
Original file line number Diff line number Diff line change 11< div style ="display: table; font-weight: bolder; width: 100%; padding: 10px 10px; background-color:#3870c4; ">
22 < p class ="nav prev ">
3- <% if @episode . exists ?( offset : -1 ) %>
3+ <% if @episode . exist ?( offset : -1 ) %>
44 <%= link_to podcast_path ( @episode . id - 1 ) , title : '前のエピソードを見る' do %>
55 « prev
66 <% end %>
1212 <%= link_to '目次に戻る' . html_safe , podcasts_path %>
1313 </ p >
1414 < p class ="nav next ">
15- <% if @episode . exists ?( offset : +1 ) %>
15+ <% if @episode . exist ?( offset : +1 ) %>
1616 <%= link_to podcast_path ( @episode . id + 1 ) , title : '次のエピソードを見る' do %>
1717 next »
1818 <% end %>
Original file line number Diff line number Diff line change 99
1010 scenario 'Charter should be exist' do
1111 @podcast = create ( :podcast )
12- allow ( @podcast ) . to receive ( :exists ? ) { true }
13- allow ( @podcast ) . to receive ( :exists ? ) . with ( offset : -1 ) { false }
12+ allow ( @podcast ) . to receive ( :exist ? ) { true }
13+ allow ( @podcast ) . to receive ( :exist ? ) . with ( offset : -1 ) { false }
1414 allow ( @podcast ) . to receive ( :content ) { "title\n 収録日: 2019/05/10\n ..." }
1515 allow ( Podcast ) . to receive ( :find_by ) . with ( id : @podcast . id . to_s ) { @podcast }
1616
2525
2626 scenario 'Load doc file with absolute path' do
2727 @podcast = create ( :podcast )
28- allow ( @podcast ) . to receive ( :exists ? ) { true }
28+ allow ( @podcast ) . to receive ( :exist ? ) { true }
2929 allow ( @podcast ) . to receive ( :content ) { "title\n 収録日: 2019/05/10\n ..." }
3030 allow ( Podcast ) . to receive ( :find_by ) . with ( id : @podcast . id . to_s ) { @podcast }
3131
Original file line number Diff line number Diff line change 1010 expect ( @podcast . path ) . to eq ( "public/podcasts/#{ @podcast . id } .md" )
1111 end
1212
13- describe 'exists ?(offset: 0)' do
13+ describe 'exist ?(offset: 0)' do
1414 it '\u0000 を含む ⇒ false' do
1515 allow ( @podcast ) . to receive ( :path ) { "public/podcasts/\u0000 " }
1616
17- expect ( @podcast . exists ?) . to eq ( false )
17+ expect ( @podcast . exist ?) . to eq ( false )
1818 end
1919
2020 context 'offset 省略' do
2525 it 'ファイルあり ⇒ true' do
2626 allow ( File ) . to receive ( :exist? ) . with ( "public/podcasts/#{ @podcast . id } .md" ) { true }
2727
28- expect ( @podcast . exists ?) . to eq ( true )
28+ expect ( @podcast . exist ?) . to eq ( true )
2929 end
3030
3131 it 'ファイルなし ⇒ false' do
32- expect ( @podcast . exists ?) . to eq ( false )
32+ expect ( @podcast . exist ?) . to eq ( false )
3333 end
3434 end
3535
4141 it 'ファイルあり ⇒ true' do
4242 allow ( File ) . to receive ( :exist? ) . with ( "public/podcasts/#{ @podcast . id + 1 } .md" ) { true }
4343
44- expect ( @podcast . exists ?( offset : 1 ) ) . to eq ( true )
44+ expect ( @podcast . exist ?( offset : 1 ) ) . to eq ( true )
4545 end
4646
4747 it 'ファイルなし ⇒ false' do
48- expect ( @podcast . exists ?( offset : 1 ) ) . to eq ( false )
48+ expect ( @podcast . exist ?( offset : 1 ) ) . to eq ( false )
4949 end
5050 end
5151 end
5757 end
5858
5959 it 'ファイル存在 ⇒ ファイルから読み込み' do
60- allow ( @podcast ) . to receive ( :exists ? ) { true }
60+ allow ( @podcast ) . to receive ( :exist ? ) { true }
6161
6262 expect ( @podcast . content ) . to eq ( @content_body )
6363 end
6464
6565 it 'ファイルなし ⇒ 空文字列' do
66- allow ( @podcast ) . to receive ( :exists ? ) { false }
66+ allow ( @podcast ) . to receive ( :exist ? ) { false }
6767
6868 expect ( @podcast . content ) . to eq ( '' )
6969 end
You can’t perform that action at this time.
0 commit comments