Skip to content

Commit

Permalink
Super Scaffold incoming webhooks test (#502)
Browse files Browse the repository at this point in the history
* Add bullet_train_webhooks controller test

* Edit webhooks controller test in transformer

* Add bullet train webhooks routing

* Fixing Standard Ruby

* Wrap webhook test in scaffolding thing check

* Add original replacement code in webhooks transformer

* Add bullet_train_webhooks controller test

* Edit webhooks controller test in transformer

* Fixing Standard Ruby

* Wrap webhook test in scaffolding thing check

* Add original replacement code in webhooks transformer

* Use Membership instead of CreativeConcept in incoming webhook test
  • Loading branch information
gazayas authored Sep 8, 2023
1 parent 57e073b commit 6912cb7
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 1 deletion.
5 changes: 5 additions & 0 deletions bullet_train-incoming_webhooks/config/routes.rb
Original file line number Diff line number Diff line change
@@ -1,2 +1,7 @@
Rails.application.routes.draw do
namespace :webhooks do
namespace :incoming do
resources :bullet_train_webhooks
end
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ def initialize(provider_name, cli_options = {})
def scaffold_incoming_webhook
files = [
"./app/models/webhooks/incoming/bullet_train_webhook.rb",
"./app/controllers/webhooks/incoming/bullet_train_webhooks_controller.rb"
"./app/controllers/webhooks/incoming/bullet_train_webhooks_controller.rb",
"./test/controllers/webhooks/incoming/bullet_train_webhooks_controller_test.rb"
]

files.each do |name|
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
require "test_helper"

class Webhooks::Incoming::BulletTrainWebhooksControllerTest < ActionDispatch::IntegrationTest
include Devise::Test::IntegrationHelpers

def setup
super
@user = FactoryBot.create(:onboarded_user)
@membership = @user.memberships.first
@team = @user.current_team
end

test "should get incoming webhook" do
webhook_params = {
data: {
data: {
name: "Test",
team_id: {
id: @team.id,
slug: nil,
locale: nil,
time_zone: @team.time_zone,
created_at: @membership.created_at,
updated_at: @membership.updated_at,
being_destroyed: nil,
},
description: ""
},
event_type: "membership.created",
subject_type: "Membership"
},
verified_at: nil,
processed_at: nil,
}

post "/webhooks/incoming/bullet_train_webhooks", params: webhook_params.to_json
assert_equal response.parsed_body, {"status" => "OK"}

webhook = Webhooks::Incoming::BulletTrainWebhook.first
assert_equal webhook.data.to_json, webhook_params.to_json
end
end

0 comments on commit 6912cb7

Please sign in to comment.