|
109 | 109 | expect(GithubLinkback.new(unlisted_post).should_enqueue?).to eq(false) |
110 | 110 | end |
111 | 111 | end |
| 112 | + |
| 113 | + describe "ignored categories" do |
| 114 | + fab!(:category) |
| 115 | + fab!(:post_in_category) do |
| 116 | + topic = Fabricate(:topic, category:) |
| 117 | + Fabricate(:post, topic:, raw: "https://github.com/discourse/discourse/commit/abc123") |
| 118 | + end |
| 119 | + |
| 120 | + before { SiteSetting.github_linkback_enabled = true } |
| 121 | + |
| 122 | + it "doesn't enqueue posts in ignored categories" do |
| 123 | + SiteSetting.github_linkback_ignored_categories = category.id.to_s |
| 124 | + expect(GithubLinkback.new(post_in_category).should_enqueue?).to eq(false) |
| 125 | + end |
| 126 | + |
| 127 | + it "enqueues posts in non-ignored categories" do |
| 128 | + other_category = Fabricate(:category) |
| 129 | + SiteSetting.github_linkback_ignored_categories = other_category.id.to_s |
| 130 | + expect(GithubLinkback.new(post_in_category).should_enqueue?).to eq(true) |
| 131 | + end |
| 132 | + |
| 133 | + it "handles multiple ignored categories" do |
| 134 | + other_category = Fabricate(:category) |
| 135 | + SiteSetting.github_linkback_ignored_categories = "#{category.id}|#{other_category.id}" |
| 136 | + expect(GithubLinkback.new(post_in_category).should_enqueue?).to eq(false) |
| 137 | + end |
| 138 | + |
| 139 | + it "enqueues when ignored categories setting is empty" do |
| 140 | + SiteSetting.github_linkback_ignored_categories = "" |
| 141 | + expect(GithubLinkback.new(post_in_category).should_enqueue?).to eq(true) |
| 142 | + end |
| 143 | + |
| 144 | + it "enqueues posts without a category" do |
| 145 | + SiteSetting.github_linkback_ignored_categories = category.id.to_s |
| 146 | + uncategorized_post = |
| 147 | + Fabricate(:post, raw: "https://github.com/discourse/discourse/commit/abc123") |
| 148 | + expect(GithubLinkback.new(uncategorized_post).should_enqueue?).to eq(true) |
| 149 | + end |
| 150 | + end |
112 | 151 | end |
113 | 152 |
|
114 | 153 | describe "#github_links" do |
|
0 commit comments