Browse Source
* Spec case logs admin table * Spec admin user admin index * Dashboard controller panel specs * Spec panel contents * Add create specs * Don't assign non db ids if we don't need them * Fix specs for new section * Fix up fieldspull/111/head
Daniel Baark
3 years ago
committed by
GitHub
14 changed files with 158 additions and 18 deletions
@ -0,0 +1,9 @@
|
||||
class RemoveOldFields < ActiveRecord::Migration[6.1] |
||||
def up |
||||
remove_column :case_logs, :property_building_type |
||||
end |
||||
|
||||
def down |
||||
add_column :case_logs, :property_building_type, :string |
||||
end |
||||
end |
@ -0,0 +1,30 @@
|
||||
require "rails_helper" |
||||
require_relative "../../support/devise" |
||||
|
||||
describe Admin::AdminUsersController, type: :controller do |
||||
render_views |
||||
let(:page) { Capybara::Node::Simple.new(response.body) } |
||||
let(:resource_title) { "Admin Users" } |
||||
let(:valid_session) { {} } |
||||
login_admin_user |
||||
|
||||
describe "Get admin users" do |
||||
before do |
||||
get :index, session: valid_session |
||||
end |
||||
|
||||
it "returns a table of admin users" do |
||||
expect(page).to have_content(resource_title) |
||||
expect(page).to have_table("index_table_admin_users") |
||||
expect(page).to have_link(AdminUser.first.id.to_s) |
||||
end |
||||
end |
||||
|
||||
describe "Create admin users" do |
||||
let(:params) { { admin_user: { email: "test2@example.com", password: "pAssword1" } } } |
||||
|
||||
it "creates a new admin users" do |
||||
expect { post :create, session: valid_session, params: params }.to change(AdminUser, :count).by(1) |
||||
end |
||||
end |
||||
end |
@ -0,0 +1,29 @@
|
||||
require "rails_helper" |
||||
require_relative "../../support/devise" |
||||
|
||||
describe Admin::CaseLogsController, type: :controller do |
||||
render_views |
||||
let(:page) { Capybara::Node::Simple.new(response.body) } |
||||
let(:resource_title) { "Case Logs" } |
||||
let(:valid_session) { {} } |
||||
login_admin_user |
||||
|
||||
describe "Get case logs" do |
||||
let!(:case_log) { FactoryBot.create(:case_log, :in_progress) } |
||||
before do |
||||
get :index, session: valid_session |
||||
end |
||||
|
||||
it "returns a table of case logs" do |
||||
expect(page).to have_content(resource_title) |
||||
expect(page).to have_table("index_table_case_logs") |
||||
expect(page).to have_link(case_log.id.to_s) |
||||
end |
||||
end |
||||
|
||||
describe "Create case logs" do |
||||
it "creates a new case log" do |
||||
expect { post :create, session: valid_session }.to change(CaseLog, :count).by(1) |
||||
end |
||||
end |
||||
end |
@ -0,0 +1,41 @@
|
||||
require "rails_helper" |
||||
require_relative "../../support/devise" |
||||
|
||||
describe Admin::DashboardController, type: :controller do |
||||
render_views |
||||
let(:page) { Capybara::Node::Simple.new(response.body) } |
||||
let(:resource_title) { "Dashboard" } |
||||
let!(:case_log) { FactoryBot.create(:case_log, :in_progress) } |
||||
let!(:case_log_2) { FactoryBot.create(:case_log, :in_progress) } |
||||
let!(:completed_case_log) { FactoryBot.create(:case_log, :completed) } |
||||
let(:valid_session) { {} } |
||||
login_admin_user |
||||
|
||||
describe "Get case logs" do |
||||
before do |
||||
get :index, session: valid_session |
||||
end |
||||
|
||||
it "returns a dashboard page" do |
||||
expect(page).to have_content(resource_title) |
||||
end |
||||
|
||||
it "returns a panel of recent case logs" do |
||||
expect(page).to have_xpath("//div[contains(@class, 'panel') and contains(//h3, 'Recent Case Logs')]") |
||||
end |
||||
|
||||
it "returns a panel of in progress case logs" do |
||||
panel_xpath = "//div[@class='panel' and .//h3[contains(., 'Total case logs in progress')]]" |
||||
panel_content_xpath = "#{panel_xpath}//div[@class='panel_contents' and .//p[contains(., 2)]]" |
||||
expect(page).to have_xpath(panel_xpath) |
||||
expect(page).to have_xpath(panel_content_xpath) |
||||
end |
||||
|
||||
it "returns a panel of completed case logs" do |
||||
panel_xpath = "//div[@class='panel' and .//h3[contains(., 'Total case logs completed')]]" |
||||
panel_content_xpath = "#{panel_xpath}//div[@class='panel_contents' and .//p[contains(., 1)]]" |
||||
expect(page).to have_xpath(panel_xpath) |
||||
expect(page).to have_xpath(panel_content_xpath) |
||||
end |
||||
end |
||||
end |
@ -0,0 +1,8 @@
|
||||
FactoryBot.define do |
||||
factory :admin_user do |
||||
email { "admin@example.com" } |
||||
password { "pAssword1" } |
||||
created_at { Time.zone.now } |
||||
updated_at { Time.zone.now } |
||||
end |
||||
end |
Loading…
Reference in new issue