Skip to content

Commit

Permalink
Completed Integration tests for 'users' and 'home' controller (#74)
Browse files Browse the repository at this point in the history
* Addes some tests for users profile

* Adding tp correct branch

* Added 2 tests to users. TODO: password change

* corrected tests

* Skipping password change tests as this is handled by devise.

* fix for #66 as suggested by @anantshri

* changed padding unit to em

* Added notes for Docker Desktop on Windows

* Create users_password integration test

* Completed integration tests for home page

Co-authored-by: Abhisek Datta <[email protected]>
  • Loading branch information
sunilkr and abhisek authored Mar 27, 2021
1 parent 14f6472 commit 3f752de
Show file tree
Hide file tree
Showing 5 changed files with 124 additions and 46 deletions.
6 changes: 5 additions & 1 deletion doc/developer-guide-docker-compose.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,11 @@
2. Docker Compose
3. Visual Studio Code

> *Note:* If you are on Windows, you might want to use the [Vagrantfile](https://github.com/null-open-security-community/swachalit/blob/master/Vagrantfile) with [VirtualBox](https://www.virtualbox.org/wiki/Downloads) and [Vagrant](https://www.vagrantup.com/downloads.html). Refer to [Setting up Development Environment with Vagrant](vagrant.md)
### Windows

If you are on Windows but not on latest versions *(1903)* of Windows 10, you need to to use the [Vagrantfile](https://github.com/null-open-security-community/swachalit/blob/master/Vagrantfile) with [VirtualBox](https://www.virtualbox.org/wiki/Downloads) and [Vagrant](https://www.vagrantup.com/downloads.html). Refer to [Setting up Development Environment with Vagrant](vagrant.md).

If you are using relatively latest 64 bit Windows 10 version *(1903 or higher)*, you may consider using [Docker for Desktop](https://docs.docker.com/docker-for-windows/install-windows-home/) with [WSL2 backend](https://docs.microsoft.com/en-us/windows/wsl/install-win10).

## Clone Repository

Expand Down
9 changes: 8 additions & 1 deletion test/fixtures/pages.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/Fixtures.html

one: {}
one:
id: 1
name: "page-1"
description: 'Test page 1'
navigation_name: 'page1'
content: "This is test page 1"
published: true


two: {}
68 changes: 68 additions & 0 deletions test/integration/home_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
require 'test_helper'

class HomeTest < ActionDispatch::IntegrationTest
include Devise::Test::IntegrationHelpers

setup do
ENV["SWACHALIT_DISABLE_BACKGROUND_TASKS"] = "1"
sign_in users(:one)
end

teardown do
ENV["SWACHALIT_DISABLE_BACKGROUND_TASKS"] = nil
end

test "User visits home page" do
get root_path
assert_response :ok
end

test "User visits upcoming event page" do
get upcoming_path
assert_response :ok
end

test "User visits archives page" do
get archives_path
assert_response :ok
end

test "User visits about page" do
get about_path
assert_response :ok
end

test "User visits calendar page" do
get calendar_path
assert_response :ok
end

test "User visits privacy page" do
get privacy_path
assert_response :ok
end

test "User visits public profile page of existing user" do
get public_profile_path(1)
assert_response :ok
end

test "User visits public profile page of non-existent user" do
assert_raise (ActiveRecord::RecordNotFound) { get public_profile_path(9999) }
end

test "User visits raise excepton page" do
assert_raise { get raise_exception_test_path }
end

test "User visits sessions page" do
get event_sessions_path
assert_response :ok
end

test "User visits forum page" do
get forum_path
assert_response :ok
end

end
43 changes: 43 additions & 0 deletions test/integration/users_password_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
require 'test_helper'

class UsersPasswordTest < ActionDispatch::IntegrationTest
include Devise::Test::IntegrationHelpers

setup do
ENV["SWACHALIT_DISABLE_BACKGROUND_TASKS"] = "1"
end

teardown do
ENV["SWACHALIT_DISABLE_BACKGROUND_TASKS"] = nil
end

test "Unauthenticated user can access passsword recovery page" do
get new_user_password_path
assert_response :ok
end

test "Unauthenticated user can not access edit passsword page" do
get edit_user_password_path
assert_redirected_to new_user_session_path
end

test "Authenticated users should change password from profile page only" do
sign_in users(:one)
get new_user_password_path
assert_redirected_to root_path
end

test "Authenticated users should edit password from profile page only" do
sign_in users(:one)
get edit_user_password_path
assert_redirected_to root_path
end

#TODO: Do we need to test updates on /users/password?
# test "Authenticated users can edit password" do
# sign_in users(:one)
# user = users(:one)
# put user_password_path, user:user
# assert_response :ok
# end
end
44 changes: 0 additions & 44 deletions test/integration/users_test.rb

This file was deleted.

0 comments on commit 3f752de

Please sign in to comment.