FIX: adjust `full_url` method in `ChatIntegrationReferencePost` to return the correct URL (#220)
* FIX: adjust `full_url` method in `ChatIntegrationReferencePost` to return the correct URL before it automation would fail because topic does not have `full_url` method * DEV: remove logs
This commit is contained in:
parent
6e7917bd5e
commit
afc4540c03
|
@ -24,7 +24,7 @@ module DiscourseChatIntegration
|
||||||
end
|
end
|
||||||
|
|
||||||
def full_url
|
def full_url
|
||||||
@topic.posts.empty? ? @topic.full_url : @topic.posts.first.full_url
|
@topic.posts.empty? ? @topic.url : @topic.posts.first.full_url
|
||||||
end
|
end
|
||||||
|
|
||||||
def excerpt(maxlength = nil, options = {})
|
def excerpt(maxlength = nil, options = {})
|
||||||
|
|
|
@ -18,7 +18,7 @@ RSpec.describe DiscourseChatIntegration::ChatIntegrationReferencePost do
|
||||||
context["removed_tags"] = %w[tag3 tag4]
|
context["removed_tags"] = %w[tag3 tag4]
|
||||||
end
|
end
|
||||||
|
|
||||||
it "creates a post with the correct raw" do
|
it "creates a post with the correct .raw" do
|
||||||
post =
|
post =
|
||||||
described_class.new(
|
described_class.new(
|
||||||
user: context["user"],
|
user: context["user"],
|
||||||
|
@ -32,7 +32,7 @@ RSpec.describe DiscourseChatIntegration::ChatIntegrationReferencePost do
|
||||||
expect(post.raw).to eq("Added #tag1, #tag2 and removed #tag3, #tag4")
|
expect(post.raw).to eq("Added #tag1, #tag2 and removed #tag3, #tag4")
|
||||||
end
|
end
|
||||||
|
|
||||||
it "has a working excerpt" do
|
it "has a working .excerpt" do
|
||||||
post =
|
post =
|
||||||
described_class.new(
|
described_class.new(
|
||||||
user: context["user"],
|
user: context["user"],
|
||||||
|
@ -45,5 +45,86 @@ RSpec.describe DiscourseChatIntegration::ChatIntegrationReferencePost do
|
||||||
)
|
)
|
||||||
expect(post.excerpt).to eq("Added #tag1, #tag2 and removed #tag3, #tag4")
|
expect(post.excerpt).to eq("Added #tag1, #tag2 and removed #tag3, #tag4")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it "has a working .full_url" do
|
||||||
|
post =
|
||||||
|
described_class.new(
|
||||||
|
user: context["user"],
|
||||||
|
topic: context["topic"],
|
||||||
|
kind: context["kind"],
|
||||||
|
context: {
|
||||||
|
"added_tags" => context["added_tags"],
|
||||||
|
"removed_tags" => context["removed_tags"],
|
||||||
|
},
|
||||||
|
)
|
||||||
|
expect(post.full_url).to eq(topic.posts.first.full_url)
|
||||||
|
|
||||||
|
new_topic = Fabricate(:topic)
|
||||||
|
post =
|
||||||
|
described_class.new(
|
||||||
|
user: context["user"],
|
||||||
|
topic: new_topic,
|
||||||
|
kind: context["kind"],
|
||||||
|
context: {
|
||||||
|
"added_tags" => context["added_tags"],
|
||||||
|
"removed_tags" => context["removed_tags"],
|
||||||
|
},
|
||||||
|
)
|
||||||
|
expect(post.full_url).to eq(new_topic.url)
|
||||||
|
end
|
||||||
|
|
||||||
|
it "has a working .is_first_post?" do
|
||||||
|
post =
|
||||||
|
described_class.new(
|
||||||
|
user: context["user"],
|
||||||
|
topic: context["topic"],
|
||||||
|
kind: context["kind"],
|
||||||
|
context: {
|
||||||
|
"added_tags" => context["added_tags"],
|
||||||
|
"removed_tags" => context["removed_tags"],
|
||||||
|
},
|
||||||
|
)
|
||||||
|
expect(post.is_first_post?).to eq(false) # we had a post already
|
||||||
|
|
||||||
|
new_topic = Fabricate(:topic)
|
||||||
|
post =
|
||||||
|
described_class.new(
|
||||||
|
user: context["user"],
|
||||||
|
topic: new_topic,
|
||||||
|
kind: context["kind"],
|
||||||
|
context: {
|
||||||
|
"added_tags" => context["added_tags"],
|
||||||
|
"removed_tags" => context["removed_tags"],
|
||||||
|
},
|
||||||
|
)
|
||||||
|
expect(post.is_first_post?).to eq(true)
|
||||||
|
end
|
||||||
|
|
||||||
|
it "has a working .id" do
|
||||||
|
new_topic = Fabricate(:topic)
|
||||||
|
post =
|
||||||
|
described_class.new(
|
||||||
|
user: context["user"],
|
||||||
|
topic: new_topic,
|
||||||
|
kind: context["kind"],
|
||||||
|
context: {
|
||||||
|
"added_tags" => context["added_tags"],
|
||||||
|
"removed_tags" => context["removed_tags"],
|
||||||
|
},
|
||||||
|
)
|
||||||
|
expect(post.id).to eq(new_topic.id)
|
||||||
|
|
||||||
|
post =
|
||||||
|
described_class.new(
|
||||||
|
user: context["user"],
|
||||||
|
topic: context["topic"],
|
||||||
|
kind: context["kind"],
|
||||||
|
context: {
|
||||||
|
"added_tags" => context["added_tags"],
|
||||||
|
"removed_tags" => context["removed_tags"],
|
||||||
|
},
|
||||||
|
)
|
||||||
|
expect(post.id).to eq(first_post.id)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue