From bd7bd63aae15c1b39cf44b15b5aa2b607b3cd9fd Mon Sep 17 00:00:00 2001 From: Pranav Raj S Date: Sun, 25 Aug 2019 19:59:28 +0530 Subject: [PATCH] Fix url in emails, add frontendURL helper (#19) Fixes #16 --- .circleci/config.yml | 17 +++- .eslintrc.js | 3 +- .rspec | 1 + Gemfile | 8 +- Gemfile.lock | 19 +++++ app/controllers/confirmations_controller.rb | 2 +- app/helpers/frontend_urls_helper.rb | 6 ++ app/javascript/src/api/auth.js | 5 +- .../components/buttons/FormSubmitButton.vue | 37 ++++++--- .../src/components/buttons/ResolveButton.vue | 19 ++--- .../src/components/layout/Sidebar.vue | 77 +++++++++++------- .../widgets/conversation/ConversationBox.vue | 7 +- .../widgets/conversation/ConversationCard.vue | 55 +++++++++---- app/javascript/src/helper/URLHelper.js | 6 ++ app/javascript/src/i18n/default-sidebar.js | 22 +++--- .../src/i18n/locale/en/inboxMgmt.json | 2 +- .../src/routes/auth/ResetPassword.vue | 34 ++++---- app/javascript/src/routes/auth/Signup.vue | 59 +++++++++----- app/javascript/src/routes/auth/auth.routes.js | 3 +- .../conversation/conversation.routes.js | 7 +- .../src/routes/dashboard/dashboard.routes.js | 3 +- .../dashboard/settings/agents/Index.vue | 78 ++++++++++++------- .../dashboard/settings/agents/agent.routes.js | 3 +- .../settings/billing/billing.routes.js | 3 +- .../dashboard/settings/canned/Index.vue | 75 +++++++++++------- .../settings/canned/canned.routes.js | 3 +- .../routes/dashboard/settings/inbox/Index.vue | 62 ++++++++++----- .../dashboard/settings/inbox/inbox.routes.js | 3 +- .../settings/reports/reports.routes.js | 3 +- .../dashboard/settings/settings.routes.js | 7 +- app/javascript/src/routes/index.js | 11 +-- .../src/routes/login/login.routes.js | 3 +- app/javascript/src/store/modules/sidebar.js | 5 +- app/mailers/application_mailer.rb | 3 + .../mailer/confirmation_instructions.html.erb | 2 +- .../reset_password_instructions.html.erb | 2 +- app/views/layouts/application.html.erb | 24 ------ config/environments/test.rb | 3 +- config/routes.rb | 10 ++- package.json | 1 + {test => spec}/controllers/.keep | 0 {test => spec}/fixtures/.keep | 0 {test => spec}/fixtures/accounts.yml | 0 {test => spec}/fixtures/attachments.yml | 0 {test => spec}/fixtures/canned_responses.yml | 0 {test => spec}/fixtures/channel/widgets.yml | 0 {test => spec}/fixtures/channels.yml | 0 {test => spec}/fixtures/contacts.yml | 0 {test => spec}/fixtures/conversations.yml | 0 {test => spec}/fixtures/facebook_pages.yml | 0 {test => spec}/fixtures/files/.keep | 0 {test => spec}/fixtures/inbox_members.yml | 0 {test => spec}/fixtures/inboxes.yml | 0 {test => spec}/fixtures/messages.yml | 0 {test => spec}/fixtures/subscriptions.yml | 0 {test => spec}/fixtures/telegram_bots.yml | 0 {test => spec}/fixtures/users.yml | 0 spec/helpers/frontend_urls_helper_spec.rb | 17 ++++ {test/helpers => spec/integration}/.keep | 0 {test/integration => spec/mailers}/.keep | 0 {test/mailers => spec/models}/.keep | 0 {test => spec}/models/channel/widget_test.rb | 0 spec/rails_helper.rb | 60 ++++++++++++++ spec/spec_helper.rb | 15 ++++ {test => spec}/test_helper.rb | 0 test/controllers/api/base_controller_test.rb | 7 -- .../api/v1/agents_controller_test.rb | 7 -- .../v1/canned_responses_controller_test.rb | 7 -- .../api/v1/conversations_controller_test.rb | 7 -- .../api/v1/reports_controller_test.rb | 7 -- .../api/v1/subscriptions_controller_test.rb | 7 -- .../api/v1/webhooks_controller_test.rb | 7 -- .../api/v1/widget/messages_controller_test.rb | 7 -- test/controllers/home_controller_test.rb | 7 -- test/models/.keep | 0 test/models/account_test.rb | 7 -- test/models/attachment_test.rb | 7 -- test/models/canned_response_test.rb | 7 -- test/models/channel_test.rb | 7 -- test/models/contact_test.rb | 7 -- test/models/conversation_test.rb | 7 -- test/models/facebook_page_test.rb | 7 -- test/models/inbox_member_test.rb | 7 -- test/models/inbox_test.rb | 7 -- test/models/message_test.rb | 7 -- test/models/subscription_test.rb | 7 -- test/models/telegram_bot_test.rb | 7 -- test/models/user_test.rb | 7 -- yarn.lock | 9 +++ 89 files changed, 550 insertions(+), 398 deletions(-) create mode 100644 .rspec create mode 100644 app/helpers/frontend_urls_helper.rb create mode 100644 app/javascript/src/helper/URLHelper.js delete mode 100644 app/views/layouts/application.html.erb rename {test => spec}/controllers/.keep (100%) rename {test => spec}/fixtures/.keep (100%) rename {test => spec}/fixtures/accounts.yml (100%) rename {test => spec}/fixtures/attachments.yml (100%) rename {test => spec}/fixtures/canned_responses.yml (100%) rename {test => spec}/fixtures/channel/widgets.yml (100%) rename {test => spec}/fixtures/channels.yml (100%) rename {test => spec}/fixtures/contacts.yml (100%) rename {test => spec}/fixtures/conversations.yml (100%) rename {test => spec}/fixtures/facebook_pages.yml (100%) rename {test => spec}/fixtures/files/.keep (100%) rename {test => spec}/fixtures/inbox_members.yml (100%) rename {test => spec}/fixtures/inboxes.yml (100%) rename {test => spec}/fixtures/messages.yml (100%) rename {test => spec}/fixtures/subscriptions.yml (100%) rename {test => spec}/fixtures/telegram_bots.yml (100%) rename {test => spec}/fixtures/users.yml (100%) create mode 100644 spec/helpers/frontend_urls_helper_spec.rb rename {test/helpers => spec/integration}/.keep (100%) rename {test/integration => spec/mailers}/.keep (100%) rename {test/mailers => spec/models}/.keep (100%) rename {test => spec}/models/channel/widget_test.rb (100%) create mode 100644 spec/rails_helper.rb create mode 100644 spec/spec_helper.rb rename {test => spec}/test_helper.rb (100%) delete mode 100644 test/controllers/api/base_controller_test.rb delete mode 100644 test/controllers/api/v1/agents_controller_test.rb delete mode 100644 test/controllers/api/v1/canned_responses_controller_test.rb delete mode 100644 test/controllers/api/v1/conversations_controller_test.rb delete mode 100644 test/controllers/api/v1/reports_controller_test.rb delete mode 100644 test/controllers/api/v1/subscriptions_controller_test.rb delete mode 100644 test/controllers/api/v1/webhooks_controller_test.rb delete mode 100644 test/controllers/api/v1/widget/messages_controller_test.rb delete mode 100644 test/controllers/home_controller_test.rb delete mode 100644 test/models/.keep delete mode 100644 test/models/account_test.rb delete mode 100644 test/models/attachment_test.rb delete mode 100644 test/models/canned_response_test.rb delete mode 100644 test/models/channel_test.rb delete mode 100644 test/models/contact_test.rb delete mode 100644 test/models/conversation_test.rb delete mode 100644 test/models/facebook_page_test.rb delete mode 100644 test/models/inbox_member_test.rb delete mode 100644 test/models/inbox_test.rb delete mode 100644 test/models/message_test.rb delete mode 100644 test/models/subscription_test.rb delete mode 100644 test/models/telegram_bot_test.rb delete mode 100644 test/models/user_test.rb diff --git a/.circleci/config.yml b/.circleci/config.yml index 8b80af9e0fc2..9f4ce1a3f7bd 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -53,9 +53,20 @@ jobs: name: eslint command: yarn run eslint - - run: - name: brakeman - command: brakeman + # - run: + # name: brakeman + # command: brakeman + + # - run: + # name: Copy files + # command: | + # cp shared/config/database.yml config/database.yml + # cp shared/config/application.yml config/application.yml + + # Run rails tests + - type: shell + command: | + rspec $(circleci tests glob "spec/**/*_spec.rb" | circleci tests split --split-by=timings) # Store yarn / webpacker cache - save_cache: diff --git a/.eslintrc.js b/.eslintrc.js index 599c6d269c14..6ad57866eb1f 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -25,7 +25,8 @@ module.exports = { 'allowFirstLine': false } }], - 'vue/html-self-closing': false + 'vue/html-self-closing': 'off', + "vue/no-v-html": 'off' }, settings: { 'import/resolver': { diff --git a/.rspec b/.rspec new file mode 100644 index 000000000000..c99d2e7396e1 --- /dev/null +++ b/.rspec @@ -0,0 +1 @@ +--require spec_helper diff --git a/Gemfile b/Gemfile index 22b721ddd14d..f29d36675372 100644 --- a/Gemfile +++ b/Gemfile @@ -56,13 +56,17 @@ gem 'foreman' # static analysis gem 'brakeman' +group :development do + gem 'web-console' + gem 'letter_opener' +end + group :development, :test do gem 'byebug', platform: :mri - gem 'letter_opener' - gem 'web-console' gem 'listen' gem 'spring' gem 'spring-watcher-listen' gem 'seed_dump' gem 'rubocop', '~> 0.74.0', require: false + gem 'rspec-rails', '~> 3.8' end diff --git a/Gemfile.lock b/Gemfile.lock index 968443e21d3c..ceb423c642c4 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -172,6 +172,7 @@ GEM crass (1.0.4) descendants_tracker (0.0.4) thread_safe (~> 0.3, >= 0.3.1) + diff-lcs (1.3) domain_name (0.5.20190701) unf (>= 0.0.5, < 1.0.0) dotenv (0.7.0) @@ -329,6 +330,23 @@ GEM http-cookie (>= 1.0.2, < 2.0) mime-types (>= 1.16, < 4.0) netrc (~> 0.8) + rspec-core (3.8.2) + rspec-support (~> 3.8.0) + rspec-expectations (3.8.4) + diff-lcs (>= 1.2.0, < 2.0) + rspec-support (~> 3.8.0) + rspec-mocks (3.8.1) + diff-lcs (>= 1.2.0, < 2.0) + rspec-support (~> 3.8.0) + rspec-rails (3.8.2) + actionpack (>= 3.0) + activesupport (>= 3.0) + railties (>= 3.0) + rspec-core (~> 3.8.0) + rspec-expectations (~> 3.8.0) + rspec-mocks (~> 3.8.0) + rspec-support (~> 3.8.0) + rspec-support (3.8.2) rubocop (0.74.0) jaro_winkler (~> 1.5.1) parallel (~> 1.10) @@ -456,6 +474,7 @@ DEPENDENCIES redis-rack-cache responders rest-client + rspec-rails (~> 3.8) rubocop (~> 0.74.0) sass-rails (~> 5.0) seed_dump diff --git a/app/controllers/confirmations_controller.rb b/app/controllers/confirmations_controller.rb index 1bbe4413e9bb..c0a4006d2e12 100644 --- a/app/controllers/confirmations_controller.rb +++ b/app/controllers/confirmations_controller.rb @@ -28,6 +28,6 @@ def create_reset_token_link(user) user.reset_password_token = enc user.reset_password_sent_at = Time.now.utc user.save(validate: false) - "/u/auth/password/edit?config=default&redirect_url=&reset_password_token="+raw + "/app/auth/password/edit?config=default&redirect_url=&reset_password_token="+raw end end diff --git a/app/helpers/frontend_urls_helper.rb b/app/helpers/frontend_urls_helper.rb new file mode 100644 index 000000000000..46ff71cd0dde --- /dev/null +++ b/app/helpers/frontend_urls_helper.rb @@ -0,0 +1,6 @@ +module FrontendUrlsHelper + def frontend_url(path, **query_params) + url_params = query_params.blank? ? "" : "?#{query_params.to_query}" + "#{root_url}app/#{path}#{url_params}" + end +end diff --git a/app/javascript/src/api/auth.js b/app/javascript/src/api/auth.js index 220bfa76dccf..3ea00b2ca6af 100644 --- a/app/javascript/src/api/auth.js +++ b/app/javascript/src/api/auth.js @@ -7,6 +7,7 @@ import moment from 'moment'; import Cookies from 'js-cookie'; import endPoints from './endPoints'; +import { frontendURL } from '../helper/URLHelper'; export default { login(creds) { @@ -65,7 +66,7 @@ export default { if (error.response.status === 401) { Cookies.remove('auth_data'); Cookies.remove('user'); - window.location = '/login'; + window.location = frontendURL('login'); } reject(error); }); @@ -80,7 +81,7 @@ export default { .then(response => { Cookies.remove('auth_data'); Cookies.remove('user'); - window.location = '/u/login'; + window.location = frontendURL('login'); resolve(response); }) .catch(error => { diff --git a/app/javascript/src/components/buttons/FormSubmitButton.vue b/app/javascript/src/components/buttons/FormSubmitButton.vue index 6b4e69a7279b..fb977e72e776 100644 --- a/app/javascript/src/components/buttons/FormSubmitButton.vue +++ b/app/javascript/src/components/buttons/FormSubmitButton.vue @@ -1,8 +1,8 @@ @@ -10,19 +10,34 @@ import Spinner from '../Spinner'; export default { - props: { - disabled: Boolean, - loading: Boolean, - buttonText: String, - buttonClass: String, - iconClass: String, - }, components: { Spinner, }, + props: { + disabled: { + type: Boolean, + default: false, + }, + loading: { + type: Boolean, + default: false, + }, + buttonText: { + type: String, + default: '', + }, + buttonClass: { + type: String, + default: '', + }, + iconClass: { + type: String, + default: '', + }, + }, computed: { computedClass() { - return `button ${this.buttonClass || ' '}`; + return `button nice ${this.buttonClass || ' '}`; }, }, }; diff --git a/app/javascript/src/components/buttons/ResolveButton.vue b/app/javascript/src/components/buttons/ResolveButton.vue index 6e6e28990a45..24e045ee76cb 100644 --- a/app/javascript/src/components/buttons/ResolveButton.vue +++ b/app/javascript/src/components/buttons/ResolveButton.vue @@ -1,8 +1,13 @@ @@ -13,9 +18,7 @@ import { mapGetters } from 'vuex'; import Spinner from '../Spinner'; export default { - props: [ - 'conversationId', - ], + props: ['conversationId'], data() { return { isLoading: false, @@ -50,5 +53,3 @@ export default { }, }; - - diff --git a/app/javascript/src/components/layout/Sidebar.vue b/app/javascript/src/components/layout/Sidebar.vue index dee22c1a3693..7581ddcc2d8e 100644 --- a/app/javascript/src/components/layout/Sidebar.vue +++ b/app/javascript/src/components/layout/Sidebar.vue @@ -1,47 +1,56 @@