mirror of
https://github.com/meineerde/rackstash.git
synced 2026-02-01 01:37:12 +00:00
Preserve the frozen state when cloning Flows objects
This commit is contained in:
parent
cdc237897f
commit
a3d66deb7a
@ -229,6 +229,7 @@ module Rackstash
|
||||
|
||||
def initialize_copy(other)
|
||||
@flows = other.flows.dup
|
||||
@flows.freeze if other.frozen?
|
||||
super
|
||||
end
|
||||
|
||||
|
||||
@ -155,6 +155,25 @@ RSpec.describe Rackstash::Flows do
|
||||
end
|
||||
end
|
||||
|
||||
describe '#clone' do
|
||||
it 'clones the flows' do
|
||||
flows << a_flow
|
||||
copied = flows.clone
|
||||
|
||||
expect(copied).to be_instance_of described_class
|
||||
expect(copied.length).to eql 1
|
||||
expect(copied).to_not equal flows
|
||||
end
|
||||
|
||||
it 'preserves the frozen? status' do
|
||||
flows.freeze
|
||||
expect(flows).to be_frozen
|
||||
|
||||
expect(flows.clone).to be_frozen
|
||||
expect { flows.clone << a_flow }.to raise_error(RuntimeError)
|
||||
end
|
||||
end
|
||||
|
||||
describe '#freeze' do
|
||||
it 'freezes the object' do
|
||||
expect(flows.freeze).to equal flows
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user