Commit bb8bfed2b2bc0e7f48c16c008dca39a75a0290dc
Exists in
master
and in
27 other branches
Merge remote-tracking branch 'origin/master'
Showing
8 changed files
with
40 additions
and
41 deletions
Show diff stats
app/helpers/person_notifier_helper.rb
app/models/environment.rb
app/models/person_notifier.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 %> | ... | ... |
db/schema.rb
| ... | ... | @@ -11,7 +11,7 @@ |
| 11 | 11 | # |
| 12 | 12 | # It's strongly recommended to check this file into your version control system. |
| 13 | 13 | |
| 14 | -ActiveRecord::Schema.define(:version => 20150113131617) do | |
| 14 | +ActiveRecord::Schema.define(:version => 20150122165042) do | |
| 15 | 15 | |
| 16 | 16 | create_table "abuse_reports", :force => true do |t| |
| 17 | 17 | t.integer "reporter_id" | ... | ... |
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 | ... | ... |
test/unit/person_notifier_helper_test.rb
| ... | ... | @@ -1,23 +0,0 @@ |
| 1 | -require_relative "../test_helper" | |
| 2 | - | |
| 3 | -class PersonNotifierHelperTest < ActionView::TestCase | |
| 4 | - | |
| 5 | - include PersonNotifierHelper | |
| 6 | - | |
| 7 | - def setup | |
| 8 | - @profile = mock | |
| 9 | - @env = Environment.new | |
| 10 | - end | |
| 11 | - attr_reader :profile, :env | |
| 12 | - | |
| 13 | - should 'append top url of environment at image path' do | |
| 14 | - profile.expects(:environment).returns(env).at_least_once | |
| 15 | - assert_match /src="http:\/\/localhost\/image.png"/, image_tag("/image.png") | |
| 16 | - end | |
| 17 | - | |
| 18 | - should 'return original path if do not have an environment' do | |
| 19 | - profile.expects(:environment).returns(nil).at_least_once | |
| 20 | - assert_match /src="\/image.png"/, image_tag("/image.png") | |
| 21 | - end | |
| 22 | - | |
| 23 | -end |