diff options
author | Robert Speicher <rspeicher@gmail.com> | 2015-09-23 23:20:58 +0300 |
---|---|---|
committer | Robert Speicher <rspeicher@gmail.com> | 2015-09-23 23:20:58 +0300 |
commit | 48cfad9013f1aa4745bf2b07bfd07e34724ba037 (patch) | |
tree | 03f84d6a3ea7220e70242dd93b140fa0070a71b4 /spec/views | |
parent | 73288a8edb10e45348846dc6491db0732945a29c (diff) |
Add a view spec (gasp!) for help/index
Diffstat (limited to 'spec/views')
-rw-r--r-- | spec/views/help/index.html.haml_spec.rb | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/spec/views/help/index.html.haml_spec.rb b/spec/views/help/index.html.haml_spec.rb new file mode 100644 index 00000000000..4fd561428f6 --- /dev/null +++ b/spec/views/help/index.html.haml_spec.rb @@ -0,0 +1,55 @@ +require 'rails_helper' + +describe 'help/index' do + describe 'version information' do + it 'is hidden from guests' do + stub_user + stub_version('8.0.2', 'abcdefg') + stub_helpers + + render + + expect(rendered).not_to match '8.0.2' + expect(rendered).not_to match 'abcdefg' + end + + it 'is hidden from users' do + stub_user(admin?: false) + stub_version('8.0.2', 'abcdefg') + stub_helpers + + render + + expect(rendered).not_to match '8.0.2' + expect(rendered).not_to match 'abcdefg' + end + + it 'is shown to admins' do + stub_user(admin?: true) + stub_version('8.0.2', 'abcdefg') + stub_helpers + + render + + expect(rendered).to match '8.0.2' + expect(rendered).to match 'abcdefg' + end + end + + def stub_user(messages = {}) + user = messages.empty? ? nil : double(messages) + + allow(view).to receive(:current_user).and_return(user) + end + + def stub_version(version, revision) + stub_const('Gitlab::VERSION', version) + stub_const('Gitlab::REVISION', revision) + end + + def stub_helpers + allow(view).to receive(:markdown).and_return('') + allow(view).to receive(:current_application_settings). + and_return(double.as_null_object) + end +end |