Skip to content

Commit 164f3d6

Browse files
committed
GET /blog とGET /sotechshaのテストを作成
本の記事一覧のソートを追加
1 parent 7817baf commit 164f3d6

File tree

5 files changed

+20
-6
lines changed

5 files changed

+20
-6
lines changed

app/controllers/so_tech_sha_overview_page_controller.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ class SoTechShaOverviewPageController < CmsController
44
def index
55
offset = params[:offset].to_i
66

7-
sts_posts_query = BlogPostPage.where(:_permalink, :starts_with, 'sotechsha-')
7+
sts_posts_query = BlogPostPage.where(:_permalink, :starts_with, 'sotechsha-').order(created: :asc)
88
sts_posts_query.batch_size(POSTS_PER_PAGE).offset(offset)
99
@sts_posts = sts_posts_query.take(POSTS_PER_PAGE)
1010

app/views/blog_overview_page/index.html.erb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<div class ="row">
22
<div class="col-lg-12">
3-
<h1 class="page-header">Page Overview </h1>
3+
<h1 class="page-header">Page Overview</h1>
44
</div>
55
</div>
66
<% @blog_posts.each do |blog_post| %>

app/views/so_tech_sha_overview_page/index.html.erb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
<div class="col-md-5">
1212
<h3><%= link_to(scrivito_value(sts_post.title), scrivito_path(sts_post)) %></h3>
1313
<%= content_tag(:p, scrivito_value(sts_post.abstract)) %>
14-
<%= link_to("View Post", scrivito_path(sts_post), :class => "btn btn-primary") %>
14+
<%= link_to("もっと読む", scrivito_path(sts_post), :class => "btn btn-primary") %>
1515
</div>
1616
</div>
1717
<hr>

test/integration/blog_test.rb

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
require 'test_helper'
2+
3+
class BlogTest < ActionDispatch::IntegrationTest
4+
def setup
5+
end
6+
7+
test "Bloglink should be rendered" do
8+
get "/blog"
9+
assert_template "blog_overview_page/index"
10+
assert_select "h1.page-header","Page Overview"
11+
end
12+
end

test/integration/so_tech_sha_test.rb

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,10 @@ def setup
2020

2121
test "SoTechShalink should be rendered" do
2222
get "/sotechsha"
23-
#so_tech_sha_overview_page.index がrenderされる
24-
#タイトルが「「Scratchでつくる! たのしむ! プログラミング道場」Webコンテンツ」である
25-
#記事の件数 7件である
23+
assert_template "so_tech_sha_overview_page/index"
24+
assert_select "h1.page-header","「Scratchでつくる! たのしむ! プログラミング道場」Webコンテンツ"
25+
assert_select "a[href]", count:14
26+
# Error
27+
# assert_select "a[href=?]", /sotechsha-/ , count:14
2628
end
2729
end

0 commit comments

Comments
 (0)