This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Api::Core::V1::UsersController < ApplicationController | |
before_action except: [:create] do | |
authenticate_token | |
end | |
def create | |
first_name = params["first_name"] | |
last_name = params["last_name"] | |
email = params["email"] | |
phone = params["phone"] | |
password = params["password"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rails_helper' | |
RSpec.describe Api::Core::V1::UsersController, type: :controller do | |
it 'must be able to create a user when first_name, last_name, email and password are specified' do | |
post :create, params: {first_name: 'Cletus', last_name: 'Mccletus', email: 'cletus@mccletus.com', password: 'cletus12345', password_confirmation: 'cletus12345'} | |
response_body = JSON.parse(response.body) | |
expect(response_body.keys).to eql ["status", "code"] | |
expect(response_body["code"]).to eql 200 | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class EmailConfirmationJob < ApplicationJob | |
queue_as :default | |
def perform(user_id) | |
user = User.find(user_id) | |
user.set_email_verification_sent | |
UserMailer.welcome_email_confirmation(user).deliver_now | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rails_helper' | |
require 'sidekiq/testing' | |
RSpec.describe EmailConfirmationJob, type: :job do | |
before(:each) do | |
@user = create_new_user | |
Sidekiq::Testing.inline! | |
end | |
it 'enqueues and changes the email_sent status to true' do |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class UserMailer < ApplicationMailer | |
default from: 'you@yourdomain.com' | |
def welcome_email_confirmation(user) | |
@user = user | |
@email_confirmation_url = user.generate_email_confirmation_link | |
mail(to: user.email, subject: "Welcome to this generic SaaS product #{user.first_name.capitalize}! Please confirm your email" ) | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require "rails_helper" | |
RSpec.describe UserMailer, type: :mailer do | |
it 'sends a welcome email to user with password confirmation link' do | |
user = create_new_user | |
subject_line = "Welcome to this generic SaaS product #{user.first_name.capitalize}! Please confirm your email" | |
generated_email = UserMailer.welcome_email_confirmation(user) | |
expect(generated_email.subject).to eql subject_line | |
expect(generated_email.to[0]).to eql user.email | |
expect(generated_email.from[0]).to eql 'you@yourdomain.com' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'simplecov' | |
SimpleCov.use_merging true | |
SimpleCov.start do | |
load_profile 'rails' | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace :test do | |
desc "test entire app" | |
task :full_suite => [:environment] do | |
if !Rails.env.production? | |
coverage_folder = "#{Rails.root}/coverage" | |
sh("rm -rf #{coverage_folder}") | |
Rake::Task["db:drop"].invoke | |
Rake::Task["db:create"].invoke | |
Rake::Task["db:migrate"].invoke | |
sh("rails test --verbose") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Ruby | |
on: | |
push: | |
branches: | |
- master | |
pull_request: | |
branches: | |
- master |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, {useEffect} from 'react'; | |
import { connect } from 'react-redux'; | |
import './FriendsContainer.css'; | |
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; | |
import { faSortAmountDown } from '@fortawesome/free-solid-svg-icons'; | |
import DropdownMenu from '../../../../Shared/Global/DropdownMenu/DropdownMenu'; | |
import FriendCard from '../FriendCard/FriendCard'; | |
import ErrorBox from '../../../../Shared/Global/ErrorBox/ErrorBox' | |
import {listFriendsByContext} from '../../../../../Services/Friends/ListFriends' | |
import {requestAuthenticationErrorHandler} from '../../../../../Utilities/AuthUtilities/Auth' |