[Internal] Add route for widget testing (#199)

This commit is contained in:
Pranav Raj S 2019-11-01 12:53:01 +05:30 committed by Sojan Jose
parent f3fc542a5f
commit 5cc3543657
7 changed files with 58 additions and 10 deletions

View file

@ -85,7 +85,7 @@ group :development, :test do
gem 'faker' gem 'faker'
gem 'listen' gem 'listen'
gem 'pry-rails' 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', '~> 0.73.0', require: false
gem 'rubocop-performance', require: false gem 'rubocop-performance', require: false
gem 'rubocop-rails', require: false gem 'rubocop-rails', require: false

View file

@ -110,6 +110,20 @@ GIT
responders responders
warden (~> 1.2.3) 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 GEM
remote: https://rubygems.org/ remote: https://rubygems.org/
specs: specs:
@ -332,14 +346,6 @@ GEM
rspec-mocks (3.9.0) rspec-mocks (3.9.0)
diff-lcs (>= 1.2.0, < 2.0) diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.9.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) rspec-support (3.9.0)
rubocop (0.73.0) rubocop (0.73.0)
jaro_winkler (~> 1.5.1) jaro_winkler (~> 1.5.1)
@ -478,7 +484,7 @@ DEPENDENCIES
redis-namespace redis-namespace
redis-rack-cache redis-rack-cache
responders responders
rspec-rails (~> 3.8) rspec-rails!
rubocop (~> 0.73.0) rubocop (~> 0.73.0)
rubocop-performance rubocop-performance
rubocop-rails rubocop-rails

View 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

View 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>

View file

@ -88,4 +88,7 @@ Rails.application.routes.draw do
mount Facebook::Messenger::Server, at: 'bot' mount Facebook::Messenger::Server, at: 'bot'
post '/webhooks/telegram/:account_id/:inbox_id' => 'home#telegram' post '/webhooks/telegram/:account_id/:inbox_id' => 'home#telegram'
# Routes for testing
resources :widget_tests, only: [:index] unless Rails.env.production?
end end

View 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