mirror of
https://github.com/Growstuff/growstuff.git
synced 2026-03-02 13:47:57 -05:00
Tidy up posts
This commit is contained in:
6
app/helpers/posts_helper.rb
Normal file
6
app/helpers/posts_helper.rb
Normal file
@@ -0,0 +1,6 @@
|
||||
module PostsHelper
|
||||
def display_post_truncated(post)
|
||||
length = 300
|
||||
return truncate(post.body, length: length, separator: ' ', omission: '... ') { link_to "Read more", post_path(post) }
|
||||
end
|
||||
end
|
||||
@@ -48,6 +48,10 @@ class Post < ApplicationRecord
|
||||
end
|
||||
end
|
||||
|
||||
def to_s
|
||||
subject
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def update_crops_posts_association
|
||||
|
||||
@@ -20,7 +20,6 @@
|
||||
%h3= t('.recently_added')
|
||||
!= Crop.recent.limit(30).map { |c| link_to(c, c) }.join(", ")
|
||||
|
||||
|
||||
%section.seeds
|
||||
%h2.text-center= t('.seeds_available_to_trade')
|
||||
.homepage-cards
|
||||
@@ -28,13 +27,14 @@
|
||||
.align-bottom
|
||||
%p.text-right= link_to "#{t('home.seeds.view_all')} »", seeds_path, class: 'btn'
|
||||
|
||||
%section.members= render 'members'
|
||||
|
||||
.col-xl-5
|
||||
.row
|
||||
.col-md-6.col-sm-12=render 'plantings'
|
||||
.col-md-6.col-sm-12= render 'harvests'
|
||||
.row
|
||||
.col-12
|
||||
%section.members= render 'discuss'
|
||||
|
||||
|
||||
%section.members= render 'discuss'
|
||||
|
||||
|
||||
%section.members= render 'members'
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
.well
|
||||
|
||||
.card
|
||||
.post{ id: "post-#{post.id}" }
|
||||
.row
|
||||
.col-md-1
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
- content_for :title, @author ? t('.title.author_posts', author: @author) : t('.title.default')
|
||||
|
||||
|
||||
%h1= @author ? t('.title.author_posts', author: @author) : t('.title.default')
|
||||
.pagination= render 'layouts/pagination', collection: @posts
|
||||
.row
|
||||
.card-deck
|
||||
- @posts.each do |post|
|
||||
.col-6.col-xs-12
|
||||
.col-6
|
||||
.card
|
||||
.card-body
|
||||
.row
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
FactoryBot.define do
|
||||
factory :post do
|
||||
subject { "A Post" }
|
||||
subject { Faker::Book.title }
|
||||
|
||||
body { "This is some text." }
|
||||
body { Faker::Lorem.paragraphs.join("\n") }
|
||||
author
|
||||
created_at { Time.zone.now }
|
||||
|
||||
|
||||
@@ -88,7 +88,7 @@ describe 'Test with visual testing', type: :feature, js: true do
|
||||
tomato_planting = FactoryBot.create :planting, garden: garden, owner: member, crop: tomato
|
||||
tomato_photo.plantings << tomato_planting
|
||||
visit garden_path(garden)
|
||||
Percy.snapshot(page, name: "#{prefix}/gardens#show-2")
|
||||
Percy.snapshot(page, name: "#{prefix}/gardens#show")
|
||||
end
|
||||
end
|
||||
|
||||
@@ -110,6 +110,16 @@ describe 'Test with visual testing', type: :feature, js: true do
|
||||
visit post_path(post)
|
||||
Percy.snapshot(page, name: "#{prefix}/posts#show")
|
||||
end
|
||||
it 'loads posts#index' do
|
||||
Member.all.each do |member|
|
||||
FactoryBot.create_list :post, 12, author: member
|
||||
end
|
||||
Post.all.order(:id).limit(4) do |post|
|
||||
FactoryBot.create_list :comment, rand(1..5), post: post
|
||||
end
|
||||
visit posts_path
|
||||
Percy.snapshot(page, name: "#{prefix}/posts#index")
|
||||
end
|
||||
end
|
||||
|
||||
describe 'photos' do
|
||||
|
||||
Reference in New Issue
Block a user