about summary refs log tree commit diff
path: root/spec/views/about
diff options
context:
space:
mode:
authorMatt Jankowski <mjankowski@thoughtbot.com>2017-04-28 11:54:03 -0400
committerEugen Rochko <eugen@zeonfederated.com>2017-04-28 17:54:03 +0200
commita823509b99eb428b1f68ed89594b88f48546253a (patch)
treeb3321b07b6824621d4449cdc97f10763bcab0f78 /spec/views/about
parent298d28af517dcbc4220133985de6a8350d33b40b (diff)
Fix broken view spec for about/links (#2591)
Diffstat (limited to 'spec/views/about')
-rw-r--r--spec/views/about/_links.html.haml_spec.rb49
1 files changed, 26 insertions, 23 deletions
diff --git a/spec/views/about/_links.html.haml_spec.rb b/spec/views/about/_links.html.haml_spec.rb
index a5d2c8924..2d7f7467a 100644
--- a/spec/views/about/_links.html.haml_spec.rb
+++ b/spec/views/about/_links.html.haml_spec.rb
@@ -3,33 +3,36 @@
 require 'rails_helper'
 
 describe 'about/_links.html.haml' do
-  it 'does not show sign in link when signed in' do
-    instance_presenter = double(:instance_presenter, open_registrations: true)
-    assign(:instance_presenter, instance_presenter)
-    allow(view).to receive(:user_signed_in?).and_return(true)
-    render 'about/links', instance: InstancePresenter.new
-
-    expect(rendered).to have_content(I18n.t('about.get_started'))
-    expect(rendered).not_to have_content(I18n.t('auth.login'))
-  end
+  context 'when signed in' do
+    before do
+      allow(view).to receive(:user_signed_in?).and_return(true)
+    end
 
-  it 'shows sign in link when signed out' do
-    instance_presenter = double(:instance_presenter, open_registrations: true)
-    assign(:instance_presenter, instance_presenter)
-    allow(view).to receive(:user_signed_in?).and_return(false)
-    render 'about/links', instance: InstancePresenter.new
+    it 'does not show sign in link' do
+      render 'about/links', instance: InstancePresenter.new
 
-    expect(rendered).to have_content(I18n.t('about.get_started'))
-    expect(rendered).to have_content(I18n.t('auth.login'))
+      expect(rendered).to have_content(I18n.t('about.get_started'))
+      expect(rendered).not_to have_content(I18n.t('auth.login'))
+    end
   end
 
-  it 'shows sign in link when register closed' do
-    instance_presenter = double(:instance_presenter, open_registrations: false)
-    assign(:instance_presenter, instance_presenter)
-    allow(view).to receive(:user_signed_in?).and_return(false)
-    render
+  context 'when signed out' do
+    before do
+      allow(view).to receive(:user_signed_in?).and_return(false)
+    end
+
+    it 'shows get started link when registrations are allowed' do
+      render 'about/links', instance: double(open_registrations: true)
+
+      expect(rendered).to have_content(I18n.t('about.get_started'))
+      expect(rendered).to have_content(I18n.t('auth.login'))
+    end
+
+    it 'hides get started link when registrations are closed' do
+      render 'about/links', instance: double(open_registrations: false)
 
-    expect(rendered).not_to have_content(I18n.t('about.get_started'))
-    expect(rendered).to have_content(I18n.t('auth.login'))
+      expect(rendered).not_to have_content(I18n.t('about.get_started'))
+      expect(rendered).to have_content(I18n.t('auth.login'))
+    end
   end
 end