2019-10-17 18:29:15 +00:00
|
|
|
require 'rails_helper'
|
2014-03-26 11:09:39 +00:00
|
|
|
|
2014-10-12 10:46:58 +00:00
|
|
|
feature 'User creates new article', js: :true do
|
2014-03-30 19:50:52 +00:00
|
|
|
let!(:category) { create(:category, domain: Category::DOMAIN_NEWS) }
|
2014-03-26 11:09:39 +00:00
|
|
|
let(:article) { attributes_for(:article) }
|
|
|
|
|
2014-03-30 19:50:52 +00:00
|
|
|
describe 'with valid Title, Content, Category' do
|
|
|
|
context 'as a basic user' do
|
|
|
|
let!(:user) { create(:user) }
|
|
|
|
|
|
|
|
before do
|
|
|
|
sign_in_as(user)
|
|
|
|
visit new_article_path
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'creates an article successfully' do
|
|
|
|
fill_in attribute_translation(:article, :title), with: article[:title]
|
|
|
|
fill_tinymce "#article_text", article[:text]
|
|
|
|
click_button I18n.t('helpers.submit.post.create')
|
|
|
|
|
|
|
|
expect(page).to have_content(I18n.t('articles_create'))
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'creates an article with a text length greater than 65535 bytes' do
|
|
|
|
fill_in attribute_translation(:article, :title), with: article[:title]
|
|
|
|
fill_tinymce "#article_text", long_text
|
|
|
|
click_button I18n.t('helpers.submit.post.create')
|
|
|
|
|
|
|
|
expect(page).to have_content(I18n.t('articles_create'))
|
|
|
|
end
|
|
|
|
end
|
2014-03-26 11:09:39 +00:00
|
|
|
end
|
|
|
|
|
2014-03-30 19:50:52 +00:00
|
|
|
private
|
|
|
|
|
|
|
|
def long_text
|
|
|
|
(0..10000).map{ (0...8).map { (65 + rand(26)).chr }.join }.join(" ") # 90008
|
2014-03-26 11:09:39 +00:00
|
|
|
end
|
|
|
|
end
|