|
18 | 18 | context["removed_tags"] = %w[tag3 tag4]
|
19 | 19 | end
|
20 | 20 |
|
21 |
| - it "creates a post with the correct raw" do |
| 21 | + it "creates a post with the correct .raw" do |
22 | 22 | post =
|
23 | 23 | described_class.new(
|
24 | 24 | user: context["user"],
|
|
32 | 32 | expect(post.raw).to eq("Added #tag1, #tag2 and removed #tag3, #tag4")
|
33 | 33 | end
|
34 | 34 |
|
35 |
| - it "has a working excerpt" do |
| 35 | + it "has a working .excerpt" do |
36 | 36 | post =
|
37 | 37 | described_class.new(
|
38 | 38 | user: context["user"],
|
|
45 | 45 | )
|
46 | 46 | expect(post.excerpt).to eq("Added #tag1, #tag2 and removed #tag3, #tag4")
|
47 | 47 | end
|
| 48 | + |
| 49 | + it "has a working .full_url" do |
| 50 | + post = |
| 51 | + described_class.new( |
| 52 | + user: context["user"], |
| 53 | + topic: context["topic"], |
| 54 | + kind: context["kind"], |
| 55 | + context: { |
| 56 | + "added_tags" => context["added_tags"], |
| 57 | + "removed_tags" => context["removed_tags"], |
| 58 | + }, |
| 59 | + ) |
| 60 | + expect(post.full_url).to eq(topic.posts.first.full_url) |
| 61 | + |
| 62 | + new_topic = Fabricate(:topic) |
| 63 | + post = |
| 64 | + described_class.new( |
| 65 | + user: context["user"], |
| 66 | + topic: new_topic, |
| 67 | + kind: context["kind"], |
| 68 | + context: { |
| 69 | + "added_tags" => context["added_tags"], |
| 70 | + "removed_tags" => context["removed_tags"], |
| 71 | + }, |
| 72 | + ) |
| 73 | + expect(post.full_url).to eq(new_topic.url) |
| 74 | + end |
| 75 | + |
| 76 | + it "has a working .is_first_post?" do |
| 77 | + post = |
| 78 | + described_class.new( |
| 79 | + user: context["user"], |
| 80 | + topic: context["topic"], |
| 81 | + kind: context["kind"], |
| 82 | + context: { |
| 83 | + "added_tags" => context["added_tags"], |
| 84 | + "removed_tags" => context["removed_tags"], |
| 85 | + }, |
| 86 | + ) |
| 87 | + expect(post.is_first_post?).to eq(false) # we had a post already |
| 88 | + |
| 89 | + new_topic = Fabricate(:topic) |
| 90 | + post = |
| 91 | + described_class.new( |
| 92 | + user: context["user"], |
| 93 | + topic: new_topic, |
| 94 | + kind: context["kind"], |
| 95 | + context: { |
| 96 | + "added_tags" => context["added_tags"], |
| 97 | + "removed_tags" => context["removed_tags"], |
| 98 | + }, |
| 99 | + ) |
| 100 | + expect(post.is_first_post?).to eq(true) |
| 101 | + end |
| 102 | + |
| 103 | + it "has a working .id" do |
| 104 | + new_topic = Fabricate(:topic) |
| 105 | + post = |
| 106 | + described_class.new( |
| 107 | + user: context["user"], |
| 108 | + topic: new_topic, |
| 109 | + kind: context["kind"], |
| 110 | + context: { |
| 111 | + "added_tags" => context["added_tags"], |
| 112 | + "removed_tags" => context["removed_tags"], |
| 113 | + }, |
| 114 | + ) |
| 115 | + expect(post.id).to eq(new_topic.id) |
| 116 | + |
| 117 | + post = |
| 118 | + described_class.new( |
| 119 | + user: context["user"], |
| 120 | + topic: context["topic"], |
| 121 | + kind: context["kind"], |
| 122 | + context: { |
| 123 | + "added_tags" => context["added_tags"], |
| 124 | + "removed_tags" => context["removed_tags"], |
| 125 | + }, |
| 126 | + ) |
| 127 | + expect(post.id).to eq(first_post.id) |
| 128 | + end |
48 | 129 | end
|
49 | 130 | end
|
0 commit comments