9 changed files with 56 additions and 18 deletions
@ -0,0 +1,5 @@
|
||||
class CreateLogsView < ActiveRecord::Migration[7.0] |
||||
def change |
||||
create_view :logs |
||||
end |
||||
end |
@ -0,0 +1,15 @@
|
||||
SELECT |
||||
id, |
||||
status, |
||||
created_at, |
||||
'lettings' as log_type |
||||
FROM lettings_logs |
||||
|
||||
UNION |
||||
|
||||
SELECT |
||||
id, |
||||
status, |
||||
created_at, |
||||
'sales' as log_type |
||||
FROM sales_logs |
@ -1,20 +1,19 @@
|
||||
require "rails_helper" |
||||
|
||||
RSpec.describe LettingsLogsController, type: :request do |
||||
describe "index" do |
||||
let(:user) { FactoryBot.create(:user) } |
||||
let(:page) { Capybara::Node::Simple.new(response.body) } |
||||
|
||||
describe "index" do |
||||
let(:user) { FactoryBot.create(:user) } |
||||
let(:page) { Capybara::Node::Simple.new(response.body) } |
||||
|
||||
before do |
||||
sign_in user |
||||
FactoryBot.create_list(:lettings_log, 3, :completed, owning_organisation: user.organisation, created_by: user) |
||||
FactoryBot.create_list(:sales_log, 3, owning_organisation: user.organisation, created_by: user) |
||||
end |
||||
before do |
||||
sign_in user |
||||
FactoryBot.create_list(:lettings_log, 3, :completed, owning_organisation: user.organisation, created_by: user) |
||||
FactoryBot.create_list(:sales_log, 3, owning_organisation: user.organisation, created_by: user) |
||||
end |
||||
|
||||
it "shows both lettings and sales logs" do |
||||
get "/logs" |
||||
expect(page).to have_content("6 total logs") |
||||
end |
||||
it "shows both lettings and sales logs" do |
||||
get "/logs" |
||||
expect(page).to have_content("6 total logs") |
||||
end |
||||
end |
||||
end |
||||
end |
||||
|
Loading…
Reference in new issue