aboutsummaryrefslogtreecommitdiffstats
path: root/spec
diff options
context:
space:
mode:
Diffstat (limited to 'spec')
-rw-r--r--spec/controllers/comment_controller_spec.rb11
-rw-r--r--spec/controllers/request_controller_spec.rb16
-rw-r--r--spec/fixtures/info_requests.yml11
-rw-r--r--spec/fixtures/public_body_translations.yml3
-rw-r--r--spec/views/request/_after_actions.rhtml_spec.rb71
5 files changed, 76 insertions, 36 deletions
diff --git a/spec/controllers/comment_controller_spec.rb b/spec/controllers/comment_controller_spec.rb
index b71bc0aea..4a7acee23 100644
--- a/spec/controllers/comment_controller_spec.rb
+++ b/spec/controllers/comment_controller_spec.rb
@@ -53,6 +53,17 @@ describe CommentController, "when commenting on a request" do
response.should render_template('new')
end
+
+ it "should not allow comments if comments are not allowed" do
+ session[:user_id] = users(:silly_name_user).id
+
+ expect {
+ post :new, :url_title => info_requests(:spam_1_request).url_title,
+ :comment => { :body => "I demand to be heard!" },
+ :type => 'request', :submitted_comment => 1, :preview => 0
+ }.to raise_error("Comments are not allowed on this request")
+
+ end
describe 'when commenting on an external request' do
diff --git a/spec/controllers/request_controller_spec.rb b/spec/controllers/request_controller_spec.rb
index 95737a250..77f43b618 100644
--- a/spec/controllers/request_controller_spec.rb
+++ b/spec/controllers/request_controller_spec.rb
@@ -238,6 +238,22 @@ describe RequestController, "when showing one request" do
response.should have_tag('div#owner_actions')
end
+ describe 'when the request does allow comments' do
+ it 'should have a comment link' do
+ get :show, { :url_title => 'why_do_you_have_such_a_fancy_dog' },
+ { :user_id => users(:admin_user).id }
+ response.should have_tag('#anyone_actions', /Add an annotation/)
+ end
+ end
+
+ describe 'when the request does not allow comments' do
+ it 'should not have a comment link' do
+ get :show, { :url_title => 'spam_1' },
+ { :user_id => users(:admin_user).id }
+ response.should_not have_tag('#anyone_actions', /Add an annotation/)
+ end
+ end
+
describe 'when the request is being viewed by an admin' do
describe 'if the request is awaiting description' do
diff --git a/spec/fixtures/info_requests.yml b/spec/fixtures/info_requests.yml
index 079a44cd0..9361ec486 100644
--- a/spec/fixtures/info_requests.yml
+++ b/spec/fixtures/info_requests.yml
@@ -8,6 +8,7 @@ fancy_dog_request:
user_id: 1
described_state: waiting_response
awaiting_description: true
+ comments_allowed: true
idhash: 50929748
naughty_chicken_request:
id: 103
@@ -19,6 +20,7 @@ naughty_chicken_request:
user_id: 1
described_state: waiting_response
awaiting_description: false
+ comments_allowed: true
idhash: e8d18c84
badger_request:
id: 104
@@ -30,6 +32,7 @@ badger_request:
user_id: 1
described_state: waiting_response
awaiting_description: false
+ comments_allowed: true
idhash: e8d18c84
boring_request:
id: 105
@@ -41,6 +44,7 @@ boring_request:
user_id: 1
described_state: successful
awaiting_description: false
+ comments_allowed: true
idhash: 173fd003
another_boring_request:
id: 106
@@ -52,6 +56,7 @@ another_boring_request:
user_id: 1
described_state: successful
awaiting_description: false
+ comments_allowed: true
idhash: 173fd004
# A pair of identical requests (with url_title differing only in the numeric suffix)
@@ -66,6 +71,7 @@ spam_1_request:
user_id: 5
described_state: successful
awaiting_description: false
+ comments_allowed: false
idhash: 173fd005
spam_2_request:
id: 108
@@ -77,6 +83,7 @@ spam_2_request:
user_id: 5
described_state: successful
awaiting_description: false
+ comments_allowed: true
idhash: 173fd005
external_request:
id: 109
@@ -87,6 +94,7 @@ external_request:
public_body_id: 2
described_state: waiting_response
awaiting_description: false
+ comments_allowed: true
idhash: a1234567
anonymous_external_request:
id: 110
@@ -97,4 +105,5 @@ anonymous_external_request:
public_body_id: 2
described_state: waiting_response
awaiting_description: false
- idhash: 7654321a \ No newline at end of file
+ comments_allowed: true
+ idhash: 7654321a
diff --git a/spec/fixtures/public_body_translations.yml b/spec/fixtures/public_body_translations.yml
index d705358c5..f3453e853 100644
--- a/spec/fixtures/public_body_translations.yml
+++ b/spec/fixtures/public_body_translations.yml
@@ -56,6 +56,7 @@ forlorn_en_public_body_translation:
url_name: lonely
locale: en
notes: A very lonely public body that no one has corresponded with
+ publication_scheme: ""
silly_walks_en_public_body_translation:
id: 6
@@ -67,6 +68,7 @@ silly_walks_en_public_body_translation:
short_name: MSW
url_name: msw
notes: You know the one.
+ publication_scheme: ""
sensible_walks_en_public_body_translation:
id: 7
@@ -78,3 +80,4 @@ sensible_walks_en_public_body_translation:
short_name: SenseWalk
url_name: sensible_walks
notes: I bet you’ve never heard of it.
+ publication_scheme: ""
diff --git a/spec/views/request/_after_actions.rhtml_spec.rb b/spec/views/request/_after_actions.rhtml_spec.rb
index d04db3fc2..5b4734c52 100644
--- a/spec/views/request/_after_actions.rhtml_spec.rb
+++ b/spec/views/request/_after_actions.rhtml_spec.rb
@@ -1,85 +1,86 @@
require File.expand_path(File.join('..', '..', '..', 'spec_helper'), __FILE__)
-describe 'when displaying actions that can be taken with regard to a request' do
-
- before do
- @mock_body = mock_model(PublicBody, :name => 'test public body',
+describe 'when displaying actions that can be taken with regard to a request' do
+
+ before do
+ @mock_body = mock_model(PublicBody, :name => 'test public body',
:url_name => 'test_public_body')
- @mock_user = mock_model(User, :name => 'test user',
+ @mock_user = mock_model(User, :name => 'test user',
:url_name => 'test_user')
- @mock_request = mock_model(InfoRequest, :title => 'test request',
- :user => @mock_user,
- :user_name => @mock_user.name,
+ @mock_request = mock_model(InfoRequest, :title => 'test request',
+ :user => @mock_user,
+ :user_name => @mock_user.name,
:is_external? => false,
- :public_body => @mock_body,
+ :public_body => @mock_body,
+ :comments_allowed? => true,
:url_title => 'test_request')
assigns[:info_request] = @mock_request
end
-
+
def do_render
render :partial => 'request/after_actions'
end
-
+
def expect_owner_div
do_render
response.should have_tag('div#owner_actions'){ yield }
end
-
+
def expect_anyone_div
do_render
response.should have_tag('div#anyone_actions'){ yield }
end
-
+
def expect_owner_link(text)
expect_owner_div{ with_tag('a', :text => text) }
end
-
+
def expect_no_owner_link(text)
expect_owner_div{ without_tag('a', :text => text) }
end
-
+
def expect_anyone_link(text)
expect_anyone_div{ with_tag('a', :text => text) }
end
-
+
def expect_no_anyone_link(text)
expect_anyone_div{ without_tag('a', :text => text) }
end
-
- describe 'if the request is old and unclassified' do
-
- before do
+
+ describe 'if the request is old and unclassified' do
+
+ before do
assigns[:old_unclassified] = true
end
-
- it 'should not display a link for the request owner to update the status of the request' do
+
+ it 'should not display a link for the request owner to update the status of the request' do
expect_no_owner_link('Update the status of this request')
end
-
- it 'should display a link for anyone to update the status of the request' do
+
+ it 'should display a link for anyone to update the status of the request' do
expect_anyone_link('Update the status of this request')
end
-
+
end
-
- describe 'if the request is not old and unclassified' do
-
- before do
+
+ describe 'if the request is not old and unclassified' do
+
+ before do
assigns[:old_unclassified] = false
end
-
- it 'should display a link for the request owner to update the status of the request' do
+
+ it 'should display a link for the request owner to update the status of the request' do
expect_owner_link('Update the status of this request')
end
-
- it 'should not display a link for anyone to update the status of the request' do
+
+ it 'should not display a link for anyone to update the status of the request' do
expect_no_anyone_link('Update the status of this request')
end
-
+
end
it 'should display a link for the request owner to request a review' do
expect_owner_link('Request an internal review')
end
-
+
end