mirror of
https://github.com/ENSL/ensl.org.git
synced 2025-01-28 04:00:45 +00:00
Add some forum testing
This commit is contained in:
parent
9c4b3d85d1
commit
8c812df99c
9 changed files with 96 additions and 24 deletions
|
@ -6,7 +6,7 @@ class DirectoriesController < ApplicationController
|
||||||
@files = @directory.files
|
@files = @directory.files
|
||||||
render partial: 'data_files/list', layout: true
|
render partial: 'data_files/list', layout: true
|
||||||
else
|
else
|
||||||
@directories = Directory.ordered.filtered.all conditions: { parent_id: 1 }
|
@directories = Directory.ordered.filtered.where(parent_id: 1)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -1,9 +1,11 @@
|
||||||
require 'rails_helper'
|
require 'rails_helper'
|
||||||
|
|
||||||
RSpec.describe ShoutmsgsController, type: :controller do
|
RSpec.describe ShoutmsgsController, type: :controller do
|
||||||
|
context 'GET #index' do
|
||||||
it "renders the index template" do
|
it "renders the index template" do
|
||||||
get :index
|
get :index
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(200)
|
||||||
expect(response).to render_template("index")
|
expect(response).to render_template("index")
|
||||||
end
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -11,4 +11,8 @@ FactoryBot.define do
|
||||||
trait :game do
|
trait :game do
|
||||||
domain Category::DOMAIN_GAMES
|
domain Category::DOMAIN_GAMES
|
||||||
end
|
end
|
||||||
|
|
||||||
|
trait :forums do
|
||||||
|
domain Category::DOMAIN_FORUMS
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -2,5 +2,20 @@ FactoryBot.define do
|
||||||
factory :forum do
|
factory :forum do
|
||||||
sequence(:title) { |n| "Forum Title #{n}" }
|
sequence(:title) { |n| "Forum Title #{n}" }
|
||||||
sequence(:description) { |n| "Forum Description #{n}" }
|
sequence(:description) { |n| "Forum Description #{n}" }
|
||||||
|
|
||||||
|
before :create do |forum|
|
||||||
|
cat = create(:category, :forums)
|
||||||
|
forum.category = cat
|
||||||
|
end
|
||||||
|
|
||||||
|
trait :with_content do
|
||||||
|
after :create do |forum|
|
||||||
|
(rand(30..100)).times do
|
||||||
|
topic = build :topic, :with_content
|
||||||
|
topic.forum = forum
|
||||||
|
topic.save
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -3,5 +3,9 @@ FactoryBot.define do
|
||||||
sequence(:text) { |n| "Post Body #{n}" }
|
sequence(:text) { |n| "Post Body #{n}" }
|
||||||
topic
|
topic
|
||||||
user
|
user
|
||||||
|
|
||||||
|
trait :with_content do
|
||||||
|
text { (0..100).map { (0...8).map { (65 + rand(26)).chr }.join }.join(" ") }
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -6,5 +6,15 @@ FactoryBot.define do
|
||||||
before(:create) do |topic|
|
before(:create) do |topic|
|
||||||
topic.first_post = "My first post on the topic"
|
topic.first_post = "My first post on the topic"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
trait :with_content do
|
||||||
|
after :create do |topic|
|
||||||
|
(rand(1..30)).times do
|
||||||
|
post = build :post
|
||||||
|
post.topic = topic
|
||||||
|
post.save
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
36
spec/features/forums/read_forums_spec.rb
Normal file
36
spec/features/forums/read_forums_spec.rb
Normal file
|
@ -0,0 +1,36 @@
|
||||||
|
require 'rails_helper'
|
||||||
|
|
||||||
|
feature 'User reads forums', js: :true do
|
||||||
|
before :all do
|
||||||
|
create_list(:forum, 5, :with_content)
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'as a basic user' do
|
||||||
|
let!(:user) { create(:user) }
|
||||||
|
|
||||||
|
before do
|
||||||
|
sign_in_as(user)
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'has forum header' do
|
||||||
|
visit forums_path
|
||||||
|
expect(page).to have_selector("td.forum h5")
|
||||||
|
end
|
||||||
|
|
||||||
|
#it 'has forum description' do
|
||||||
|
# visit forums_path
|
||||||
|
# expect("td.forum").to have_content()
|
||||||
|
#end
|
||||||
|
|
||||||
|
it 'can click last post' do
|
||||||
|
find('td.last>a').click
|
||||||
|
expect(response).to have_http_status(200)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def long_text(len = 10_000)
|
||||||
|
(0..len).map{ (0...8).map { (65 + rand(26)).chr }.join }.join(" ") # 90008
|
||||||
|
end
|
||||||
|
end
|
|
@ -9,6 +9,7 @@ feature "Visitor signs up", js: :true do
|
||||||
|
|
||||||
scenario "with valid Username, Email, Password and Steam ID" do
|
scenario "with valid Username, Email, Password and Steam ID" do
|
||||||
within registration_form do
|
within registration_form do
|
||||||
|
|
||||||
fill_form(:user, user.slice(*sign_up_attributes))
|
fill_form(:user, user.slice(*sign_up_attributes))
|
||||||
click_button submit(:user, :create)
|
click_button submit(:user, :create)
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue