From 5cc354365768ed1a3b0685f794f15a8a495a8749 Mon Sep 17 00:00:00 2001 From: Pranav Raj S Date: Fri, 1 Nov 2019 12:53:01 +0530 Subject: [PATCH] [Internal] Add route for widget testing (#199) --- Gemfile | 2 +- Gemfile.lock | 24 ++++++++++++------- app/controllers/widget_tests_controller.rb | 13 ++++++++++ app/views/widget_tests/index.html.erb | 14 +++++++++++ config/routes.rb | 3 +++ .../room_channel_spec.rb | 0 .../widget_tests_controller_spec.rb | 12 ++++++++++ 7 files changed, 58 insertions(+), 10 deletions(-) create mode 100644 app/controllers/widget_tests_controller.rb create mode 100644 app/views/widget_tests/index.html.erb rename spec/{controllers => channels}/room_channel_spec.rb (100%) create mode 100644 spec/controllers/widget_tests_controller_spec.rb diff --git a/Gemfile b/Gemfile index 87f6be227..9dc837f09 100644 --- a/Gemfile +++ b/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 diff --git a/Gemfile.lock b/Gemfile.lock index b4f818ba6..2a8137aa1 100644 --- a/Gemfile.lock +++ b/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 diff --git a/app/controllers/widget_tests_controller.rb b/app/controllers/widget_tests_controller.rb new file mode 100644 index 000000000..22a8c0da8 --- /dev/null +++ b/app/controllers/widget_tests_controller.rb @@ -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 diff --git a/app/views/widget_tests/index.html.erb b/app/views/widget_tests/index.html.erb new file mode 100644 index 000000000..6b8cd29a5 --- /dev/null +++ b/app/views/widget_tests/index.html.erb @@ -0,0 +1,14 @@ + diff --git a/config/routes.rb b/config/routes.rb index c567fe397..c5120299a 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -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 diff --git a/spec/controllers/room_channel_spec.rb b/spec/channels/room_channel_spec.rb similarity index 100% rename from spec/controllers/room_channel_spec.rb rename to spec/channels/room_channel_spec.rb diff --git a/spec/controllers/widget_tests_controller_spec.rb b/spec/controllers/widget_tests_controller_spec.rb new file mode 100644 index 000000000..5d0d6ccb8 --- /dev/null +++ b/spec/controllers/widget_tests_controller_spec.rb @@ -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