Skip to content
This repository has been archived by the owner on Oct 12, 2018. It is now read-only.

Commit

Permalink
Merge pull request #37 from alphagov/tag-short-descriptions
Browse files Browse the repository at this point in the history
Tag short descriptions
  • Loading branch information
mnowster committed Nov 5, 2012
2 parents fa6663d + 456bead commit 238f486
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 13 deletions.
2 changes: 1 addition & 1 deletion Gemfile
Expand Up @@ -35,7 +35,7 @@ gem 'lograge'
if ENV['CONTENT_MODELS_DEV']
gem "govuk_content_models", path: '../govuk_content_models'
else
gem "govuk_content_models", "2.0.0"
gem "govuk_content_models", "2.1.0"
end

if ENV['BUNDLE_DEV']
Expand Down
6 changes: 3 additions & 3 deletions Gemfile.lock
Expand Up @@ -119,11 +119,11 @@ GEM
json
gherkin (2.11.1)
json (>= 1.4.6)
govspeak (1.2.0)
govspeak (1.2.2)
htmlentities (~> 4)
kramdown (~> 0.13.3)
sanitize (= 2.0.3)
govuk_content_models (2.0.0)
govuk_content_models (2.1.0)
bson_ext
differ
gds-api-adapters
Expand Down Expand Up @@ -322,7 +322,7 @@ DEPENDENCIES
gds-sso (= 2.0.0)
gds-warmup-controller (= 0.1.0)
gelf
govuk_content_models (= 2.0.0)
govuk_content_models (= 2.1.0)
launchy
less-rails-bootstrap
lograge
Expand Down
3 changes: 2 additions & 1 deletion app/views/tags/edit.html.erb
Expand Up @@ -20,9 +20,10 @@
<%= semantic_form_for(@tag, :html => { :class => '', :id => 'tag'}) do |f| %>
<%= f.inputs do %>
<%= f.input :title, :input_html => { :class => "span6" } %>
<%= f.input :short_description, :as => :text, :input_html => { :class => "span6", :rows => 2} %>
<%= f.input :description, :as => :text, :input_html => { :class => "span6", :rows => 6} %>
<% end %>
<%= f.submit :value => "Save", :class => "btn btn-success" %>
<%= f.submit :value => "Save", :class => "btn btn-success" %>
<% end %>
</div>
</div>
7 changes: 6 additions & 1 deletion features/step_definitions/category_steps.rb
Expand Up @@ -32,6 +32,11 @@
click_button "Save"
end

When /^I change the short description to "(.*?)"$/ do |short_description|
fill_in "Short description", with: short_description
click_button "Save"
end

Then /^I should be on the categories page$/ do
assert_equal categories_path, page.current_url
end
Expand All @@ -44,4 +49,4 @@
Tag.where(tag_type: 'section').each do |t|
assert CuratedList.any_in(tag_ids: [t.tag_id]).first, "List for #{t.tag_id} missing"
end
end
end
8 changes: 8 additions & 0 deletions features/tag_management.feature
Expand Up @@ -13,3 +13,11 @@ Feature: Managing tags

Then I should see "Successfully updated"
And I should see "Crime, justice and superheroes"

Scenario: Updating a tag title
When I visit the categories page
And I follow the link to edit the category
And I change the short description to "A superhero is a fictional character who has powers which are unusual for normal people"

Then I should see "Successfully updated"
And I should see "A superhero is a fictional character who has powers which are unusual for normal people"
13 changes: 6 additions & 7 deletions test/functional/tags_controller_test.rb
Expand Up @@ -3,20 +3,22 @@
class TagsControllerTest < ActionController::TestCase
setup do
login_as_stub_user
TagRepository.put(tag_id: "crime", title: "Crime", tag_type: "section")
TagRepository.put(tag_id: "crime", title: "Crime", tag_type: "section",
short_description: "Legal processes, courts and the police")
TagRepository.put(tag_id: "crime/the-police", title: "The Police", tag_type: "section")
@tag_count = 2
end

context "GET /tags/:id" do
should "return tag" do
get :show, id: "crime/the-police", format: "json"
get :show, id: "crime", format: "json"
parsed = JSON.parse(response.body)
assert_response :success
assert_equal parsed["status"], "ok"
assert_equal parsed["tag"]["type"], "section"
assert_equal parsed["tag"]["id"], "crime/the-police"
assert_equal parsed["tag"]["title"], "The Police"
assert_equal parsed["tag"]["id"], "crime"
assert_equal parsed["tag"]["title"], "Crime"
assert_match /Legal processes, courts and the police/, parsed["tag"]["short_description"]
end

should "return 404" do
Expand All @@ -33,7 +35,6 @@ class TagsControllerTest < ActionController::TestCase
assert_equal parsed["status"], "ok"
assert_equal parsed["total"], @tag_count
assert_equal parsed["results"].count, @tag_count

end
end

Expand All @@ -46,6 +47,4 @@ class TagsControllerTest < ActionController::TestCase
refute parsed["results"].any? { |result| result["id"] == "minister-of-silly" }
end
end


end

0 comments on commit 238f486

Please sign in to comment.