2019-04-29 19:27:42 -05:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2013-02-05 13:16:51 -06:00
|
|
|
Fabricator(:post) do
|
2024-01-18 00:08:40 -06:00
|
|
|
user { Fabricate(:user, refresh_auto_groups: true) }
|
2017-07-27 20:20:09 -05:00
|
|
|
topic { |attrs| Fabricate(:topic, user: attrs[:user]) }
|
2013-02-25 10:42:20 -06:00
|
|
|
raw "Hello world"
|
2015-09-21 17:50:52 -05:00
|
|
|
post_type Post.types[:regular]
|
2022-02-06 21:23:34 -06:00
|
|
|
|
|
|
|
# Fabrication bypasses PostCreator, for performance reasons, where the counts are updated so we have to handle this manually here.
|
2023-01-09 05:18:21 -06:00
|
|
|
after_create { |post, _transients| UserStatCountUpdater.increment!(post) }
|
2013-02-05 13:16:51 -06:00
|
|
|
end
|
|
|
|
|
2014-04-11 15:07:39 -05:00
|
|
|
Fabricator(:post_with_long_raw_content, from: :post) do
|
2023-01-09 05:18:21 -06:00
|
|
|
raw "This is a sample post with semi-long raw content. The raw content is also more than
|
2014-04-11 15:07:39 -05:00
|
|
|
two hundred characters to satisfy any test conditions that require content longer
|
2023-01-09 05:18:21 -06:00
|
|
|
than the typical test post raw content. It really is some long content, folks."
|
2014-04-11 15:07:39 -05:00
|
|
|
end
|
|
|
|
|
2023-06-01 13:55:27 -05:00
|
|
|
Fabricator(:post_with_very_long_raw_content, from: :post) do
|
|
|
|
raw "This is a sample post with very long raw content. The raw content is actually so long
|
|
|
|
that there is no way it could be longer. It is adding so many characters to the post content
|
|
|
|
so that we can use it in testing for scenarios where a post is very long and might cause issues.
|
|
|
|
The post is so long in fact, that the text is split into various paragraphs. Some people are not
|
|
|
|
very concise in their words. They tend to ramble and ramble on about certain information. This
|
|
|
|
is why we need to make sure that we are going about testing in certain ways so that when people
|
|
|
|
such as those that ramble on, are making posts, we can be sure that the posts are not causing
|
|
|
|
any issues. When issues happen it can cause lots of problems. For example, if a post is too long,
|
|
|
|
it affects the way it can be viewed by others.
|
|
|
|
Depending on the screen size, it may cause a lot of scrolling to take place. This is not good.
|
|
|
|
In certain cases, we want to truncate the content of the post when its too long so that it does
|
|
|
|
not cause issues. This is why we need to make sure that we are testing for these scenarios. I think
|
|
|
|
this post has gotten very long, however, I would like to make sure that it is a bit longer, so I
|
|
|
|
will add one final sentence. This is my final sentence, thank you for reading, goodbye."
|
|
|
|
end
|
|
|
|
|
2013-02-05 13:16:51 -06:00
|
|
|
Fabricator(:post_with_youtube, from: :post) do
|
2023-01-09 05:18:21 -06:00
|
|
|
raw "http://www.youtube.com/watch?v=9bZkp7q19f0"
|
2013-04-10 02:52:38 -05:00
|
|
|
cooked '<p><a href="http://www.youtube.com/watch?v=9bZkp7q19f0" class="onebox" target="_blank">http://www.youtube.com/watch?v=9bZkp7q19f0</a></p>'
|
2013-02-05 13:16:51 -06:00
|
|
|
end
|
|
|
|
|
|
|
|
Fabricator(:old_post, from: :post) do
|
2017-07-27 20:20:09 -05:00
|
|
|
topic { |attrs| Fabricate(:topic, user: attrs[:user], created_at: (DateTime.now - 100)) }
|
2020-04-22 13:49:53 -05:00
|
|
|
created_at { 100.days.ago }
|
2013-02-05 13:16:51 -06:00
|
|
|
end
|
|
|
|
|
|
|
|
Fabricator(:moderator_post, from: :post) do
|
|
|
|
user
|
2017-07-27 20:20:09 -05:00
|
|
|
topic { |attrs| Fabricate(:topic, user: attrs[:user]) }
|
2013-03-18 15:03:46 -05:00
|
|
|
post_type Post.types[:moderator_action]
|
2013-02-25 10:42:20 -06:00
|
|
|
raw "Hello world"
|
2013-02-05 13:16:51 -06:00
|
|
|
end
|
|
|
|
|
|
|
|
Fabricator(:basic_reply, from: :post) do
|
2019-01-15 20:40:16 -06:00
|
|
|
user(fabricator: :coding_horror)
|
2013-02-05 13:16:51 -06:00
|
|
|
reply_to_post_number 1
|
|
|
|
topic
|
2023-01-09 05:18:21 -06:00
|
|
|
raw "this reply has no quotes"
|
2013-02-05 13:16:51 -06:00
|
|
|
end
|
|
|
|
|
|
|
|
Fabricator(:reply, from: :post) do
|
2019-01-15 20:40:16 -06:00
|
|
|
user(fabricator: :coding_horror)
|
2013-02-05 13:16:51 -06:00
|
|
|
topic
|
|
|
|
raw '
|
|
|
|
[quote="Evil Trout, post:1"]hello[/quote]
|
|
|
|
Hmmm!
|
|
|
|
'
|
|
|
|
end
|
|
|
|
|
2023-01-09 05:18:21 -06:00
|
|
|
Fabricator(:post_with_plenty_of_images, from: :post) { cooked <<~HTML }
|
2019-12-17 23:51:57 -06:00
|
|
|
<aside class="quote"><img src="/#{Discourse.store.upload_path}/original/1X/1234567890123456.jpg"></aside>
|
|
|
|
<div class="onebox-result"><img src="/#{Discourse.store.upload_path}/original/1X/1234567890123456.jpg"></div>
|
|
|
|
<div class="onebox"><img src="/#{Discourse.store.upload_path}/original/1X/1234567890123456.jpg"></div>
|
2022-02-09 05:18:59 -06:00
|
|
|
<p>With an emoji! <img src="//cdn.discourse.org/meta/images/emoji/twitter/smile.png?v=#{Emoji::EMOJI_VERSION}" title=":smile:" class="emoji" alt="smile" loading="lazy" width="20" height="20"></p>
|
2018-08-16 06:45:30 -05:00
|
|
|
HTML
|
2013-07-07 18:39:08 -05:00
|
|
|
|
2013-07-21 17:37:23 -05:00
|
|
|
Fabricator(:post_with_uploaded_image, from: :post) do
|
FEATURE: Include optimized thumbnails for topics (#9215)
This introduces new APIs for obtaining optimized thumbnails for topics. There are a few building blocks required for this:
- Introduces new `image_upload_id` columns on the `posts` and `topics` table. This replaces the old `image_url` column, which means that thumbnails are now restricted to uploads. Hotlinked thumbnails are no longer possible. In normal use (with pull_hotlinked_images enabled), this has no noticeable impact
- A migration attempts to match existing urls to upload records. If a match cannot be found then the posts will be queued for rebake
- Optimized thumbnails are generated during post_process_cooked. If thumbnails are missing when serializing a topic list, then a sidekiq job is queued
- Topic lists and topics now include a `thumbnails` key, which includes all the available images:
```
"thumbnails": [
{
"max_width": null,
"max_height": null,
"url": "//example.com/original-image.png",
"width": 1380,
"height": 1840
},
{
"max_width": 1024,
"max_height": 1024,
"url": "//example.com/optimized-image.png",
"width": 768,
"height": 1024
}
]
```
- Themes can request additional thumbnail sizes by using a modifier in their `about.json` file:
```
"modifiers": {
"topic_thumbnail_sizes": [
[200, 200],
[800, 800]
],
...
```
Remember that these are generated asynchronously, so your theme should include logic to fallback to other available thumbnails if your requested size has not yet been generated
- Two new raw plugin outlets are introduced, to improve the customisability of the topic list. `topic-list-before-columns` and `topic-list-before-link`
2020-05-05 03:07:50 -05:00
|
|
|
raw { "<img src=\"#{Fabricate(:image_upload)}\" width=\"1500\" height=\"2000\">" }
|
2013-07-07 18:39:08 -05:00
|
|
|
end
|
|
|
|
|
2013-07-10 15:59:07 -05:00
|
|
|
Fabricator(:post_with_an_attachment, from: :post) do
|
2024-02-29 05:24:37 -06:00
|
|
|
raw "<a class=\"attachment\" href=\"/#{Discourse.store.upload_path}/original/1X/66b3ed1503efc936.zip\">archive.zip</a>"
|
2013-07-10 15:59:07 -05:00
|
|
|
end
|
|
|
|
|
2013-07-07 18:39:08 -05:00
|
|
|
Fabricator(:post_with_unsized_images, from: :post) do
|
2019-12-17 23:51:57 -06:00
|
|
|
raw "
|
|
|
|
<img src=\"http://foo.bar/image.png\">
|
|
|
|
<img src=\"/#{Discourse.store.upload_path}/original/1X/1234567890123456.jpg\">
|
|
|
|
"
|
2013-07-07 18:39:08 -05:00
|
|
|
end
|
|
|
|
|
2013-11-25 11:36:13 -06:00
|
|
|
Fabricator(:post_with_image_urls, from: :post) do
|
2015-09-29 11:51:26 -05:00
|
|
|
raw '
|
2013-11-25 11:36:13 -06:00
|
|
|
<img src="http://foo.bar/image.png">
|
|
|
|
<img src="http://domain.com/picture.jpg" width="50" height="42">
|
|
|
|
'
|
2013-07-07 18:39:08 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
Fabricator(:post_with_large_image, from: :post) do
|
2019-12-17 23:51:57 -06:00
|
|
|
raw "<img src=\"/#{Discourse.store.upload_path}/original/1X/1234567890123456.jpg\">"
|
2013-07-07 18:39:08 -05:00
|
|
|
end
|
|
|
|
|
2014-11-03 15:03:06 -06:00
|
|
|
Fabricator(:post_with_large_image_and_title, from: :post) do
|
2019-12-17 23:51:57 -06:00
|
|
|
raw "<img src=\"/#{Discourse.store.upload_path}/original/1X/1234567890123456.jpg\" title=\"WAT\">"
|
2014-11-03 15:03:06 -06:00
|
|
|
end
|
|
|
|
|
2016-03-09 21:50:07 -06:00
|
|
|
Fabricator(:post_with_large_image_on_subfolder, from: :post) do
|
2019-12-17 23:51:57 -06:00
|
|
|
raw "<img src=\"/subfolder/#{Discourse.store.upload_path}/original/1X/1234567890123456.jpg\">"
|
2016-03-09 21:50:07 -06:00
|
|
|
end
|
|
|
|
|
2013-11-05 12:04:47 -06:00
|
|
|
Fabricator(:post_with_uploads, from: :post) do
|
2019-12-17 23:51:57 -06:00
|
|
|
raw "
|
|
|
|
<a href=\"/#{Discourse.store.upload_path}/original/2X/2345678901234567.jpg\">Link</a>
|
|
|
|
<img src=\"/#{Discourse.store.upload_path}/original/1X/1234567890123456.jpg\">
|
|
|
|
"
|
2013-11-05 12:04:47 -06:00
|
|
|
end
|
|
|
|
|
2023-01-09 05:18:21 -06:00
|
|
|
Fabricator(:post_with_uploads_and_links, from: :post) { raw <<~MD }
|
2019-12-17 23:51:57 -06:00
|
|
|
<a href="/#{Discourse.store.upload_path}/original/2X/2345678901234567.jpg">Link</a>
|
|
|
|
<img src="/#{Discourse.store.upload_path}/original/1X/1234567890123456.jpg">
|
2018-12-11 01:03:13 -06:00
|
|
|
<a href="http://www.google.com">Google</a>
|
|
|
|
<img src="http://foo.bar/image.png">
|
2019-12-17 23:51:57 -06:00
|
|
|
<a class="attachment" href="/#{Discourse.store.upload_path}/original/1X/af2c2618032c679333bebf745e75f9088748d737.txt">text.txt</a> (20 Bytes)
|
2018-12-11 01:03:13 -06:00
|
|
|
:smile:
|
DEV: Correctly tag heredocs (#16061)
This allows text editors to use correct syntax coloring for the heredoc sections.
Heredoc tag names we use:
languages: SQL, JS, RUBY, LUA, HTML, CSS, SCSS, SH, HBS, XML, YAML/YML, MF, ICS
other: MD, TEXT/TXT, RAW, EMAIL
2022-02-28 13:50:55 -06:00
|
|
|
MD
|
2013-11-05 12:04:47 -06:00
|
|
|
|
2013-02-05 13:16:51 -06:00
|
|
|
Fabricator(:post_with_external_links, from: :post) do
|
2024-01-18 00:08:40 -06:00
|
|
|
user { Fabricate(:user, refresh_auto_groups: true) }
|
2013-02-05 13:16:51 -06:00
|
|
|
topic
|
DEV: Correctly tag heredocs (#16061)
This allows text editors to use correct syntax coloring for the heredoc sections.
Heredoc tag names we use:
languages: SQL, JS, RUBY, LUA, HTML, CSS, SCSS, SH, HBS, XML, YAML/YML, MF, ICS
other: MD, TEXT/TXT, RAW, EMAIL
2022-02-28 13:50:55 -06:00
|
|
|
raw <<~MD
|
2018-12-11 01:03:13 -06:00
|
|
|
Here's a link to twitter: http://twitter.com
|
|
|
|
And a link to google: http://google.com
|
|
|
|
And a secure link to google: https://google.com
|
|
|
|
And a markdown link: [forumwarz](http://forumwarz.com)
|
|
|
|
And a markdown link with a period after it [codinghorror](http://www.codinghorror.com/blog).
|
|
|
|
And one with a hash http://discourse.org#faq
|
|
|
|
And one with a two hash http://discourse.org#a#b
|
DEV: Correctly tag heredocs (#16061)
This allows text editors to use correct syntax coloring for the heredoc sections.
Heredoc tag names we use:
languages: SQL, JS, RUBY, LUA, HTML, CSS, SCSS, SH, HBS, XML, YAML/YML, MF, ICS
other: MD, TEXT/TXT, RAW, EMAIL
2022-02-28 13:50:55 -06:00
|
|
|
MD
|
2013-02-05 13:16:51 -06:00
|
|
|
end
|
2013-04-03 12:25:52 -05:00
|
|
|
|
|
|
|
Fabricator(:private_message_post, from: :post) do
|
2022-08-10 00:25:39 -05:00
|
|
|
transient :recipient
|
2013-04-03 12:25:52 -05:00
|
|
|
user
|
|
|
|
topic do |attrs|
|
2023-01-09 05:18:21 -06:00
|
|
|
Fabricate(
|
|
|
|
:private_message_topic,
|
2013-04-03 12:25:52 -05:00
|
|
|
user: attrs[:user],
|
|
|
|
created_at: attrs[:created_at],
|
2013-04-16 15:56:18 -05:00
|
|
|
subtype: TopicSubtype.user_to_user,
|
2013-04-03 12:25:52 -05:00
|
|
|
topic_allowed_users: [
|
2017-04-26 22:53:53 -05:00
|
|
|
Fabricate.build(:topic_allowed_user, user: attrs[:user]),
|
2023-01-09 05:18:21 -06:00
|
|
|
Fabricate.build(:topic_allowed_user, user: attrs[:recipient] || Fabricate(:user)),
|
|
|
|
],
|
2013-04-03 12:25:52 -05:00
|
|
|
)
|
|
|
|
end
|
|
|
|
raw "Ssshh! This is our secret conversation!"
|
2013-04-10 02:52:38 -05:00
|
|
|
end
|
2017-11-10 09:10:25 -06:00
|
|
|
|
2022-09-30 00:44:04 -05:00
|
|
|
Fabricator(:group_private_message_post, from: :post) do
|
|
|
|
transient :recipients
|
|
|
|
user
|
|
|
|
topic do |attrs|
|
2023-01-09 05:18:21 -06:00
|
|
|
Fabricate(
|
|
|
|
:private_message_topic,
|
2022-09-30 00:44:04 -05:00
|
|
|
user: attrs[:user],
|
|
|
|
created_at: attrs[:created_at],
|
|
|
|
subtype: TopicSubtype.user_to_user,
|
2023-01-09 05:18:21 -06:00
|
|
|
topic_allowed_users: [Fabricate.build(:topic_allowed_user, user: attrs[:user])],
|
2022-09-30 00:44:04 -05:00
|
|
|
topic_allowed_groups: [
|
2023-01-09 05:18:21 -06:00
|
|
|
Fabricate.build(:topic_allowed_group, group: attrs[:recipients] || Fabricate(:group)),
|
|
|
|
],
|
2022-09-30 00:44:04 -05:00
|
|
|
)
|
|
|
|
end
|
|
|
|
raw "Ssshh! This is our group secret conversation!"
|
|
|
|
end
|
|
|
|
|
2019-07-22 09:55:49 -05:00
|
|
|
Fabricator(:private_message_post_one_user, from: :post) do
|
|
|
|
user
|
|
|
|
topic do |attrs|
|
2023-01-09 05:18:21 -06:00
|
|
|
Fabricate(
|
|
|
|
:private_message_topic,
|
2019-07-22 09:55:49 -05:00
|
|
|
user: attrs[:user],
|
|
|
|
created_at: attrs[:created_at],
|
|
|
|
subtype: TopicSubtype.user_to_user,
|
2023-01-09 05:18:21 -06:00
|
|
|
topic_allowed_users: [Fabricate.build(:topic_allowed_user, user: attrs[:user])],
|
2019-07-22 09:55:49 -05:00
|
|
|
)
|
|
|
|
end
|
|
|
|
raw "Ssshh! This is our secret conversation!"
|
|
|
|
end
|
|
|
|
|
2017-11-10 09:10:25 -06:00
|
|
|
Fabricator(:post_via_email, from: :post) do
|
|
|
|
incoming_email
|
|
|
|
via_email true
|
|
|
|
|
|
|
|
after_create do |post|
|
|
|
|
incoming_email.topic = post.topic
|
|
|
|
incoming_email.post = post
|
|
|
|
incoming_email.user = post.user
|
|
|
|
end
|
|
|
|
end
|
2019-09-06 13:48:57 -05:00
|
|
|
|
2023-01-09 05:18:21 -06:00
|
|
|
Fabricator(:whisper, from: :post) { post_type Post.types[:whisper] }
|
2021-08-30 00:07:53 -05:00
|
|
|
|
2023-01-09 05:18:21 -06:00
|
|
|
Fabricator(:small_action, from: :post) { post_type Post.types[:small_action] }
|