Commit 7da88278 authored by Lin Jen-Shin's avatar Lin Jen-Shin

Make sure protected can't be null; Test protected!

parent 0ab8c852
...@@ -356,7 +356,7 @@ ActiveRecord::Schema.define(version: 20170525174156) do ...@@ -356,7 +356,7 @@ ActiveRecord::Schema.define(version: 20170525174156) do
t.string "encrypted_value_salt" t.string "encrypted_value_salt"
t.string "encrypted_value_iv" t.string "encrypted_value_iv"
t.integer "project_id", null: false t.integer "project_id", null: false
t.boolean "protected", default: false t.boolean "protected", default: false, null: false
end end
add_index "ci_variables", ["project_id"], name: "index_ci_variables_on_project_id", using: :btree add_index "ci_variables", ["project_id"], name: "index_ci_variables_on_project_id", using: :btree
...@@ -1493,4 +1493,4 @@ ActiveRecord::Schema.define(version: 20170525174156) do ...@@ -1493,4 +1493,4 @@ ActiveRecord::Schema.define(version: 20170525174156) do
add_foreign_key "trending_projects", "projects", on_delete: :cascade add_foreign_key "trending_projects", "projects", on_delete: :cascade
add_foreign_key "u2f_registrations", "users" add_foreign_key "u2f_registrations", "users"
add_foreign_key "web_hook_logs", "web_hooks", on_delete: :cascade add_foreign_key "web_hook_logs", "web_hooks", on_delete: :cascade
end end
\ No newline at end of file
...@@ -12,11 +12,33 @@ describe Ci::Variable, models: true do ...@@ -12,11 +12,33 @@ describe Ci::Variable, models: true do
it { is_expected.not_to allow_value('foo bar').for(:key) } it { is_expected.not_to allow_value('foo bar').for(:key) }
it { is_expected.not_to allow_value('foo/bar').for(:key) } it { is_expected.not_to allow_value('foo/bar').for(:key) }
before :each do describe '.unprotected' do
subject.value = secret_value subject { described_class.unprotected }
context 'when variable is protected' do
before do
create(:ci_variable, :protected)
end
it 'returns nothing' do
is_expected.to be_empty
end
end
context 'when variable is not protected' do
let(:variable) { create(:ci_variable, protected: false) }
it 'returns the variable' do
is_expected.to contain_exactly(variable)
end
end
end end
describe '#value' do describe '#value' do
before do
subject.value = secret_value
end
it 'stores the encrypted value' do it 'stores the encrypted value' do
expect(subject.encrypted_value).not_to be_nil expect(subject.encrypted_value).not_to be_nil
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment