Commit 91109fe37086fb29a1508b00cdb85b2c33f7cf55
1 parent
2b336e03
Exists in
master
and in
27 other branches
hide license selection in article edition when there is no license available
Showing
4 changed files
with
38 additions
and
1 deletions
Show diff stats
app/models/environment.rb
app/views/cms/_general_fields.html.erb
| 1 | 1 | <%= select_profile_folder(_('Parent folder:'), 'article[parent_id]', profile, @article.parent_id) %> |
| 2 | -<%= labelled_form_field(_('License'), select(:article, :license_id, options_for_select_with_title([[_('None'), nil]] + profile.environment.licenses.map {|license| [license.name, license.id]}, @article.license ? @article.license.id : nil))) %> | |
| 2 | +<% if profile.environment.has_license? %> | |
| 3 | + <%= labelled_form_field(_('License'), select(:article, :license_id, options_for_select_with_title([[_('None'), nil]] + profile.environment.licenses.map {|license| [license.name, license.id]}, @article.license ? @article.license.id : nil))) %> | |
| 4 | +<% end %> | ... | ... |
test/functional/cms_controller_test.rb
| ... | ... | @@ -1678,6 +1678,15 @@ class CmsControllerTest < ActionController::TestCase |
| 1678 | 1678 | assert_equal license, article.license |
| 1679 | 1679 | end |
| 1680 | 1680 | |
| 1681 | + should 'not display license field if there is no license availabe in environment' do | |
| 1682 | + article = fast_create(Article, :profile_id => profile.id) | |
| 1683 | + License.delete_all | |
| 1684 | + login_as(profile.identifier) | |
| 1685 | + | |
| 1686 | + get :new, :profile => profile.identifier, :type => 'TinyMceArticle' | |
| 1687 | + assert_no_tag :tag => 'select', :attributes => {:id => 'article_license_id'} | |
| 1688 | + end | |
| 1689 | + | |
| 1681 | 1690 | should 'list folders options to move content' do |
| 1682 | 1691 | article = fast_create(Article, :profile_id => profile.id) |
| 1683 | 1692 | f1 = fast_create(Folder, :profile_id => profile.id) | ... | ... |
test/unit/environment_test.rb
| ... | ... | @@ -1627,4 +1627,26 @@ class EnvironmentTest < ActiveSupport::TestCase |
| 1627 | 1627 | |
| 1628 | 1628 | assert_equal 'Welcome to the environment', environment.signup_welcome_screen_body |
| 1629 | 1629 | end |
| 1630 | + | |
| 1631 | + should 'has_license be true if there is one license in enviroment' do | |
| 1632 | + e = fast_create(Environment) | |
| 1633 | + fast_create(License, :name => 'Some', :environment_id => e.id) | |
| 1634 | + | |
| 1635 | + assert e.has_license? | |
| 1636 | + end | |
| 1637 | + | |
| 1638 | + should 'has_license be true if there is many licenses in enviroment' do | |
| 1639 | + e = fast_create(Environment) | |
| 1640 | + fast_create(License, :name => 'Some', :environment_id => e.id) | |
| 1641 | + fast_create(License, :name => 'Another', :environment_id => e.id) | |
| 1642 | + | |
| 1643 | + assert e.has_license? | |
| 1644 | + end | |
| 1645 | + | |
| 1646 | + should 'has_license be false if there is no license in enviroment' do | |
| 1647 | + e = fast_create(Environment) | |
| 1648 | + | |
| 1649 | + assert !e.has_license? | |
| 1650 | + end | |
| 1651 | + | |
| 1630 | 1652 | end | ... | ... |