\ No newline at end of file
diff --git a/app/views/admins/show.html.erb b/app/views/admins/show.html.erb
new file mode 100644
index 000000000..7fa2dffd4
--- /dev/null
+++ b/app/views/admins/show.html.erb
@@ -0,0 +1,84 @@
+
\ No newline at end of file
diff --git a/app/views/agencies/index.html.erb b/app/views/agencies/index.html.erb
new file mode 100644
index 000000000..18419ea32
--- /dev/null
+++ b/app/views/agencies/index.html.erb
@@ -0,0 +1,26 @@
+
\ No newline at end of file
diff --git a/app/views/agencies/show.html.erb b/app/views/agencies/show.html.erb
new file mode 100644
index 000000000..3452aaf50
--- /dev/null
+++ b/app/views/agencies/show.html.erb
@@ -0,0 +1,93 @@
+
+ <% end %>
+ <%= render "devise/shared/links" %>
+
+
+
+
\ No newline at end of file
diff --git a/app/views/devise/sessions/new.html.erb b/app/views/devise/sessions/new.html.erb
new file mode 100644
index 000000000..11f30d2bd
--- /dev/null
+++ b/app/views/devise/sessions/new.html.erb
@@ -0,0 +1,50 @@
+
+
+<% end %>
diff --git a/app/views/messages/_message.html.erb b/app/views/messages/_message.html.erb
new file mode 100644
index 000000000..22e07f272
--- /dev/null
+++ b/app/views/messages/_message.html.erb
@@ -0,0 +1,11 @@
+
+
+
+ <%=message.body%>
+
+
+ <%=message.user.username%>
+
+
+
+
\ No newline at end of file
diff --git a/app/views/messages/_mine.html.erb b/app/views/messages/_mine.html.erb
new file mode 100644
index 000000000..3edfb1183
--- /dev/null
+++ b/app/views/messages/_mine.html.erb
@@ -0,0 +1,11 @@
+
+
+
+ <%=message.body%>
+
+
+ <%=message.user.username%>
+
+
+
+
\ No newline at end of file
diff --git a/app/views/messages/_theirs.html.erb b/app/views/messages/_theirs.html.erb
new file mode 100644
index 000000000..14df3f828
--- /dev/null
+++ b/app/views/messages/_theirs.html.erb
@@ -0,0 +1,11 @@
+
+
+
+ <%=message.body%>
+
+
+ <%=message.user.username%>
+
+
+
+
\ No newline at end of file
diff --git a/app/views/shared/_errors.html.erb b/app/views/shared/_errors.html.erb
new file mode 100644
index 000000000..5c84e5f83
--- /dev/null
+++ b/app/views/shared/_errors.html.erb
@@ -0,0 +1,15 @@
+<% if obj.errors.any? %>
+
+
+
The folowing errors prevent the <%=obj.class.name.downcase%> from being saved
+
+
+
+ <% obj.errors.full_messages.each do |msg| %>
+
<%=msg%>
+
+ <%end%>
+
+
+
+ <%end%>
\ No newline at end of file
diff --git a/app/views/shared/_nav_bar.html.erb b/app/views/shared/_nav_bar.html.erb
new file mode 100644
index 000000000..58caaac73
--- /dev/null
+++ b/app/views/shared/_nav_bar.html.erb
@@ -0,0 +1,109 @@
+
diff --git a/app/views/tourist_tours/index.html.erb b/app/views/tourist_tours/index.html.erb
new file mode 100644
index 000000000..1033340b4
--- /dev/null
+++ b/app/views/tourist_tours/index.html.erb
@@ -0,0 +1,33 @@
+
+
+<%end%>
\ No newline at end of file
diff --git a/app/views/tourist_tours/new.html.erb b/app/views/tourist_tours/new.html.erb
new file mode 100644
index 000000000..cccf188aa
--- /dev/null
+++ b/app/views/tourist_tours/new.html.erb
@@ -0,0 +1,76 @@
+
+
+
<%=@tour.name%>
+
+
+
+
+
+
+
+
+
+
+ <% if @tour.images.attached?%>
+ <%@tour.images.each do |image|%>
+
+ <%= javascript_pack_tag 'tourist_tour_new' %>
\ No newline at end of file
diff --git a/app/views/tourist_tours/show.html.erb b/app/views/tourist_tours/show.html.erb
new file mode 100644
index 000000000..0c40e40f2
--- /dev/null
+++ b/app/views/tourist_tours/show.html.erb
@@ -0,0 +1,15 @@
+
+
+
+ <%if @tourist_tour.tour.images.attached?%>
+ <%@tourist_tour.tour.images.each do |img|%>
+
+ <% end %>
+ <%end%>
+
+
<%= @tourist_tour.tour.name%>
+
<%= @tourist_tour.tour.details.body%>
+
+
+
+
\ No newline at end of file
diff --git a/app/views/tourists/show.html.erb b/app/views/tourists/show.html.erb
new file mode 100644
index 000000000..44eb7b8ff
--- /dev/null
+++ b/app/views/tourists/show.html.erb
@@ -0,0 +1,83 @@
+
+<%= javascript_pack_tag 'image_preview' %>
\ No newline at end of file
diff --git a/app/views/tours/index.html.erb b/app/views/tours/index.html.erb
new file mode 100644
index 000000000..60513f5f0
--- /dev/null
+++ b/app/views/tours/index.html.erb
@@ -0,0 +1,35 @@
+
+<%= javascript_pack_tag 'image_preview' %>
\ No newline at end of file
diff --git a/app/views/tours/show.html.erb b/app/views/tours/show.html.erb
new file mode 100644
index 000000000..979f142ba
--- /dev/null
+++ b/app/views/tours/show.html.erb
@@ -0,0 +1,63 @@
+
+ <% if @tour.images.attached?%>
+ <%@tour.images.each do |image|%>
+
+
+
+ <%end%>
+ <%end%>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Location: <%=@tour.location%>
+
Price: <%=@tour.price%>
+
Duration: <%=@tour.duration%>
+
Details:
+
<%=@tour.details%>
+
+
+
+
+
\ No newline at end of file
diff --git a/app/views/travel_transactions/index.html.erb b/app/views/travel_transactions/index.html.erb
new file mode 100644
index 000000000..bdf38c380
--- /dev/null
+++ b/app/views/travel_transactions/index.html.erb
@@ -0,0 +1,29 @@
+
+
+
+
+
Package Name
+
Tourist
+
Agency
+
Date Availed
+
Start Date
+
End Date
+
+
+
+ <% @travel_transactions.each do |transaction|%>
+
\ No newline at end of file
diff --git a/config/credentials.yml.enc b/config/credentials.yml.enc
index 13bec8b12..3797e37c6 100644
--- a/config/credentials.yml.enc
+++ b/config/credentials.yml.enc
@@ -1 +1 @@
-vGGT60HbIwlvjrOSj8QkGzQ+EqBcuWQJziz4siEGjSykZwqibwIc5BZChF2C3wBvxcuXygOObUvRGWcp+B58qkXoCUjwueUUhnkq4Utn0QcjV/5rmsVdVuLC2V7ZmxT/IKgviPzOa1Iz7PN7tBrqJTZoi6KrqYYYWRnXSvC0lLDkdqoKG35CEKRcdLtt385m4rK3JWWQXOVJXLSlQhCANW0XvXvZEJtm8E0LCwUx98SXoV8WRO//B4i7CUv56H61daxxSb9A940DcRkDR6dJLDOAyCJbuOGgsyoX3R4ybiK4xNzS9XXLmiUyXfdRxeAJAeB0Bthc4+8tymmiEd5Nlo8U5mwAN8U149b/5wBbw4vKMPkdNxCLMygLjC84rbMtJTrxCsdRHjQ+YbCrxirhEFQNHM2XyUoJ06WD--RYah7W4NWRhsH2Sf--TLLM8vHkIpbAHY802vtuIA==
\ No newline at end of file
+VpZ3b9VHg9mCmhG1sKHVqbonBKeeCjRVvm4JAxAiuleJA11OFk1xttBxZSd2fOJ+HtPkkl3nemazBQ5TDX9/EBExNsEVg1DDmiSwEA0kFESOfyjVR1Xpoz+WcVHUunydUvdM0cx3s7jtxWOKy72dGZZa/VayAVMGLRLfUHoYFuZwAJ3q+nEaVLxAGTciqjQnQYi15Jqagd0TWfjBP8pOqoEvjVm2xnFqkiWQbt9qU5WAO7b6N2xM5c1Jl4pygudfN8K2RlwSSKtI8JJMO3VjNt4HbCWFRRZxKr2Fp6TT2EsM7FzuBlK6MS/+6LAhMcIylQv77a6KbrktTVPX0yZfF44MMbUyXkFp629rPW8CF+tfP+X+nN8sMiyuc7I02ixcsx7IY7PuLWeyacASPCe1GgKkM6Vpr6uOCLHsIyym1C/nL1/SW3edLezQpV/ZMX8aPiqY+m5B4NqGWTvK1IHvRMO82El3tA6gYHJF11I1r+BltbGHkCZ+i7D29F9eYnajiazPiVqyyK9JBN8RgEfouid4uf41hZTrY4Rf7BlSy2OeSTbPnzPzFmYbrggJW1gxIBTBBQ5II7/1HqgaFzV13HW3PbZIneldAmrmXtss6EzRVRFKbGWZ3mmaTGDzuHqZa6zDzrHjF07C7ousN1dxeZbHsWsIMlh3LTVRXassmyI9SkkiSov6uw/5BCL9m/Wo3LtbhxfXtcBEU8It--QF1AlFmuZZ0WpUc0--Gkvn5+LTGq7BhNDm9maQYQ==
\ No newline at end of file
diff --git a/config/environments/development.rb b/config/environments/development.rb
index 66df51f6f..f77c59e83 100644
--- a/config/environments/development.rb
+++ b/config/environments/development.rb
@@ -59,4 +59,5 @@
# Use an evented file watcher to asynchronously detect changes in source code,
# routes, locales, etc. This feature depends on the listen gem.
config.file_watcher = ActiveSupport::EventedFileUpdateChecker
+ config.action_mailer.default_url_options = { host: 'localhost', port: 3000 }
end
diff --git a/config/environments/production.rb b/config/environments/production.rb
index 69afea11b..77ddb50bd 100644
--- a/config/environments/production.rb
+++ b/config/environments/production.rb
@@ -36,7 +36,7 @@
# config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for NGINX
# Store uploaded files on the local file system (see config/storage.yml for options).
- config.active_storage.service = :local
+ config.active_storage.service = :amazon
# Mount Action Cable outside main process or domain.
# config.action_cable.mount_path = nil
diff --git a/config/initializers/devise.rb b/config/initializers/devise.rb
new file mode 100644
index 000000000..a98ad2613
--- /dev/null
+++ b/config/initializers/devise.rb
@@ -0,0 +1,311 @@
+# frozen_string_literal: true
+
+# Assuming you have not yet modified this file, each configuration option below
+# is set to its default value. Note that some are commented out while others
+# are not: uncommented lines are intended to protect your configuration from
+# breaking changes in upgrades (i.e., in the event that future versions of
+# Devise change the default values for those options).
+#
+# Use this hook to configure devise mailer, warden hooks and so forth.
+# Many of these configuration options can be set straight in your model.
+Devise.setup do |config|
+ # The secret key used by Devise. Devise uses this key to generate
+ # random tokens. Changing this key will render invalid all existing
+ # confirmation, reset password and unlock tokens in the database.
+ # Devise will use the `secret_key_base` as its `secret_key`
+ # by default. You can change it below and use your own secret key.
+ # config.secret_key = '45ea502616488c88616e1b5a578ac46a7151aff872f47c7b3cbb2607445ba0a52726baef340953c1d820aa821edfe0045231489f19042c94a033536a6e717ef6'
+
+ # ==> Controller configuration
+ # Configure the parent class to the devise controllers.
+ # config.parent_controller = 'DeviseController'
+
+ # ==> Mailer Configuration
+ # Configure the e-mail address which will be shown in Devise::Mailer,
+ # note that it will be overwritten if you use your own mailer class
+ # with default "from" parameter.
+ config.mailer_sender = 'please-change-me-at-config-initializers-devise@example.com'
+
+ # Configure the class responsible to send e-mails.
+ # config.mailer = 'Devise::Mailer'
+
+ # Configure the parent class responsible to send e-mails.
+ # config.parent_mailer = 'ActionMailer::Base'
+
+ # ==> ORM configuration
+ # Load and configure the ORM. Supports :active_record (default) and
+ # :mongoid (bson_ext recommended) by default. Other ORMs may be
+ # available as additional gems.
+ require 'devise/orm/active_record'
+
+ # ==> Configuration for any authentication mechanism
+ # Configure which keys are used when authenticating a user. The default is
+ # just :email. You can configure it to use [:username, :subdomain], so for
+ # authenticating a user, both parameters are required. Remember that those
+ # parameters are used only when authenticating and not when retrieving from
+ # session. If you need permissions, you should implement that in a before filter.
+ # You can also supply a hash where the value is a boolean determining whether
+ # or not authentication should be aborted when the value is not present.
+ # config.authentication_keys = [:email]
+
+ # Configure parameters from the request object used for authentication. Each entry
+ # given should be a request method and it will automatically be passed to the
+ # find_for_authentication method and considered in your model lookup. For instance,
+ # if you set :request_keys to [:subdomain], :subdomain will be used on authentication.
+ # The same considerations mentioned for authentication_keys also apply to request_keys.
+ # config.request_keys = []
+
+ # Configure which authentication keys should be case-insensitive.
+ # These keys will be downcased upon creating or modifying a user and when used
+ # to authenticate or find a user. Default is :email.
+ config.case_insensitive_keys = [:email]
+
+ # Configure which authentication keys should have whitespace stripped.
+ # These keys will have whitespace before and after removed upon creating or
+ # modifying a user and when used to authenticate or find a user. Default is :email.
+ config.strip_whitespace_keys = [:email]
+
+ # Tell if authentication through request.params is enabled. True by default.
+ # It can be set to an array that will enable params authentication only for the
+ # given strategies, for example, `config.params_authenticatable = [:database]` will
+ # enable it only for database (email + password) authentication.
+ # config.params_authenticatable = true
+
+ # Tell if authentication through HTTP Auth is enabled. False by default.
+ # It can be set to an array that will enable http authentication only for the
+ # given strategies, for example, `config.http_authenticatable = [:database]` will
+ # enable it only for database authentication.
+ # For API-only applications to support authentication "out-of-the-box", you will likely want to
+ # enable this with :database unless you are using a custom strategy.
+ # The supported strategies are:
+ # :database = Support basic authentication with authentication key + password
+ # config.http_authenticatable = false
+
+ # If 401 status code should be returned for AJAX requests. True by default.
+ # config.http_authenticatable_on_xhr = true
+
+ # The realm used in Http Basic Authentication. 'Application' by default.
+ # config.http_authentication_realm = 'Application'
+
+ # It will change confirmation, password recovery and other workflows
+ # to behave the same regardless if the e-mail provided was right or wrong.
+ # Does not affect registerable.
+ # config.paranoid = true
+
+ # By default Devise will store the user in session. You can skip storage for
+ # particular strategies by setting this option.
+ # Notice that if you are skipping storage for all authentication paths, you
+ # may want to disable generating routes to Devise's sessions controller by
+ # passing skip: :sessions to `devise_for` in your config/routes.rb
+ config.skip_session_storage = [:http_auth]
+
+ # By default, Devise cleans up the CSRF token on authentication to
+ # avoid CSRF token fixation attacks. This means that, when using AJAX
+ # requests for sign in and sign up, you need to get a new CSRF token
+ # from the server. You can disable this option at your own risk.
+ # config.clean_up_csrf_token_on_authentication = true
+
+ # When false, Devise will not attempt to reload routes on eager load.
+ # This can reduce the time taken to boot the app but if your application
+ # requires the Devise mappings to be loaded during boot time the application
+ # won't boot properly.
+ # config.reload_routes = true
+
+ # ==> Configuration for :database_authenticatable
+ # For bcrypt, this is the cost for hashing the password and defaults to 12. If
+ # using other algorithms, it sets how many times you want the password to be hashed.
+ # The number of stretches used for generating the hashed password are stored
+ # with the hashed password. This allows you to change the stretches without
+ # invalidating existing passwords.
+ #
+ # Limiting the stretches to just one in testing will increase the performance of
+ # your test suite dramatically. However, it is STRONGLY RECOMMENDED to not use
+ # a value less than 10 in other environments. Note that, for bcrypt (the default
+ # algorithm), the cost increases exponentially with the number of stretches (e.g.
+ # a value of 20 is already extremely slow: approx. 60 seconds for 1 calculation).
+ config.stretches = Rails.env.test? ? 1 : 12
+
+ # Set up a pepper to generate the hashed password.
+ # config.pepper = 'e7dbc2411fdbdc86605f235229e3cea5c762a3eb163746e28a81e38e452f71e9b26cd5dc66e421eea949b8784f0221aa8946192f1609bb6fdf4b4388c0f1f234'
+
+ # Send a notification to the original email when the user's email is changed.
+ # config.send_email_changed_notification = false
+
+ # Send a notification email when the user's password is changed.
+ # config.send_password_change_notification = false
+
+ # ==> Configuration for :confirmable
+ # A period that the user is allowed to access the website even without
+ # confirming their account. For instance, if set to 2.days, the user will be
+ # able to access the website for two days without confirming their account,
+ # access will be blocked just in the third day.
+ # You can also set it to nil, which will allow the user to access the website
+ # without confirming their account.
+ # Default is 0.days, meaning the user cannot access the website without
+ # confirming their account.
+ # config.allow_unconfirmed_access_for = 2.days
+
+ # A period that the user is allowed to confirm their account before their
+ # token becomes invalid. For example, if set to 3.days, the user can confirm
+ # their account within 3 days after the mail was sent, but on the fourth day
+ # their account can't be confirmed with the token any more.
+ # Default is nil, meaning there is no restriction on how long a user can take
+ # before confirming their account.
+ # config.confirm_within = 3.days
+
+ # If true, requires any email changes to be confirmed (exactly the same way as
+ # initial account confirmation) to be applied. Requires additional unconfirmed_email
+ # db field (see migrations). Until confirmed, new email is stored in
+ # unconfirmed_email column, and copied to email column on successful confirmation.
+ config.reconfirmable = true
+
+ # Defines which key will be used when confirming an account
+ # config.confirmation_keys = [:email]
+
+ # ==> Configuration for :rememberable
+ # The time the user will be remembered without asking for credentials again.
+ # config.remember_for = 2.weeks
+
+ # Invalidates all the remember me tokens when the user signs out.
+ config.expire_all_remember_me_on_sign_out = true
+
+ # If true, extends the user's remember period when remembered via cookie.
+ # config.extend_remember_period = false
+
+ # Options to be passed to the created cookie. For instance, you can set
+ # secure: true in order to force SSL only cookies.
+ # config.rememberable_options = {}
+
+ # ==> Configuration for :validatable
+ # Range for password length.
+ config.password_length = 6..128
+
+ # Email regex used to validate email formats. It simply asserts that
+ # one (and only one) @ exists in the given string. This is mainly
+ # to give user feedback and not to assert the e-mail validity.
+ config.email_regexp = /\A[^@\s]+@[^@\s]+\z/
+
+ # ==> Configuration for :timeoutable
+ # The time you want to timeout the user session without activity. After this
+ # time the user will be asked for credentials again. Default is 30 minutes.
+ # config.timeout_in = 30.minutes
+
+ # ==> Configuration for :lockable
+ # Defines which strategy will be used to lock an account.
+ # :failed_attempts = Locks an account after a number of failed attempts to sign in.
+ # :none = No lock strategy. You should handle locking by yourself.
+ # config.lock_strategy = :failed_attempts
+
+ # Defines which key will be used when locking and unlocking an account
+ # config.unlock_keys = [:email]
+
+ # Defines which strategy will be used to unlock an account.
+ # :email = Sends an unlock link to the user email
+ # :time = Re-enables login after a certain amount of time (see :unlock_in below)
+ # :both = Enables both strategies
+ # :none = No unlock strategy. You should handle unlocking by yourself.
+ # config.unlock_strategy = :both
+
+ # Number of authentication tries before locking an account if lock_strategy
+ # is failed attempts.
+ # config.maximum_attempts = 20
+
+ # Time interval to unlock the account if :time is enabled as unlock_strategy.
+ # config.unlock_in = 1.hour
+
+ # Warn on the last attempt before the account is locked.
+ # config.last_attempt_warning = true
+
+ # ==> Configuration for :recoverable
+ #
+ # Defines which key will be used when recovering the password for an account
+ # config.reset_password_keys = [:email]
+
+ # Time interval you can reset your password with a reset password key.
+ # Don't put a too small interval or your users won't have the time to
+ # change their passwords.
+ config.reset_password_within = 6.hours
+
+ # When set to false, does not sign a user in automatically after their password is
+ # reset. Defaults to true, so a user is signed in automatically after a reset.
+ # config.sign_in_after_reset_password = true
+
+ # ==> Configuration for :encryptable
+ # Allow you to use another hashing or encryption algorithm besides bcrypt (default).
+ # You can use :sha1, :sha512 or algorithms from others authentication tools as
+ # :clearance_sha1, :authlogic_sha512 (then you should set stretches above to 20
+ # for default behavior) and :restful_authentication_sha1 (then you should set
+ # stretches to 10, and copy REST_AUTH_SITE_KEY to pepper).
+ #
+ # Require the `devise-encryptable` gem when using anything other than bcrypt
+ # config.encryptor = :sha512
+
+ # ==> Scopes configuration
+ # Turn scoped views on. Before rendering "sessions/new", it will first check for
+ # "users/sessions/new". It's turned off by default because it's slower if you
+ # are using only default views.
+ # config.scoped_views = false
+
+ # Configure the default scope given to Warden. By default it's the first
+ # devise role declared in your routes (usually :user).
+ # config.default_scope = :user
+
+ # Set this configuration to false if you want /users/sign_out to sign out
+ # only the current scope. By default, Devise signs out all scopes.
+ # config.sign_out_all_scopes = true
+
+ # ==> Navigation configuration
+ # Lists the formats that should be treated as navigational. Formats like
+ # :html, should redirect to the sign in page when the user does not have
+ # access, but formats like :xml or :json, should return 401.
+ #
+ # If you have any extra navigational formats, like :iphone or :mobile, you
+ # should add them to the navigational formats lists.
+ #
+ # The "*/*" below is required to match Internet Explorer requests.
+ # config.navigational_formats = ['*/*', :html]
+
+ # The default HTTP method used to sign out a resource. Default is :delete.
+ config.sign_out_via = :delete
+
+ # ==> OmniAuth
+ # Add a new OmniAuth provider. Check the wiki for more information on setting
+ # up on your models and hooks.
+ # config.omniauth :github, 'APP_ID', 'APP_SECRET', scope: 'user,public_repo'
+
+ # ==> Warden configuration
+ # If you want to use other strategies, that are not supported by Devise, or
+ # change the failure app, you can configure them inside the config.warden block.
+ #
+ # config.warden do |manager|
+ # manager.intercept_401 = false
+ # manager.default_strategies(scope: :user).unshift :some_external_strategy
+ # end
+
+ # ==> Mountable engine configurations
+ # When using Devise inside an engine, let's call it `MyEngine`, and this engine
+ # is mountable, there are some extra configurations to be taken into account.
+ # The following options are available, assuming the engine is mounted as:
+ #
+ # mount MyEngine, at: '/my_engine'
+ #
+ # The router that invoked `devise_for`, in the example above, would be:
+ # config.router_name = :my_engine
+ #
+ # When using OmniAuth, Devise cannot automatically set OmniAuth path,
+ # so you need to do it manually. For the users scope, it would be:
+ # config.omniauth_path_prefix = '/my_engine/users/auth'
+
+ # ==> Turbolinks configuration
+ # If your app is using Turbolinks, Turbolinks::Controller needs to be included to make redirection work correctly:
+ #
+ # ActiveSupport.on_load(:devise_failure_app) do
+ # include Turbolinks::Controller
+ # end
+
+ # ==> Configuration for :registerable
+
+ # When set to false, does not sign a user in automatically after their password is
+ # changed. Defaults to true, so a user is signed in automatically after changing a password.
+ # config.sign_in_after_change_password = true
+end
diff --git a/config/locales/devise.en.yml b/config/locales/devise.en.yml
new file mode 100644
index 000000000..ab1f07060
--- /dev/null
+++ b/config/locales/devise.en.yml
@@ -0,0 +1,65 @@
+# Additional translations at https://github.com/heartcombo/devise/wiki/I18n
+
+en:
+ devise:
+ confirmations:
+ confirmed: "Your email address has been successfully confirmed."
+ send_instructions: "You will receive an email with instructions for how to confirm your email address in a few minutes."
+ send_paranoid_instructions: "If your email address exists in our database, you will receive an email with instructions for how to confirm your email address in a few minutes."
+ failure:
+ already_authenticated: "You are already signed in."
+ inactive: "Your account is not activated yet."
+ invalid: "Invalid %{authentication_keys} or password."
+ locked: "Your account is locked."
+ last_attempt: "You have one more attempt before your account is locked."
+ not_found_in_database: "Invalid %{authentication_keys} or password."
+ timeout: "Your session expired. Please sign in again to continue."
+ unauthenticated: "You need to sign in or sign up before continuing."
+ unconfirmed: "You have to confirm your email address before continuing."
+ mailer:
+ confirmation_instructions:
+ subject: "Confirmation instructions"
+ reset_password_instructions:
+ subject: "Reset password instructions"
+ unlock_instructions:
+ subject: "Unlock instructions"
+ email_changed:
+ subject: "Email Changed"
+ password_change:
+ subject: "Password Changed"
+ omniauth_callbacks:
+ failure: "Could not authenticate you from %{kind} because \"%{reason}\"."
+ success: "Successfully authenticated from %{kind} account."
+ passwords:
+ no_token: "You can't access this page without coming from a password reset email. If you do come from a password reset email, please make sure you used the full URL provided."
+ send_instructions: "You will receive an email with instructions on how to reset your password in a few minutes."
+ send_paranoid_instructions: "If your email address exists in our database, you will receive a password recovery link at your email address in a few minutes."
+ updated: "Your password has been changed successfully. You are now signed in."
+ updated_not_active: "Your password has been changed successfully."
+ registrations:
+ destroyed: "Bye! Your account has been successfully cancelled. We hope to see you again soon."
+ signed_up: "Welcome! You have signed up successfully."
+ signed_up_but_inactive: "You have signed up successfully. However, we could not sign you in because your account is not yet activated."
+ signed_up_but_locked: "You have signed up successfully. However, we could not sign you in because your account is locked."
+ signed_up_but_unconfirmed: "A message with a confirmation link has been sent to your email address. Please follow the link to activate your account."
+ update_needs_confirmation: "You updated your account successfully, but we need to verify your new email address. Please check your email and follow the confirmation link to confirm your new email address."
+ updated: "Your account has been updated successfully."
+ updated_but_not_signed_in: "Your account has been updated successfully, but since your password was changed, you need to sign in again"
+ sessions:
+ signed_in: "Signed in successfully."
+ signed_out: "Signed out successfully."
+ already_signed_out: "Signed out successfully."
+ unlocks:
+ send_instructions: "You will receive an email with instructions for how to unlock your account in a few minutes."
+ send_paranoid_instructions: "If your account exists, you will receive an email with instructions for how to unlock it in a few minutes."
+ unlocked: "Your account has been unlocked successfully. Please sign in to continue."
+ errors:
+ messages:
+ already_confirmed: "was already confirmed, please try signing in"
+ confirmation_period_expired: "needs to be confirmed within %{period}, please request a new one"
+ expired: "has expired, please request a new one"
+ not_found: "not found"
+ not_locked: "was not locked"
+ not_saved:
+ one: "1 error prohibited this %{resource} from being saved:"
+ other: "%{count} errors prohibited this %{resource} from being saved:"
diff --git a/config/routes.rb b/config/routes.rb
index c06383a17..badf52b96 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -1,3 +1,23 @@
Rails.application.routes.draw do
+ devise_for :tourists
+ devise_for :agencies
+ devise_for :admins, skip: :registration
+
# For details on the DSL available within this file, see https://guides.rubyonrails.org/routing.html
+
+ root "home#index"
+
+ resources :admins
+ resources :agencies, only: [:index, :show, :update]
+ resources :tourists, only: :show
+ resources :tours, except: [:destroy]
+ resources :tourist_tours, except: [:new, :edit, :update]
+ resources :travel_transactions, only: [:index]
+ resources :chat_rooms, only: [:index, :show]
+ resources :messages, only: [:create]
+ resources :checkouts, only: [:create]
+ resources :webhooks, only: [:create]
+ post 'chat_user', to: 'chat_rooms#chat_user', as: 'chat_user'
+ get '/tourist_tours/new/:tour_id', to: 'tourist_tours#new', as: 'new_tourist_tour'
+
end
diff --git a/config/storage.yml b/config/storage.yml
index d32f76e8f..ecc7b0ad9 100644
--- a/config/storage.yml
+++ b/config/storage.yml
@@ -7,12 +7,12 @@ local:
root: <%= Rails.root.join("storage") %>
# Use rails credentials:edit to set the AWS secrets (as aws:access_key_id|secret_access_key)
-# amazon:
-# service: S3
-# access_key_id: <%= Rails.application.credentials.dig(:aws, :access_key_id) %>
-# secret_access_key: <%= Rails.application.credentials.dig(:aws, :secret_access_key) %>
-# region: us-east-1
-# bucket: your_own_bucket
+amazon:
+ service: S3
+ access_key_id: <%= Rails.application.credentials.dig(:aws, :access_key_id) %>
+ secret_access_key: <%= Rails.application.credentials.dig(:aws, :secret_access_key) %>
+ region: ap-southeast-1
+ bucket: travel-go
# Remember not to checkin your GCS keyfile to a repository
# google:
@@ -31,4 +31,4 @@ local:
# mirror:
# service: Mirror
# primary: local
-# mirrors: [ amazon, google, microsoft ]
+# mirrors: [ amazon, google, microsoft ]
\ No newline at end of file
diff --git a/config/webpack/environment.js b/config/webpack/environment.js
index d16d9af74..3cf52851b 100644
--- a/config/webpack/environment.js
+++ b/config/webpack/environment.js
@@ -1,3 +1,8 @@
const { environment } = require('@rails/webpacker')
-
+const webpack = require("webpack")
+environment.plugins.append("Provide", new webpack.ProvidePlugin({
+ $: 'jquery',
+ jQuery: 'jquery',
+ Popper: ['popper.js', 'default']
+}))
module.exports = environment
diff --git a/config/webpacker.yml b/config/webpacker.yml
index 8581ac047..79711bc8d 100644
--- a/config/webpacker.yml
+++ b/config/webpacker.yml
@@ -53,7 +53,7 @@ development:
compile: true
# Verifies that correct packages and versions are installed by inspecting package.json, yarn.lock, and node_modules
- check_yarn_integrity: true
+ check_yarn_integrity: false
# Reference: https://webpack.js.org/configuration/dev-server/
dev_server:
diff --git a/db/migrate/20210712140032_create_active_storage_tables.active_storage.rb b/db/migrate/20210712140032_create_active_storage_tables.active_storage.rb
new file mode 100644
index 000000000..0b2ce257c
--- /dev/null
+++ b/db/migrate/20210712140032_create_active_storage_tables.active_storage.rb
@@ -0,0 +1,27 @@
+# This migration comes from active_storage (originally 20170806125915)
+class CreateActiveStorageTables < ActiveRecord::Migration[5.2]
+ def change
+ create_table :active_storage_blobs do |t|
+ t.string :key, null: false
+ t.string :filename, null: false
+ t.string :content_type
+ t.text :metadata
+ t.bigint :byte_size, null: false
+ t.string :checksum, null: false
+ t.datetime :created_at, null: false
+
+ t.index [ :key ], unique: true
+ end
+
+ create_table :active_storage_attachments do |t|
+ t.string :name, null: false
+ t.references :record, null: false, polymorphic: true, index: false
+ t.references :blob, null: false
+
+ t.datetime :created_at, null: false
+
+ t.index [ :record_type, :record_id, :name, :blob_id ], name: "index_active_storage_attachments_uniqueness", unique: true
+ t.foreign_key :active_storage_blobs, column: :blob_id
+ end
+ end
+end
diff --git a/db/migrate/20210712140502_devise_create_users.rb b/db/migrate/20210712140502_devise_create_users.rb
new file mode 100644
index 000000000..a655fc42c
--- /dev/null
+++ b/db/migrate/20210712140502_devise_create_users.rb
@@ -0,0 +1,59 @@
+# frozen_string_literal: true
+
+class DeviseCreateUsers < ActiveRecord::Migration[6.0]
+ def change
+ create_table :users do |t|
+ ## Database authenticatable
+ t.string :email, null: false, default: ""
+ t.string :encrypted_password, null: false, default: ""
+ t.integer :contact_number
+ t.string :address
+ t.string :type
+ ## Tourist
+ t.string :first_name
+ t.string :middle_name
+ t.string :last_name
+ t.date :birth_date
+
+ ##Travel Agency
+ t.string :agency_name
+ t.decimal :average_rating
+ t.bigint :verified_by
+ t.boolean :active, default: true
+
+
+ ## Recoverable
+ t.string :reset_password_token
+ t.datetime :reset_password_sent_at
+
+ ## Rememberable
+ t.datetime :remember_created_at
+
+ ## Trackable
+ # t.integer :sign_in_count, default: 0, null: false
+ # t.datetime :current_sign_in_at
+ # t.datetime :last_sign_in_at
+ # t.string :current_sign_in_ip
+ # t.string :last_sign_in_ip
+
+ ## Confirmable
+ # t.string :confirmation_token
+ # t.datetime :confirmed_at
+ # t.datetime :confirmation_sent_at
+ # t.string :unconfirmed_email # Only if using reconfirmable
+
+ ## Lockable
+ # t.integer :failed_attempts, default: 0, null: false # Only if lock strategy is :failed_attempts
+ # t.string :unlock_token # Only if unlock strategy is :email or :both
+ # t.datetime :locked_at
+
+
+ t.timestamps null: false
+ end
+
+ add_index :users, :email, unique: true
+ add_index :users, :reset_password_token, unique: true
+ # add_index :users, :confirmation_token, unique: true
+ # add_index :users, :unlock_token, unique: true
+ end
+end
diff --git a/db/migrate/20210712140709_create_tours.rb b/db/migrate/20210712140709_create_tours.rb
new file mode 100644
index 000000000..4626fcb0a
--- /dev/null
+++ b/db/migrate/20210712140709_create_tours.rb
@@ -0,0 +1,13 @@
+class CreateTours < ActiveRecord::Migration[6.0]
+ def change
+ create_table :tours do |t|
+ t.belongs_to :agency
+ t.string :name
+ t.decimal :price
+ t.string :location
+ t.integer :duration
+ t.boolean :active, default: true
+ t.timestamps
+ end
+ end
+end
diff --git a/db/migrate/20210712140806_create_tourist_tours.rb b/db/migrate/20210712140806_create_tourist_tours.rb
new file mode 100644
index 000000000..7998c80a2
--- /dev/null
+++ b/db/migrate/20210712140806_create_tourist_tours.rb
@@ -0,0 +1,13 @@
+class CreateTouristTours < ActiveRecord::Migration[6.0]
+ def change
+ create_table :tourist_tours do |t|
+ t.belongs_to :tourist
+ t.belongs_to :tour
+ t.integer :guest_quantity
+ t.decimal :amount_bought
+ t.date :start_date
+ t.date :end_date
+ t.timestamps
+ end
+ end
+end
diff --git a/db/migrate/20210712140856_create_travel_transactions.rb b/db/migrate/20210712140856_create_travel_transactions.rb
new file mode 100644
index 000000000..cf0ab7747
--- /dev/null
+++ b/db/migrate/20210712140856_create_travel_transactions.rb
@@ -0,0 +1,10 @@
+class CreateTravelTransactions < ActiveRecord::Migration[6.0]
+ def change
+ create_table :travel_transactions do |t|
+ t.belongs_to :tourist_tour
+ t.belongs_to :agency
+ t.decimal :total_price
+ t.timestamps
+ end
+ end
+end
diff --git a/db/migrate/20210712140925_create_reviews.rb b/db/migrate/20210712140925_create_reviews.rb
new file mode 100644
index 000000000..341478814
--- /dev/null
+++ b/db/migrate/20210712140925_create_reviews.rb
@@ -0,0 +1,11 @@
+class CreateReviews < ActiveRecord::Migration[6.0]
+ def change
+ create_table :reviews do |t|
+ t.belongs_to :agency
+ t.belongs_to :tourist
+ t.text :review
+ t.decimal :rating
+ t.timestamps
+ end
+ end
+end
diff --git a/db/migrate/20210716070806_create_chat_rooms.rb b/db/migrate/20210716070806_create_chat_rooms.rb
new file mode 100644
index 000000000..a75fccfd5
--- /dev/null
+++ b/db/migrate/20210716070806_create_chat_rooms.rb
@@ -0,0 +1,7 @@
+class CreateChatRooms < ActiveRecord::Migration[6.0]
+ def change
+ create_table :chat_rooms do |t|
+ t.timestamps
+ end
+ end
+end
diff --git a/db/migrate/20210716070910_create_messages.rb b/db/migrate/20210716070910_create_messages.rb
new file mode 100644
index 000000000..3a626712a
--- /dev/null
+++ b/db/migrate/20210716070910_create_messages.rb
@@ -0,0 +1,10 @@
+class CreateMessages < ActiveRecord::Migration[6.0]
+ def change
+ create_table :messages do |t|
+ t.belongs_to :chat_room
+ t.belongs_to :user
+ t.text :body
+ t.timestamps
+ end
+ end
+end
diff --git a/db/migrate/20210716071040_create_action_text_tables.action_text.rb b/db/migrate/20210716071040_create_action_text_tables.action_text.rb
new file mode 100644
index 000000000..5dfbd1561
--- /dev/null
+++ b/db/migrate/20210716071040_create_action_text_tables.action_text.rb
@@ -0,0 +1,14 @@
+# This migration comes from action_text (originally 20180528164100)
+class CreateActionTextTables < ActiveRecord::Migration[6.0]
+ def change
+ create_table :action_text_rich_texts do |t|
+ t.string :name, null: false
+ t.text :body, size: :long
+ t.references :record, null: false, polymorphic: true, index: false
+
+ t.timestamps
+
+ t.index [ :record_type, :record_id, :name ], name: "index_action_text_rich_texts_uniqueness", unique: true
+ end
+ end
+end
diff --git a/db/migrate/20210716071208_create_chat_room_users.rb b/db/migrate/20210716071208_create_chat_room_users.rb
new file mode 100644
index 000000000..015af7120
--- /dev/null
+++ b/db/migrate/20210716071208_create_chat_room_users.rb
@@ -0,0 +1,9 @@
+class CreateChatRoomUsers < ActiveRecord::Migration[6.0]
+ def change
+ create_table :chat_room_users do |t|
+ t.belongs_to :user
+ t.belongs_to :chat_room
+ t.timestamps
+ end
+ end
+end
diff --git a/db/migrate/20210716071248_add_column_to_users.rb b/db/migrate/20210716071248_add_column_to_users.rb
new file mode 100644
index 000000000..c4c60c2c3
--- /dev/null
+++ b/db/migrate/20210716071248_add_column_to_users.rb
@@ -0,0 +1,5 @@
+class AddColumnToUsers < ActiveRecord::Migration[6.0]
+ def change
+ add_column :users, :approved, :boolean, default: false
+ end
+end
diff --git a/db/migrate/20210717023742_change_contact_type.rb b/db/migrate/20210717023742_change_contact_type.rb
new file mode 100644
index 000000000..82d942297
--- /dev/null
+++ b/db/migrate/20210717023742_change_contact_type.rb
@@ -0,0 +1,5 @@
+class ChangeContactType < ActiveRecord::Migration[6.0]
+ def change
+ change_column :users, :contact_number, :string
+ end
+end
diff --git a/db/schema.rb b/db/schema.rb
index b10373ba6..b85b15c78 100644
--- a/db/schema.rb
+++ b/db/schema.rb
@@ -10,9 +10,135 @@
#
# It's strongly recommended that you check this file into your version control system.
-ActiveRecord::Schema.define(version: 0) do
+ActiveRecord::Schema.define(version: 2021_07_17_023742) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
+ create_table "action_text_rich_texts", force: :cascade do |t|
+ t.string "name", null: false
+ t.text "body"
+ t.string "record_type", null: false
+ t.bigint "record_id", null: false
+ t.datetime "created_at", precision: 6, null: false
+ t.datetime "updated_at", precision: 6, null: false
+ t.index ["record_type", "record_id", "name"], name: "index_action_text_rich_texts_uniqueness", unique: true
+ end
+
+ create_table "active_storage_attachments", force: :cascade do |t|
+ t.string "name", null: false
+ t.string "record_type", null: false
+ t.bigint "record_id", null: false
+ t.bigint "blob_id", null: false
+ t.datetime "created_at", null: false
+ t.index ["blob_id"], name: "index_active_storage_attachments_on_blob_id"
+ t.index ["record_type", "record_id", "name", "blob_id"], name: "index_active_storage_attachments_uniqueness", unique: true
+ end
+
+ create_table "active_storage_blobs", force: :cascade do |t|
+ t.string "key", null: false
+ t.string "filename", null: false
+ t.string "content_type"
+ t.text "metadata"
+ t.bigint "byte_size", null: false
+ t.string "checksum", null: false
+ t.datetime "created_at", null: false
+ t.index ["key"], name: "index_active_storage_blobs_on_key", unique: true
+ end
+
+ create_table "chat_room_users", force: :cascade do |t|
+ t.bigint "user_id"
+ t.bigint "chat_room_id"
+ t.datetime "created_at", precision: 6, null: false
+ t.datetime "updated_at", precision: 6, null: false
+ t.index ["chat_room_id"], name: "index_chat_room_users_on_chat_room_id"
+ t.index ["user_id"], name: "index_chat_room_users_on_user_id"
+ end
+
+ create_table "chat_rooms", force: :cascade do |t|
+ t.datetime "created_at", precision: 6, null: false
+ t.datetime "updated_at", precision: 6, null: false
+ end
+
+ create_table "messages", force: :cascade do |t|
+ t.bigint "chat_room_id"
+ t.bigint "user_id"
+ t.text "body"
+ t.datetime "created_at", precision: 6, null: false
+ t.datetime "updated_at", precision: 6, null: false
+ t.index ["chat_room_id"], name: "index_messages_on_chat_room_id"
+ t.index ["user_id"], name: "index_messages_on_user_id"
+ end
+
+ create_table "reviews", force: :cascade do |t|
+ t.bigint "agency_id"
+ t.bigint "tourist_id"
+ t.text "review"
+ t.decimal "rating"
+ t.datetime "created_at", precision: 6, null: false
+ t.datetime "updated_at", precision: 6, null: false
+ t.index ["agency_id"], name: "index_reviews_on_agency_id"
+ t.index ["tourist_id"], name: "index_reviews_on_tourist_id"
+ end
+
+ create_table "tourist_tours", force: :cascade do |t|
+ t.bigint "tourist_id"
+ t.bigint "tour_id"
+ t.integer "guest_quantity"
+ t.decimal "amount_bought"
+ t.date "start_date"
+ t.date "end_date"
+ t.datetime "created_at", precision: 6, null: false
+ t.datetime "updated_at", precision: 6, null: false
+ t.index ["tour_id"], name: "index_tourist_tours_on_tour_id"
+ t.index ["tourist_id"], name: "index_tourist_tours_on_tourist_id"
+ end
+
+ create_table "tours", force: :cascade do |t|
+ t.bigint "agency_id"
+ t.string "name"
+ t.decimal "price"
+ t.string "location"
+ t.integer "duration"
+ t.boolean "active", default: true
+ t.datetime "created_at", precision: 6, null: false
+ t.datetime "updated_at", precision: 6, null: false
+ t.index ["agency_id"], name: "index_tours_on_agency_id"
+ end
+
+ create_table "travel_transactions", force: :cascade do |t|
+ t.bigint "tourist_tour_id"
+ t.bigint "agency_id"
+ t.decimal "total_price"
+ t.datetime "created_at", precision: 6, null: false
+ t.datetime "updated_at", precision: 6, null: false
+ t.index ["agency_id"], name: "index_travel_transactions_on_agency_id"
+ t.index ["tourist_tour_id"], name: "index_travel_transactions_on_tourist_tour_id"
+ end
+
+ create_table "users", force: :cascade do |t|
+ t.string "email", default: "", null: false
+ t.string "encrypted_password", default: "", null: false
+ t.string "contact_number"
+ t.string "address"
+ t.string "type"
+ t.string "first_name"
+ t.string "middle_name"
+ t.string "last_name"
+ t.date "birth_date"
+ t.string "agency_name"
+ t.decimal "average_rating"
+ t.bigint "verified_by"
+ t.boolean "active", default: true
+ t.string "reset_password_token"
+ t.datetime "reset_password_sent_at"
+ t.datetime "remember_created_at"
+ t.datetime "created_at", precision: 6, null: false
+ t.datetime "updated_at", precision: 6, null: false
+ t.boolean "approved", default: false
+ t.index ["email"], name: "index_users_on_email", unique: true
+ t.index ["reset_password_token"], name: "index_users_on_reset_password_token", unique: true
+ end
+
+ add_foreign_key "active_storage_attachments", "active_storage_blobs", column: "blob_id"
end
diff --git a/package.json b/package.json
index b56a1d18e..dbe838d5f 100644
--- a/package.json
+++ b/package.json
@@ -2,10 +2,15 @@
"name": "rails_project",
"private": true,
"dependencies": {
+ "@popperjs/core": "^2.9.2",
"@rails/actioncable": "^6.0.0",
+ "@rails/actiontext": "^6.0.3-6",
"@rails/activestorage": "^6.0.0",
"@rails/ujs": "^6.0.0",
"@rails/webpacker": "4.3.0",
+ "bootstrap": "^5.0.2",
+ "jquery": "^3.6.0",
+ "trix": "^1.2.0",
"turbolinks": "^5.2.0"
},
"version": "0.1.0",
diff --git a/spec/models/chat_room_spec.rb b/spec/models/chat_room_spec.rb
new file mode 100644
index 000000000..6f48ed43b
--- /dev/null
+++ b/spec/models/chat_room_spec.rb
@@ -0,0 +1,19 @@
+require 'rails_helper'
+
+RSpec.describe ChatRoom, type: :model do
+ let!(:chat_room) { described_class.new }
+
+ context 'with validations of relationship' do
+ it 'belongs to messages' do
+ expect(chat_room).to have_many(:messages)
+ end
+
+ it 'belongs to a chat room users' do
+ expect(chat_room).to have_many(:chat_room_users)
+ end
+
+ it 'belongs to a users' do
+ expect(chat_room).to have_many(:users)
+ end
+ end
+end
diff --git a/spec/models/chat_room_user_spec.rb b/spec/models/chat_room_user_spec.rb
new file mode 100644
index 000000000..ff888877f
--- /dev/null
+++ b/spec/models/chat_room_user_spec.rb
@@ -0,0 +1,15 @@
+require 'rails_helper'
+
+RSpec.describe ChatRoomUser, type: :model do
+ let!(:chat_room_user) { described_class.new }
+
+ context 'with validations of relationship' do
+ it 'belongs to tourist tour' do
+ expect(chat_room_user).to belong_to(:user)
+ end
+
+ it 'belongs to a agency' do
+ expect(chat_room_user).to belong_to(:chat_room)
+ end
+ end
+end
diff --git a/spec/models/message_spec.rb b/spec/models/message_spec.rb
new file mode 100644
index 000000000..f96091a4a
--- /dev/null
+++ b/spec/models/message_spec.rb
@@ -0,0 +1,15 @@
+require 'rails_helper'
+
+RSpec.describe Message, type: :model do
+ let!(:message) { described_class.new }
+
+ context 'with validations of relationship' do
+ it 'belongs to chat room' do
+ expect(message).to belong_to(:chat_room)
+ end
+
+ it 'belongs to a user' do
+ expect(message).to belong_to(:user)
+ end
+ end
+end
diff --git a/spec/models/review_spec.rb b/spec/models/review_spec.rb
new file mode 100644
index 000000000..f78c523f4
--- /dev/null
+++ b/spec/models/review_spec.rb
@@ -0,0 +1,21 @@
+require 'rails_helper'
+
+RSpec.describe Review, type: :model do
+ let!(:review) { described_class.new }
+
+ context 'with validations' do
+ it 'must have a valid rating' do
+ expect(review).to validate_numericality_of(:rating).is_greater_than_or_equal_to(0)
+ end
+ end
+
+ context 'with validations of relationship' do
+ it 'belongs to agency' do
+ expect(review).to belong_to(:agency)
+ end
+
+ it 'belongs to a tourist' do
+ expect(review).to belong_to(:tourist)
+ end
+ end
+end
diff --git a/spec/models/tour_spec.rb b/spec/models/tour_spec.rb
new file mode 100644
index 000000000..587e85499
--- /dev/null
+++ b/spec/models/tour_spec.rb
@@ -0,0 +1,41 @@
+require 'rails_helper'
+
+RSpec.describe Tour, type: :model do
+ let!(:tour) { described_class.new }
+
+ context 'with validations' do
+ it 'is not valid without name' do
+ expect(tour).to validate_presence_of(:name)
+ end
+
+ it 'must have atlease 1 character' do
+ expect(tour).to validate_length_of(:name)
+ .is_at_least(1)
+ .on(:create)
+ end
+
+ it 'is not valid without location' do
+ expect(tour).to validate_presence_of(:location)
+ end
+
+ it 'must have at least 1 character' do
+ expect(tour).to validate_length_of(:location)
+ .is_at_least(1)
+ .on(:create)
+ end
+
+ it 'must have a valid price' do
+ expect(tour).to validate_numericality_of(:price).is_greater_than_or_equal_to(0)
+ end
+
+ it 'must have a valid duration' do
+ expect(tour).to validate_numericality_of(:duration).is_greater_than_or_equal_to(1)
+ end
+ end
+
+ context 'with validations of relationship' do
+ it 'belongs to agency' do
+ expect(tour).to belong_to(:agency)
+ end
+ end
+end
diff --git a/spec/models/tourist_tour_spec.rb b/spec/models/tourist_tour_spec.rb
new file mode 100644
index 000000000..6ac39ca8f
--- /dev/null
+++ b/spec/models/tourist_tour_spec.rb
@@ -0,0 +1,15 @@
+require 'rails_helper'
+
+RSpec.describe TouristTour, type: :model do
+ let!(:tourist_tour) { described_class.new }
+
+ context 'with validations' do
+ it 'must have a valid guest quantity' do
+ expect(tourist_tour).to validate_numericality_of(:guest_quantity).is_greater_than_or_equal_to(1)
+ end
+
+ it 'must have a valid amount bought' do
+ expect(tourist_tour).to validate_numericality_of(:amount_bought).is_greater_than_or_equal_to(0)
+ end
+ end
+end
diff --git a/spec/models/travel_transaction_spec.rb b/spec/models/travel_transaction_spec.rb
new file mode 100644
index 000000000..8de15be20
--- /dev/null
+++ b/spec/models/travel_transaction_spec.rb
@@ -0,0 +1,21 @@
+require 'rails_helper'
+
+RSpec.describe TravelTransaction, type: :model do
+ let!(:travel_transaction) { described_class.new }
+
+ context 'with validations' do
+ it 'must have a valid amount bought' do
+ expect(travel_transaction).to validate_numericality_of(:total_price).is_greater_than_or_equal_to(1)
+ end
+ end
+
+ context 'with validations of relationship' do
+ it 'belongs to tourist tour' do
+ expect(travel_transaction).to belong_to(:tourist_tour)
+ end
+
+ it 'belongs to a agency' do
+ expect(travel_transaction).to belong_to(:agency)
+ end
+ end
+end
diff --git a/spec/rails_helper.rb b/spec/rails_helper.rb
index 69a565b8e..115f2d25f 100644
--- a/spec/rails_helper.rb
+++ b/spec/rails_helper.rb
@@ -21,7 +21,7 @@
config.use_transactional_fixtures = false
config.infer_spec_type_from_file_location!
config.filter_rails_from_backtrace!
-
+ config.include Devise::Test::IntegrationHelpers
config.include FactoryBot::Syntax::Methods
config.before(:suite) do
diff --git a/spec/requests/admins_controllers_spec.rb b/spec/requests/admins_controllers_spec.rb
new file mode 100644
index 000000000..8250c0603
--- /dev/null
+++ b/spec/requests/admins_controllers_spec.rb
@@ -0,0 +1,38 @@
+require 'rails_helper'
+
+RSpec.describe 'AdminsControllers', type: :request do
+ let!(:admin) { Admin.create(email: 'admin@email.com', first_name: 'Admin', last_name: 'Last', password: '1234567') }
+
+ before do
+ sign_in(admin)
+ end
+
+ context 'when GET admins' do
+ it 'shows the index page' do
+ get admins_path
+ expect(response).to have_http_status(:ok)
+ end
+
+ it 'shows the selected admin' do
+ get admin_path(admin)
+ expect(response).to have_http_status(:ok)
+ end
+
+ it 'shows the new admin template' do
+ get new_admin_path
+ expect(response).to have_http_status(:ok)
+ end
+ end
+
+ context 'when POST and PATCH admins' do
+ it 'creates a new admin' do
+ post admins_path, params: { admin: { email: 'admin2@email.com', first_name: 'Admin', last_name: 'Last', birth_date: Date.new(1999, 10, 10), address: 'Kyoto, Japan', password: '1234567' } }
+ expect(response).to redirect_to(admins_path)
+ end
+
+ it 'updates a new admin' do
+ patch admin_path(admin), params: { admin: { email: 'admin4@email.com', first_name: 'Admin2', last_name: 'Last', birth_date: Date.new(1999, 10, 10), address: 'Kyoto, Japan', password: '1234567' } }
+ expect(response).to redirect_to(admin_path(admin))
+ end
+ end
+end
diff --git a/spec/requests/agencies_controllers_spec.rb b/spec/requests/agencies_controllers_spec.rb
new file mode 100644
index 000000000..764601dcb
--- /dev/null
+++ b/spec/requests/agencies_controllers_spec.rb
@@ -0,0 +1,27 @@
+require 'rails_helper'
+
+RSpec.describe 'AgenciesControllers', type: :request do
+ let!(:agency) { Agency.create(email: 'agency@email.com', agency_name: 'AgencyOne', address: 'address', password: '1234567') }
+ let!(:admin) { Admin.create(email: 'admin@email.com', first_name: 'Admin', last_name: 'Last', password: '1234567') }
+
+ before { sign_in(admin) }
+
+ context 'when GET agencies' do
+ it 'gets all agencies' do
+ get agencies_path
+ expect(response).to have_http_status(:ok)
+ end
+
+ it 'shows a specific agency' do
+ get agency_path(agency)
+ expect(response).to have_http_status(:ok)
+ end
+ end
+
+ context 'when PATCH agencies' do
+ it 'updates a specific agency' do
+ patch agency_path(agency), params: { agency: { email: 'agency5@email.com', agency_name: 'AgencyOne', password: '1234567', verified_by: admin.id } }
+ expect(response).to redirect_to(admins_path)
+ end
+ end
+end
diff --git a/spec/requests/chat_rooms_controllers_spec.rb b/spec/requests/chat_rooms_controllers_spec.rb
new file mode 100644
index 000000000..5fc142cb2
--- /dev/null
+++ b/spec/requests/chat_rooms_controllers_spec.rb
@@ -0,0 +1,45 @@
+require 'rails_helper'
+
+RSpec.describe 'ChatRoomsControllers', type: :request do
+ let!(:tourist) { create(:tourist) }
+ let!(:tourist2) { create(:tourist) }
+ let!(:agency) { create(:approved_agency) }
+ let!(:chat_room) { ChatRoom.create }
+
+ before do
+ chat_room.users << tourist
+ chat_room.users << agency
+ end
+
+ describe 'GET chat_rooms#index path' do
+ it 'returns a redirect response if not logged_in' do
+ get chat_rooms_path
+ expect(response).to have_http_status(:found)
+ end
+
+ it 'returns a success response if logged_in' do
+ sign_in(tourist)
+ get chat_rooms_path
+ expect(response).to have_http_status(:ok)
+ end
+ end
+
+ describe 'GET /chat_rooms/:id show path request response for different users' do
+ it 'returns a redirect response if not logged_in' do
+ get chat_room_path(chat_room)
+ expect(response).to have_http_status(:found)
+ end
+
+ it 'returns a success response if logged_in user owns the chatroom' do
+ sign_in(tourist)
+ get chat_room_path(chat_room)
+ expect(response).to have_http_status(:ok)
+ end
+
+ it 'returns a redirect response if logged_in user is not the owener of the chatroom' do
+ sign_in(tourist2)
+ get chat_room_path(chat_room)
+ expect(response).to have_http_status(:found)
+ end
+ end
+end
diff --git a/spec/requests/tourist_tours_controllers_spec.rb b/spec/requests/tourist_tours_controllers_spec.rb
new file mode 100644
index 000000000..46467830d
--- /dev/null
+++ b/spec/requests/tourist_tours_controllers_spec.rb
@@ -0,0 +1,84 @@
+require 'rails_helper'
+
+RSpec.describe 'TouristToursControllers', type: :request do
+ let!(:admin) { create(:admin) }
+ let!(:tourist) { create(:tourist) }
+ let!(:agency) { create(:approved_agency) }
+ let!(:tour) { create(:tour, agency: agency) }
+ let!(:tourist_tour) { create(:tourist_tour, tourist: tourist, tour: tour) }
+
+ describe 'GET tourist_tour index path request response for different users' do
+ it 'returns a redirect response if not logged_in ' do
+ get tourist_tours_path
+ expect(response).to have_http_status(:found)
+ end
+
+ it 'returns a success response if current_user is tourist ' do
+ sign_in(tourist)
+ get tourist_tours_path
+ expect(response).to have_http_status(:ok)
+ end
+
+ it 'returns a redirect response if current_user is agency ' do
+ sign_in(agency)
+ get tourist_tours_path
+ expect(response).to have_http_status(:found)
+ end
+
+ it 'returns a redirect response if current_user is admin ' do
+ sign_in(admin)
+ get tourist_tours_path
+ expect(response).to have_http_status(:found)
+ end
+ end
+
+ describe 'GET /tourist_tours/new/:tour_id path (new tourist_tour) for different users' do
+ it 'returns a redirect response if not logged_in ' do
+ get new_tourist_tour_path(tour)
+ expect(response).to have_http_status(:found)
+ end
+
+ it 'returns a redirect response if current_user is agency ' do
+ sign_in(agency)
+ get new_tourist_tour_path(tour)
+ expect(response).to have_http_status(:found)
+ end
+
+ it 'returns a redirect response if current_user is admin ' do
+ sign_in(admin)
+ get new_tourist_tour_path(tour)
+ expect(response).to have_http_status(:found)
+ end
+
+ it 'returns a success response if current_user is tourist ' do
+ sign_in(tourist)
+ get new_tourist_tour_path(tour)
+ expect(response).to have_http_status(:ok)
+ end
+ end
+
+ describe 'GET /tourist_tours/:id path (show tourist tour) for different users' do
+ it 'returns a redirect response if not logged_in ' do
+ get tourist_tours_path(tourist_tour)
+ expect(response).to have_http_status(:unauthorized)
+ end
+
+ it 'returns a redirect response if current_user is agency ' do
+ sign_in(agency)
+ get tourist_tours_path(tourist_tour)
+ expect(response).to have_http_status(:unauthorized)
+ end
+
+ it 'returns a redirect response if current_user is admin ' do
+ sign_in(admin)
+ get tourist_tours_path(tourist_tour)
+ expect(response).to have_http_status(:unauthorized)
+ end
+
+ it 'returns a success response if current_user is tourist ' do
+ sign_in(tourist)
+ get tourist_tours_path(tourist_tour)
+ expect(response).to have_http_status(:ok)
+ end
+ end
+end
diff --git a/spec/requests/tourists_controllers_spec.rb b/spec/requests/tourists_controllers_spec.rb
new file mode 100644
index 000000000..61c9ffb38
--- /dev/null
+++ b/spec/requests/tourists_controllers_spec.rb
@@ -0,0 +1,14 @@
+require 'rails_helper'
+
+RSpec.describe 'TouristsControllers', type: :request do
+ let!(:tourist) { Tourist.create(email: 'tourist@email.com', first_name: 'TouristOne', last_name: 'Tourist', address: 'Kyoto, Japan', birth_date: Date.new(1999, 8, 10), password: '1234567') }
+
+ before { sign_in(tourist) }
+
+ context 'when GET tourists' do
+ it 'works! (now write some real specs)' do
+ get tourist_path(tourist)
+ expect(response).to have_http_status(:ok)
+ end
+ end
+end
diff --git a/spec/requests/tours_controllers_spec.rb b/spec/requests/tours_controllers_spec.rb
new file mode 100644
index 000000000..f9f4bfb7d
--- /dev/null
+++ b/spec/requests/tours_controllers_spec.rb
@@ -0,0 +1,42 @@
+require 'rails_helper'
+
+RSpec.describe 'ToursControllers', type: :request do
+ let!(:agency) { create(:approved_agency) }
+ let!(:tour) { create(:tour, agency: agency) }
+
+ before { sign_in(agency) }
+
+ context 'when GET in tours' do
+ it 'gets all active tours' do
+ get tours_path
+ expect(response).to have_http_status(:ok)
+ end
+
+ it 'gets the specifc tour' do
+ get tour_path(tour)
+ expect(response).to have_http_status(:ok)
+ end
+
+ it 'gets the new tour template' do
+ get new_tour_path
+ expect(response).to have_http_status(:ok)
+ end
+
+ it 'gets the edit tour template' do
+ get edit_tour_path(tour)
+ expect(response).to have_http_status(:ok)
+ end
+ end
+
+ context 'when POST and PATCH tours' do
+ it 'posts a new tour' do
+ post tours_path, params: { tour: { name: 'Boracay', location: 'Boracay', duration: 3, price: 300, agency: agency } }
+ expect(response).to redirect_to(tours_path)
+ end
+
+ it 'updates a tour' do
+ patch tour_path(tour), params: { tour: { name: 'Boracay', location: 'Boracay', duration: 3, price: 300, agency: agency } }
+ expect(response).to redirect_to(tour_path)
+ end
+ end
+end
diff --git a/spec/requests/travel_transactions_controllers_spec.rb b/spec/requests/travel_transactions_controllers_spec.rb
new file mode 100644
index 000000000..d463ff125
--- /dev/null
+++ b/spec/requests/travel_transactions_controllers_spec.rb
@@ -0,0 +1,34 @@
+require 'rails_helper'
+
+RSpec.describe 'TravelTransactionsControllers', type: :request do
+ let!(:admin) { create(:admin) }
+ let!(:tourist) { create(:tourist) }
+ let!(:agency) { create(:approved_agency) }
+ let!(:tourist_tour) { create(:tourist_tour, tourist: tourist) }
+ let(:travel_transaction) { create(:travel_transaction, tourist_tour: tourist_tour, agency: agency) }
+
+ describe 'GET /travel_transactions index path request response for different users' do
+ it 'returns a redirect response if not logged_in ' do
+ get travel_transactions_path
+ expect(response).to have_http_status(:found)
+ end
+
+ it 'returns a success response if current_user is tourist ' do
+ sign_in(tourist)
+ get travel_transactions_path
+ expect(response).to have_http_status(:ok)
+ end
+
+ it 'returns a success response if current_user is agency ' do
+ sign_in(agency)
+ get travel_transactions_path
+ expect(response).to have_http_status(:ok)
+ end
+
+ it 'returns a success response if current_user is admin ' do
+ sign_in(admin)
+ get travel_transactions_path
+ expect(response).to have_http_status(:ok)
+ end
+ end
+end
diff --git a/test/factories/admins.rb b/test/factories/admins.rb
new file mode 100644
index 000000000..34a7c0735
--- /dev/null
+++ b/test/factories/admins.rb
@@ -0,0 +1,10 @@
+FactoryBot.define do
+ factory :admin do
+ email { "#{first_name.gsub(' ', '')}@email.com" }
+ password { 'secure123' }
+ address { 'Antipolo City' }
+ approved { true }
+ first_name { 'admin' }
+ type { 'Admin' }
+ end
+end
diff --git a/test/factories/agencies.rb b/test/factories/agencies.rb
new file mode 100644
index 000000000..c2241c63e
--- /dev/null
+++ b/test/factories/agencies.rb
@@ -0,0 +1,17 @@
+FactoryBot.define do
+ factory :agency do
+ sequence(:email) { |n| "#{agency_name.gsub(' ', '')}#{n}@email.com" }
+ password { 'secure123' }
+ address { 'Antipolo City' }
+ agency_name { 'Tourist Travel Tours' }
+ type { 'Agency' }
+ contact_number { '9307176311' }
+ average_rating { 5 }
+
+ trait :approved do
+ approved { true }
+ end
+
+ factory :approved_agency, traits: [:approved]
+ end
+end
diff --git a/test/factories/tourist_tours.rb b/test/factories/tourist_tours.rb
new file mode 100644
index 000000000..4b43a9848
--- /dev/null
+++ b/test/factories/tourist_tours.rb
@@ -0,0 +1,10 @@
+FactoryBot.define do
+ factory :tourist_tour do
+ guest_quantity { 2 }
+ amount_bought { 7998 }
+ start_date { '2021-07-16' }
+ end_date { '2021-07-19' }
+ tourist
+ tour
+ end
+end
diff --git a/test/factories/tourists.rb b/test/factories/tourists.rb
new file mode 100644
index 000000000..0d1aa4d5d
--- /dev/null
+++ b/test/factories/tourists.rb
@@ -0,0 +1,13 @@
+FactoryBot.define do
+ factory :tourist do
+ sequence(:email) { |n| "#{first_name.gsub(' ', '')}#{n}@email.com" }
+ password { 'secure123' }
+ address { 'Antipolo City' }
+ approved { true }
+ first_name { 'Tourist' }
+ middle_name { 'New' }
+ last_name { 'Gala' }
+ birth_date { '2006-01-01' }
+ type { 'Tourist' }
+ end
+end
diff --git a/test/factories/tours.rb b/test/factories/tours.rb
new file mode 100644
index 000000000..56dcf2082
--- /dev/null
+++ b/test/factories/tours.rb
@@ -0,0 +1,9 @@
+FactoryBot.define do
+ factory :tour do
+ name { 'Trip to Boracay 3 days and 2 nights' }
+ price { 3999 }
+ location { 'Boracay' }
+ duration { 3 }
+ agency
+ end
+end
diff --git a/test/factories/travel_transactions.rb b/test/factories/travel_transactions.rb
new file mode 100644
index 000000000..ec288ca50
--- /dev/null
+++ b/test/factories/travel_transactions.rb
@@ -0,0 +1,7 @@
+FactoryBot.define do
+ factory :travel_transaction do
+ total_price { 19_995 }
+ tourist_tour
+ agency
+ end
+end
diff --git a/test/fixtures/action_text/rich_texts.yml b/test/fixtures/action_text/rich_texts.yml
new file mode 100644
index 000000000..8b371ea60
--- /dev/null
+++ b/test/fixtures/action_text/rich_texts.yml
@@ -0,0 +1,4 @@
+# one:
+# record: name_of_fixture (ClassOfFixture)
+# name: content
+# body: