remove readonly column specs for now
This commit is contained in:
parent
7caf82f03c
commit
b9757bd02e
|
@ -49,77 +49,77 @@ RSpec.describe ColumnDropper do
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
describe '.mark_readonly' do
|
# describe '.mark_readonly' do
|
||||||
let(:table_name) { "table_with_readonly_column" }
|
# let(:table_name) { "table_with_readonly_column" }
|
||||||
|
#
|
||||||
before do
|
# before do
|
||||||
ActiveRecord::Base.exec_sql <<~SQL
|
# ActiveRecord::Base.exec_sql <<~SQL
|
||||||
CREATE TABLE #{table_name} (topic_id INTEGER, email TEXT);
|
# CREATE TABLE #{table_name} (topic_id INTEGER, email TEXT);
|
||||||
|
#
|
||||||
INSERT INTO #{table_name} (topic_id, email)
|
# INSERT INTO #{table_name} (topic_id, email)
|
||||||
VALUES (1, 'something@email.com');
|
# VALUES (1, 'something@email.com');
|
||||||
SQL
|
# SQL
|
||||||
|
#
|
||||||
described_class.mark_readonly(table_name, 'email')
|
# described_class.mark_readonly(table_name, 'email')
|
||||||
end
|
# end
|
||||||
|
#
|
||||||
after do
|
# after do
|
||||||
ActiveRecord::Base.exec_sql <<~SQL
|
# ActiveRecord::Base.exec_sql <<~SQL
|
||||||
DROP TABLE IF EXISTS #{table_name};
|
# DROP TABLE IF EXISTS #{table_name};
|
||||||
DROP TRIGGER IF EXISTS #{table_name}_email_readonly ON #{table_name};
|
# DROP TRIGGER IF EXISTS #{table_name}_email_readonly ON #{table_name};
|
||||||
SQL
|
# SQL
|
||||||
end
|
# end
|
||||||
|
#
|
||||||
it 'should prevent updates to the readonly column' do
|
# it 'should prevent updates to the readonly column' do
|
||||||
expect do
|
# expect do
|
||||||
ActiveRecord::Base.exec_sql <<~SQL
|
# ActiveRecord::Base.exec_sql <<~SQL
|
||||||
UPDATE #{table_name}
|
# UPDATE #{table_name}
|
||||||
SET email = 'testing@email.com'
|
# SET email = 'testing@email.com'
|
||||||
WHERE topic_id = 1;
|
# WHERE topic_id = 1;
|
||||||
SQL
|
# SQL
|
||||||
end.to raise_error(
|
# end.to raise_error(
|
||||||
PG::RaiseException,
|
# PG::RaiseException,
|
||||||
/Discourse: email in #{table_name} is readonly/
|
# /Discourse: email in #{table_name} is readonly/
|
||||||
)
|
# )
|
||||||
|
#
|
||||||
ActiveRecord::Base.exec_sql("ROLLBACK")
|
# ActiveRecord::Base.exec_sql("ROLLBACK")
|
||||||
end
|
# end
|
||||||
|
#
|
||||||
it 'should allow updates to the other columns' do
|
# it 'should allow updates to the other columns' do
|
||||||
ActiveRecord::Base.exec_sql <<~SQL
|
# ActiveRecord::Base.exec_sql <<~SQL
|
||||||
UPDATE #{table_name}
|
# UPDATE #{table_name}
|
||||||
SET topic_id = 2
|
# SET topic_id = 2
|
||||||
WHERE topic_id = 1
|
# WHERE topic_id = 1
|
||||||
SQL
|
# SQL
|
||||||
|
#
|
||||||
expect(
|
# expect(
|
||||||
ActiveRecord::Base.exec_sql("SELECT * FROM #{table_name};").values
|
# ActiveRecord::Base.exec_sql("SELECT * FROM #{table_name};").values
|
||||||
).to include(["2", "something@email.com"])
|
# ).to include(["2", "something@email.com"])
|
||||||
end
|
# end
|
||||||
|
#
|
||||||
it 'should prevent insertions to the readonly column' do
|
# it 'should prevent insertions to the readonly column' do
|
||||||
expect do
|
# expect do
|
||||||
ActiveRecord::Base.exec_sql <<~SQL
|
# ActiveRecord::Base.exec_sql <<~SQL
|
||||||
INSERT INTO #{table_name} (topic_id, email)
|
# INSERT INTO #{table_name} (topic_id, email)
|
||||||
VALUES (2, 'something@email.com');
|
# VALUES (2, 'something@email.com');
|
||||||
SQL
|
# SQL
|
||||||
end.to raise_error(
|
# end.to raise_error(
|
||||||
PG::RaiseException,
|
# PG::RaiseException,
|
||||||
/Discourse: email in table_with_readonly_column is readonly/
|
# /Discourse: email in table_with_readonly_column is readonly/
|
||||||
)
|
# )
|
||||||
|
#
|
||||||
ActiveRecord::Base.exec_sql("ROLLBACK")
|
# ActiveRecord::Base.exec_sql("ROLLBACK")
|
||||||
end
|
# end
|
||||||
|
#
|
||||||
it 'should allow insertions to the other columns' do
|
# it 'should allow insertions to the other columns' do
|
||||||
ActiveRecord::Base.exec_sql <<~SQL
|
# ActiveRecord::Base.exec_sql <<~SQL
|
||||||
INSERT INTO #{table_name} (topic_id)
|
# INSERT INTO #{table_name} (topic_id)
|
||||||
VALUES (2);
|
# VALUES (2);
|
||||||
SQL
|
# SQL
|
||||||
|
#
|
||||||
expect(
|
# expect(
|
||||||
ActiveRecord::Base.exec_sql("SELECT * FROM #{table_name} WHERE topic_id = 2;").values
|
# ActiveRecord::Base.exec_sql("SELECT * FROM #{table_name} WHERE topic_id = 2;").values
|
||||||
).to include(["2", nil])
|
# ).to include(["2", nil])
|
||||||
end
|
# end
|
||||||
end
|
# end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue