mirror of
https://github.com/internetee/registry.git
synced 2025-06-06 20:55:44 +02:00
Remove unused db column
This commit is contained in:
parent
d34e6430a2
commit
5a68035818
5 changed files with 20 additions and 31 deletions
|
@ -3,7 +3,6 @@ class Invoice < ActiveRecord::Base
|
||||||
include Concerns::Invoice::Cancellable
|
include Concerns::Invoice::Cancellable
|
||||||
include Concerns::Invoice::Payable
|
include Concerns::Invoice::Payable
|
||||||
|
|
||||||
belongs_to :seller, class_name: 'Registrar'
|
|
||||||
belongs_to :buyer, class_name: 'Registrar'
|
belongs_to :buyer, class_name: 'Registrar'
|
||||||
has_one :account_activity
|
has_one :account_activity
|
||||||
has_many :items, class_name: 'InvoiceItem', dependent: :destroy
|
has_many :items, class_name: 'InvoiceItem', dependent: :destroy
|
||||||
|
|
|
@ -57,7 +57,7 @@
|
||||||
%th{class: 'col-xs-3'}= t(:total)
|
%th{class: 'col-xs-3'}= t(:total)
|
||||||
%tbody
|
%tbody
|
||||||
- @invoices.each do |invoice|
|
- @invoices.each do |invoice|
|
||||||
%tr.invoice
|
%tr
|
||||||
%td= link_to(invoice, [:registrar, invoice])
|
%td= link_to(invoice, [:registrar, invoice])
|
||||||
- if invoice.paid?
|
- if invoice.paid?
|
||||||
%td= l invoice.receipt_date
|
%td= l invoice.receipt_date
|
||||||
|
|
5
db/migrate/20190811184334_remove_invoices_seller_id.rb
Normal file
5
db/migrate/20190811184334_remove_invoices_seller_id.rb
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
class RemoveInvoicesSellerId < ActiveRecord::Migration
|
||||||
|
def change
|
||||||
|
remove_column :invoices, :seller_id
|
||||||
|
end
|
||||||
|
end
|
|
@ -935,7 +935,6 @@ CREATE TABLE public.invoices (
|
||||||
description character varying,
|
description character varying,
|
||||||
reference_no character varying NOT NULL,
|
reference_no character varying NOT NULL,
|
||||||
vat_rate numeric(4,3) NOT NULL,
|
vat_rate numeric(4,3) NOT NULL,
|
||||||
seller_id integer,
|
|
||||||
seller_name character varying NOT NULL,
|
seller_name character varying NOT NULL,
|
||||||
seller_reg_no character varying,
|
seller_reg_no character varying,
|
||||||
seller_iban character varying NOT NULL,
|
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);
|
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:
|
-- 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 ('20190620084334');
|
||||||
|
|
||||||
|
INSERT INTO schema_migrations (version) VALUES ('20190811184334');
|
||||||
|
|
||||||
|
|
|
@ -3,10 +3,9 @@ require 'test_helper'
|
||||||
class ListInvoicesTest < ApplicationSystemTestCase
|
class ListInvoicesTest < ApplicationSystemTestCase
|
||||||
setup do
|
setup do
|
||||||
@user = users(:api_bestnames)
|
@user = users(:api_bestnames)
|
||||||
sign_in @user
|
|
||||||
|
|
||||||
@invoice = invoices(:one)
|
@invoice = invoices(:one)
|
||||||
eliminate_effect_of_other_invoices
|
|
||||||
|
sign_in @user
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_show_balance
|
def test_show_balance
|
||||||
|
@ -14,31 +13,23 @@ class ListInvoicesTest < ApplicationSystemTestCase
|
||||||
assert_text "Your current account balance is 100,00 EUR"
|
assert_text "Your current account balance is 100,00 EUR"
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_show_invoices_of_current_registrar
|
def test_shows_invoice_owned_by_current_user
|
||||||
registrar = registrars(:bestnames)
|
owning_registrar = registrars(:bestnames)
|
||||||
@user.update!(registrar: registrar)
|
assert_equal owning_registrar, @user.registrar
|
||||||
@invoice.update!(seller: registrar)
|
@invoice.update!(buyer: owning_registrar)
|
||||||
|
|
||||||
visit registrar_invoices_url
|
visit registrar_invoices_url
|
||||||
|
|
||||||
assert_css '.invoice'
|
assert_text @invoice.to_s
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_do_not_show_invoices_of_other_registrars
|
def test_hides_invoice_owned_by_other_user
|
||||||
registrar = registrars(:goodnames)
|
other_registrar = registrars(:goodnames)
|
||||||
@user.update!(registrar: registrar)
|
assert_not_equal other_registrar, @user.registrar
|
||||||
@invoice.update!(seller: registrar)
|
@invoice.update!(buyer: other_registrar)
|
||||||
|
|
||||||
visit registrar_invoices_url
|
visit registrar_invoices_url
|
||||||
|
|
||||||
assert_no_css '.invoice'
|
assert_no_text @invoice.to_s
|
||||||
end
|
|
||||||
|
|
||||||
private
|
|
||||||
|
|
||||||
def eliminate_effect_of_other_invoices
|
|
||||||
Invoice.connection.disable_referential_integrity do
|
|
||||||
Invoice.delete_all("id != #{@invoice.id}")
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
Loading…
Add table
Add a link
Reference in a new issue