Remove unused db column

This commit is contained in:
Artur Beljajev 2019-08-11 22:02:19 +03:00
parent d34e6430a2
commit 5a68035818
5 changed files with 20 additions and 31 deletions

View file

@ -3,7 +3,6 @@ class Invoice < ActiveRecord::Base
include Concerns::Invoice::Cancellable
include Concerns::Invoice::Payable
belongs_to :seller, class_name: 'Registrar'
belongs_to :buyer, class_name: 'Registrar'
has_one :account_activity
has_many :items, class_name: 'InvoiceItem', dependent: :destroy

View file

@ -57,7 +57,7 @@
%th{class: 'col-xs-3'}= t(:total)
%tbody
- @invoices.each do |invoice|
%tr.invoice
%tr
%td= link_to(invoice, [:registrar, invoice])
- if invoice.paid?
%td= l invoice.receipt_date

View file

@ -0,0 +1,5 @@
class RemoveInvoicesSellerId < ActiveRecord::Migration
def change
remove_column :invoices, :seller_id
end
end

View file

@ -935,7 +935,6 @@ CREATE TABLE public.invoices (
description character varying,
reference_no character varying NOT NULL,
vat_rate numeric(4,3) NOT NULL,
seller_id integer,
seller_name character varying NOT NULL,
seller_reg_no character varying,
seller_iban character varying NOT NULL,
@ -3453,13 +3452,6 @@ CREATE INDEX index_invoice_items_on_invoice_id ON public.invoice_items USING btr
CREATE INDEX index_invoices_on_buyer_id ON public.invoices USING btree (buyer_id);
--
-- Name: index_invoices_on_seller_id; Type: INDEX; Schema: public; Owner: -; Tablespace:
--
CREATE INDEX index_invoices_on_seller_id ON public.invoices USING btree (seller_id);
--
-- Name: index_keyrelays_on_accepter_id; Type: INDEX; Schema: public; Owner: -; Tablespace:
--
@ -4817,3 +4809,5 @@ INSERT INTO schema_migrations (version) VALUES ('20190617122505');
INSERT INTO schema_migrations (version) VALUES ('20190620084334');
INSERT INTO schema_migrations (version) VALUES ('20190811184334');

View file

@ -3,10 +3,9 @@ require 'test_helper'
class ListInvoicesTest < ApplicationSystemTestCase
setup do
@user = users(:api_bestnames)
sign_in @user
@invoice = invoices(:one)
eliminate_effect_of_other_invoices
sign_in @user
end
def test_show_balance
@ -14,31 +13,23 @@ class ListInvoicesTest < ApplicationSystemTestCase
assert_text "Your current account balance is 100,00 EUR"
end
def test_show_invoices_of_current_registrar
registrar = registrars(:bestnames)
@user.update!(registrar: registrar)
@invoice.update!(seller: registrar)
def test_shows_invoice_owned_by_current_user
owning_registrar = registrars(:bestnames)
assert_equal owning_registrar, @user.registrar
@invoice.update!(buyer: owning_registrar)
visit registrar_invoices_url
assert_css '.invoice'
assert_text @invoice.to_s
end
def test_do_not_show_invoices_of_other_registrars
registrar = registrars(:goodnames)
@user.update!(registrar: registrar)
@invoice.update!(seller: registrar)
def test_hides_invoice_owned_by_other_user
other_registrar = registrars(:goodnames)
assert_not_equal other_registrar, @user.registrar
@invoice.update!(buyer: other_registrar)
visit registrar_invoices_url
assert_no_css '.invoice'
end
private
def eliminate_effect_of_other_invoices
Invoice.connection.disable_referential_integrity do
Invoice.delete_all("id != #{@invoice.id}")
end
assert_no_text @invoice.to_s
end
end