Skip to content

Commit

Permalink
Remove unused db column
Browse files Browse the repository at this point in the history
  • Loading branch information
Artur Beljajev committed Aug 11, 2019
1 parent d34e643 commit 5a68035
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 31 deletions.
1 change: 0 additions & 1 deletion app/models/invoice.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion app/views/registrar/invoices/index.haml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 5 additions & 0 deletions db/migrate/20190811184334_remove_invoices_seller_id.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class RemoveInvoicesSellerId < ActiveRecord::Migration
def change
remove_column :invoices, :seller_id
end
end
10 changes: 2 additions & 8 deletions db/structure.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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:
--
Expand Down Expand Up @@ -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');

33 changes: 12 additions & 21 deletions test/system/registrar_area/invoices/list_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,42 +3,33 @@
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
visit registrar_invoices_path
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

0 comments on commit 5a68035

Please sign in to comment.