summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorRobert Speicher <rspeicher@gmail.com>2015-06-12 20:39:48 -0400
committerRobert Speicher <rspeicher@gmail.com>2015-06-16 12:52:40 -0400
commit7cff7d6fce29511230314123a9de1d78b048fa29 (patch)
tree67d2053b8e9fedf1f0053f40b5d5e11c44bd744c /spec
parent17af09b19075e74688ae9b78ccd773230e5b46fc (diff)
downloadgitlab-ce-7cff7d6fce29511230314123a9de1d78b048fa29.tar.gz
Refactor dashboard_choices
cherry-picked
Diffstat (limited to 'spec')
-rw-r--r--spec/helpers/preferences_helper_spec.rb18
1 files changed, 10 insertions, 8 deletions
diff --git a/spec/helpers/preferences_helper_spec.rb b/spec/helpers/preferences_helper_spec.rb
index 46d104a8e80..0fba3ba5631 100644
--- a/spec/helpers/preferences_helper_spec.rb
+++ b/spec/helpers/preferences_helper_spec.rb
@@ -3,18 +3,20 @@ require 'spec_helper'
describe PreferencesHelper do
describe 'dashboard_choices' do
it 'raises an exception when defined choices may be missing' do
- dashboards = User.dashboards
- expect(User).to receive(:dashboards).
- and_return(dashboards.merge(foo: 'foo'))
+ expect(User).to receive(:dashboards).and_return(foo: 'foo')
+ expect { dashboard_choices }.to raise_error(RuntimeError)
+ end
- expect { dashboard_choices }.to raise_error
+ it 'raises an exception when defined choices may be using the wrong key' do
+ expect(User).to receive(:dashboards).and_return(foo: 'foo', bar: 'bar')
+ expect { dashboard_choices }.to raise_error(KeyError)
end
it 'provides better option descriptions' do
- choices = dashboard_choices
-
- expect(choices[0]).to eq ['Your Projects (default)', 'projects']
- expect(choices[1]).to eq ['Starred Projects', 'stars']
+ expect(dashboard_choices).to match_array [
+ ['Your Projects (default)', 'projects'],
+ ['Starred Projects', 'stars']
+ ]
end
end
end