Spiegel von
https://github.com/paviliondev/discourse-custom-wizard.git
synchronisiert 2024-11-26 02:50:28 +01:00
Merge pull request #98 from paviliondev/pm-multiple-targets
FEATURE: allow targetting multiple users/groups when sending a privat…
Dieser Commit ist enthalten in:
Commit
ec21c8e274
3 geänderte Dateien mit 74 neuen und 18 gelöschten Zeilen
|
@ -89,11 +89,13 @@ class CustomWizard::Action
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
|
params[:target_group_names] = []
|
||||||
|
params[:target_usernames] = []
|
||||||
targets.each do |target|
|
targets.each do |target|
|
||||||
if Group.find_by(name: target)
|
if Group.find_by(name: target)
|
||||||
params[:target_group_names] = target
|
params[:target_group_names] << target
|
||||||
elsif User.find_by_username(target)
|
elsif User.find_by_username(target)
|
||||||
params[:target_usernames] = target
|
params[:target_usernames] << target
|
||||||
else
|
else
|
||||||
#
|
#
|
||||||
end
|
end
|
||||||
|
|
|
@ -68,7 +68,8 @@ describe CustomWizard::Action do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'sends a message' do
|
context 'sending a message' do
|
||||||
|
it 'works' do
|
||||||
User.create(username: 'angus1', email: "angus1@email.com")
|
User.create(username: 'angus1', email: "angus1@email.com")
|
||||||
|
|
||||||
wizard = CustomWizard::Builder.new(@template[:id], user).build
|
wizard = CustomWizard::Builder.new(@template[:id], user).build
|
||||||
|
@ -90,6 +91,31 @@ describe CustomWizard::Action do
|
||||||
expect(post.exists?).to eq(true)
|
expect(post.exists?).to eq(true)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it 'allows using multiple PM targets' do
|
||||||
|
User.create(username: 'angus1', email: "angus1@email.com")
|
||||||
|
User.create(username: 'faiz', email: "faiz@email.com")
|
||||||
|
Group.create(name: "cool_group")
|
||||||
|
Group.create(name: 'cool_group_1')
|
||||||
|
wizard = CustomWizard::Builder.new(@template[:id], user).build
|
||||||
|
wizard.create_updater(wizard.steps[0].id, {}).update
|
||||||
|
wizard.create_updater(wizard.steps[1].id, {}).update
|
||||||
|
|
||||||
|
topic = Topic.where(
|
||||||
|
archetype: Archetype.private_message,
|
||||||
|
title: "Multiple Recipients title"
|
||||||
|
)
|
||||||
|
|
||||||
|
post = Post.where(
|
||||||
|
topic_id: topic.pluck(:id),
|
||||||
|
raw: "I will interpolate some wizard fields"
|
||||||
|
)
|
||||||
|
expect(topic.exists?).to eq(true)
|
||||||
|
expect(topic.first.all_allowed_users.map(&:username)).to include('angus1', 'faiz')
|
||||||
|
expect(topic.first.allowed_groups.map(&:name)).to include('cool_group', 'cool_group_1')
|
||||||
|
expect(post.exists?).to eq(true)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
it 'updates a profile' do
|
it 'updates a profile' do
|
||||||
wizard = CustomWizard::Builder.new(@template[:id], user).build
|
wizard = CustomWizard::Builder.new(@template[:id], user).build
|
||||||
upload = Upload.create!(
|
upload = Upload.create!(
|
||||||
|
|
28
spec/fixtures/wizard.json
gevendort
28
spec/fixtures/wizard.json
gevendort
|
@ -464,6 +464,34 @@
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"id": "action_11",
|
||||||
|
"run_after": "step_2",
|
||||||
|
"type": "send_message",
|
||||||
|
"post_builder": true,
|
||||||
|
"post_template": "I will interpolate some wizard fields w{step_1_field_1} w{step_1_field_2}",
|
||||||
|
"title": [
|
||||||
|
{
|
||||||
|
"type": "assignment",
|
||||||
|
"output": "Multiple Recipients title",
|
||||||
|
"output_type": "text",
|
||||||
|
"output_connector": "set"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"recipient": [
|
||||||
|
{
|
||||||
|
"type": "assignment",
|
||||||
|
"output_type": "user",
|
||||||
|
"output_connector": "set",
|
||||||
|
"output": [
|
||||||
|
"angus1",
|
||||||
|
"faiz",
|
||||||
|
"cool_group",
|
||||||
|
"cool_group_1"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"id": "action_3",
|
"id": "action_3",
|
||||||
"run_after": "step_2",
|
"run_after": "step_2",
|
||||||
|
|
Laden …
In neuem Issue referenzieren