Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feedback widget implementation, part I
- Loading branch information
1 parent
3742dc1
commit 5b7d4b7
Showing
6 changed files
with
57 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
module Api | ||
class FeedbacksController < AbstractConfigController | ||
def create | ||
message = raw_json[:message] | ||
slug = raw_json[:slug] | ||
if message | ||
current_device.delay.provide_feedback(message, slug) | ||
end | ||
render json: {} | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
require "spec_helper" | ||
|
||
describe Api::FeedbacksController do | ||
let(:user) { FactoryBot.create(:user) } | ||
include Devise::Test::ControllerHelpers | ||
|
||
it "submits feedback" do | ||
sign_in user | ||
input = { message: "Example message", slug: "Example slug" } | ||
expect(Faraday).to receive(:post).and_return("THIS IS A STUB") | ||
with_modified_env FEEDBACK_WEBHOOK_URL: 'https://localhost:3000/' do | ||
run_jobs_now do | ||
post :create, body: input.to_json | ||
end | ||
end | ||
expect(response.status).to eq(200) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters