Browse files

Merge remote branch 'origin/add-language-to-artefact'

  • Loading branch information...
2 parents 4a456c3 + 6627260 commit b94185c453283331aff0215983288e07c14d5106 @alext alext committed Nov 29, 2012
View
2 Gemfile
@@ -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.4.0"
+ gem "govuk_content_models", "2.5.0"
end
if ENV['BUNDLE_DEV']
View
4 Gemfile.lock
@@ -123,7 +123,7 @@ GEM
htmlentities (~> 4)
kramdown (~> 0.13.3)
sanitize (= 2.0.3)
- govuk_content_models (2.4.0)
+ govuk_content_models (2.5.0)
bson_ext
differ
gds-api-adapters
@@ -322,7 +322,7 @@ DEPENDENCIES
gds-sso (= 2.0.0)
gds-warmup-controller (= 0.1.0)
gelf
- govuk_content_models (= 2.4.0)
+ govuk_content_models (= 2.5.0)
launchy
less-rails-bootstrap
lograge
View
BIN app/assets/images/language_cy.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
18 app/assets/stylesheets/application.css
@@ -35,4 +35,20 @@ table#artefact-list tr.archived {
opacity: 0.5;
}
-/* end of tablesorter styling */
+/* end of tablesorter styling */
+
+.language_icon {
+ display: inline-block;
+ text-indent: -9999px;
+ vertical-align: middle;
+}
+
+/*
+ Right now - only mark welsh content so that it can be better distinguished in the artefact list.
+ In future, we could show the language for all artefacts.
+*/
+.language_icon.lang_cy {
+ width: 16px;
+ height: 16px;
+ background: url(language_cy.png) no-repeat center center;
+}
View
1 app/views/artefacts/_form.html.erb
@@ -31,6 +31,7 @@
<hr>
+ <%= f.input :language, :collection => {"English" => "en", "Welsh" => "cy"}, :as => :select, :input_html => { :class => "span2" }, :include_blank => false %>
<%= f.input :business_proposition, :label => 'Is this business content?', :as => :boolean %>
<hr>
View
1 app/views/artefacts/index.html.erb
@@ -40,6 +40,7 @@
<td><%= link_to artefact.name, edit_artefact_path(artefact.id) %></td>
<td class="icon">
<%= image_tag "icon-#{artefact.kind.downcase}.png", :title => artefact.kind.humanize %>
+ <%= content_tag "span", artefact.language, :class => "language_icon lang_#{artefact.language}" %>
</td>
<td><%= artefact.primary_section %></td>
<td><%= (artefact.sections - [artefact.primary_section]).join(", ") %></td>
View
27 test/integration/artefacts_edit_test.rb
@@ -50,6 +50,33 @@ class ArtefactsEditTest < ActionDispatch::IntegrationTest
end
end
+ context "editing language" do
+ setup do
+ @artefact = FactoryGirl.create(:artefact, :name => "Bank holidays", :language => nil)
+ end
+
+ should "allow changing language for an artefact" do
+ visit "/artefacts"
+ click_on "Bank holidays"
+
+ select "Welsh", :from => "artefact[language]"
+ click_on "Save and continue editing"
+
+ @artefact.reload
+ assert_equal "cy", @artefact.language
+ end
+
+ should "select english language by default" do
+ visit "/artefacts"
+ click_on "Bank holidays"
+
+ click_on "Save and continue editing"
+
+ @artefact.reload
+ assert_equal "en", @artefact.language
+ end
+ end
+
should "not include completed transactions in related item lists" do
a = FactoryGirl.create(:artefact, :name => "Alpha", :slug => 'alpha')
b = FactoryGirl.create(:artefact, :name => "Beta", :slug => 'beta')
View
13 test/integration/artefacts_index_test.rb
@@ -17,4 +17,17 @@ class ArtefactsIndexTest < ActionDispatch::IntegrationTest
assert page.has_link?("bravo", :href => "http://www.test.gov.uk/bravo")
assert page.has_link?("charlie", :href => "http://www.test.gov.uk/charlie")
end
+
+ should "display the language for the artefact" do
+ FactoryGirl.create(:artefact, :name => 'Alpha', :slug => 'alpha', :language => "en")
+ FactoryGirl.create(:artefact, :name => 'Bravo', :slug => 'bravo', :language => "cy")
+
+ visit "/artefacts"
+
+ alpha = find('tr', :text => "Alpha")
+ bravo = find('tr', :text => "Bravo")
+
+ assert alpha.has_content?("en")
+ assert bravo.has_content?("cy")
+ end
end

0 comments on commit b94185c

Please sign in to comment.