diff options
author | Lin Jen-Shin <godfat@godfat.org> | 2018-08-31 00:25:17 +0800 |
---|---|---|
committer | Lin Jen-Shin <godfat@godfat.org> | 2018-09-11 18:45:49 +0800 |
commit | 07da8f9128f507bb20d5694c1c0b5ca73e58d203 (patch) | |
tree | 02d55edafb3c40b056b1857804008dffba8b8672 /spec | |
parent | d7f87a2bc9b9638285eb85b50957879c8599a6b9 (diff) | |
download | gitlab-ce-07da8f9128f507bb20d5694c1c0b5ca73e58d203.tar.gz |
Preserve prepend semantics for Ruby
However we still want to make ClassMethods work!
And we'll need to fix codes using the wrong include/prepend
along the way. There were a lot of misuses.
Diffstat (limited to 'spec')
-rw-r--r-- | spec/lib/gitlab/patch/prependable_spec.rb | 29 |
1 files changed, 24 insertions, 5 deletions
diff --git a/spec/lib/gitlab/patch/prependable_spec.rb b/spec/lib/gitlab/patch/prependable_spec.rb index b902f174c6d..d33c14e8b15 100644 --- a/spec/lib/gitlab/patch/prependable_spec.rb +++ b/spec/lib/gitlab/patch/prependable_spec.rb @@ -71,22 +71,41 @@ describe Gitlab::Patch::Prependable do subject - expect(prepended_modules).to eq([[subject, ee], [subject, ce]]) + expect(prepended_modules).to eq([[ce, ee]]) + end + + context 'overriding a method' do + before do + subject.module_eval do + def self.class_name + 'Custom' + end + + def name + 'custom' + end + end + end + + it 'returns values from the class' do + expect(subject.new.name).to eq('custom') + expect(subject.class_name).to eq('Custom') + end end end describe 'a class prepending a concern prepending a concern' do subject { Class.new.prepend(ce) } - it 'returns values from prepended module ce' do - expect(subject.new.name).to eq('ce') - expect(subject.class_name).to eq('CE') + it 'returns values from prepended module ee' do + expect(subject.new.name).to eq('ee') + expect(subject.class_name).to eq('EE') end it 'prepends only once' do subject.prepend(ce) - expect(prepended_modules).to eq([[subject, ee], [subject, ce]]) + expect(prepended_modules).to eq([[ce, ee], [subject, ce]]) end end |