[Internal] Add route for widget testing (#199)
This commit is contained in:
parent
f3fc542a5f
commit
5cc3543657
7 changed files with 58 additions and 10 deletions
2
Gemfile
2
Gemfile
|
@ -85,7 +85,7 @@ group :development, :test do
|
|||
gem 'faker'
|
||||
gem 'listen'
|
||||
gem 'pry-rails'
|
||||
gem 'rspec-rails', '~> 3.8'
|
||||
gem 'rspec-rails', git: 'https://github.com/rspec/rspec-rails', tag: 'v4.0.0.beta3'
|
||||
gem 'rubocop', '~> 0.73.0', require: false
|
||||
gem 'rubocop-performance', require: false
|
||||
gem 'rubocop-rails', require: false
|
||||
|
|
24
Gemfile.lock
24
Gemfile.lock
|
@ -110,6 +110,20 @@ GIT
|
|||
responders
|
||||
warden (~> 1.2.3)
|
||||
|
||||
GIT
|
||||
remote: https://github.com/rspec/rspec-rails
|
||||
revision: bfa37ce6d6ab80257c48e407042406007c7cb724
|
||||
tag: v4.0.0.beta3
|
||||
specs:
|
||||
rspec-rails (4.0.0.beta3)
|
||||
actionpack (>= 4.2)
|
||||
activesupport (>= 4.2)
|
||||
railties (>= 4.2)
|
||||
rspec-core (~> 3.8)
|
||||
rspec-expectations (~> 3.8)
|
||||
rspec-mocks (~> 3.8)
|
||||
rspec-support (~> 3.8)
|
||||
|
||||
GEM
|
||||
remote: https://rubygems.org/
|
||||
specs:
|
||||
|
@ -332,14 +346,6 @@ GEM
|
|||
rspec-mocks (3.9.0)
|
||||
diff-lcs (>= 1.2.0, < 2.0)
|
||||
rspec-support (~> 3.9.0)
|
||||
rspec-rails (3.9.0)
|
||||
actionpack (>= 3.0)
|
||||
activesupport (>= 3.0)
|
||||
railties (>= 3.0)
|
||||
rspec-core (~> 3.9.0)
|
||||
rspec-expectations (~> 3.9.0)
|
||||
rspec-mocks (~> 3.9.0)
|
||||
rspec-support (~> 3.9.0)
|
||||
rspec-support (3.9.0)
|
||||
rubocop (0.73.0)
|
||||
jaro_winkler (~> 1.5.1)
|
||||
|
@ -478,7 +484,7 @@ DEPENDENCIES
|
|||
redis-namespace
|
||||
redis-rack-cache
|
||||
responders
|
||||
rspec-rails (~> 3.8)
|
||||
rspec-rails!
|
||||
rubocop (~> 0.73.0)
|
||||
rubocop-performance
|
||||
rubocop-rails
|
||||
|
|
13
app/controllers/widget_tests_controller.rb
Normal file
13
app/controllers/widget_tests_controller.rb
Normal file
|
@ -0,0 +1,13 @@
|
|||
class WidgetTestsController < ActionController::Base
|
||||
before_action :set_web_widget
|
||||
|
||||
def index
|
||||
render
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def set_web_widget
|
||||
@web_widget = Channel::WebWidget.first
|
||||
end
|
||||
end
|
14
app/views/widget_tests/index.html.erb
Normal file
14
app/views/widget_tests/index.html.erb
Normal file
|
@ -0,0 +1,14 @@
|
|||
<script>
|
||||
(function(d,t) {
|
||||
var BASE_URL = '';
|
||||
var g=d.createElement(t),s=d.getElementsByTagName(t)[0];
|
||||
g.src= BASE_URL + "/packs/js/sdk.js";
|
||||
s.parentNode.insertBefore(g,s);
|
||||
g.onload=function(){
|
||||
window.chatwootSDK.run({
|
||||
websiteToken: '<%= @web_widget.website_token %>',
|
||||
baseUrl: BASE_URL
|
||||
})
|
||||
}
|
||||
})(document,"script");
|
||||
</script>
|
|
@ -88,4 +88,7 @@ Rails.application.routes.draw do
|
|||
|
||||
mount Facebook::Messenger::Server, at: 'bot'
|
||||
post '/webhooks/telegram/:account_id/:inbox_id' => 'home#telegram'
|
||||
|
||||
# Routes for testing
|
||||
resources :widget_tests, only: [:index] unless Rails.env.production?
|
||||
end
|
||||
|
|
12
spec/controllers/widget_tests_controller_spec.rb
Normal file
12
spec/controllers/widget_tests_controller_spec.rb
Normal file
|
@ -0,0 +1,12 @@
|
|||
require 'rails_helper'
|
||||
|
||||
describe WidgetTestsController, type: :controller do
|
||||
let(:channel_widget) { create(:channel_widget) }
|
||||
|
||||
describe '#index' do
|
||||
it 'renders the page correctly' do
|
||||
get :index
|
||||
expect(response.status).to eq 200
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Reference in a new issue