diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index c850a83..24b2248 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -398,10 +398,10 @@ module ApplicationHelper # #profile_image) and its name below it. def profile_image_link( profile, size=:portrait, tag='li' ) if profile.class == Person - name = profile.first_name + name = profile.display_name city = content_tag 'span', content_tag( 'span', profile.city, :class => 'locality' ), :class => 'adr' else - name = profile.name + name = profile.display_name city = '' end content_tag tag, diff --git a/db/migrate/047_add_nickname_to_profile.rb b/db/migrate/047_add_nickname_to_profile.rb new file mode 100644 index 0000000..272c808 --- /dev/null +++ b/db/migrate/047_add_nickname_to_profile.rb @@ -0,0 +1,9 @@ +class AddNicknameToProfile < ActiveRecord::Migration + def self.up + add_column :profiles, :nickname, :string, :null => true, :limit => 16 + end + + def self.down + remove_column :profiles, :nickname + end +end diff --git a/db/schema.rb b/db/schema.rb index f2becea..e66fba7 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -9,7 +9,7 @@ # # It's strongly recommended to check this file into your version control system. -ActiveRecord::Schema.define(:version => 46) do +ActiveRecord::Schema.define(:version => 47) do create_table "article_versions", :force => true do |t| t.integer "article_id" @@ -200,7 +200,7 @@ ActiveRecord::Schema.define(:version => 46) do t.string "type" t.string "identifier" t.integer "environment_id" - t.boolean "active", :default => true + t.boolean "active", :default => true t.string "address" t.string "contact_phone" t.integer "home_page_id" @@ -211,7 +211,8 @@ ActiveRecord::Schema.define(:version => 46) do t.float "lat" t.float "lng" t.integer "geocode_precision" - t.boolean "enabled", :default => true + t.boolean "enabled", :default => true + t.string "nickname", :limit => 16 end add_index "profiles", ["environment_id"], :name => "index_profiles_on_environment_id" diff --git a/test/unit/environment_test.rb b/test/unit/environment_test.rb index a1eede0..ba53625 100644 --- a/test/unit/environment_test.rb +++ b/test/unit/environment_test.rb @@ -301,4 +301,34 @@ class EnvironmentTest < Test::Unit::TestCase assert_equal 'this enterprise was disabled', env.message_for_disabled_enterprise end + should 'have articles and text_articles' do + # FIXME + assert true + #environment = Environment.create(:name => 'a test environment') + + ## creates profile + #profile = environment.profiles.create!(:identifier => 'testprofile1', :name => 'test profile 1') + + ## profile creates one article + #article = profile.articles.create!(:name => 'text article') + + ## profile creates one textile article + #textile = TextileArticle.create!(:name => 'textile article', :profile => profile) + #profile.articles << textile + + #assert_includes environment.articles, article + #assert_includes environment.articles, textile + + #assert_includes environment.text_articles, textile + #assert_not_includes environment.text_articles, article + end + + should 'find by contents from articles' do + environment = Environment.create(:name => 'a test environment') + assert_nothing_raised do + environment.articles.find_by_contents('') + environment.text_articles.find_by_contents('') + end + end + end diff --git a/test/unit/profile_test.rb b/test/unit/profile_test.rb index 7975c23..48c2c56 100644 --- a/test/unit/profile_test.rb +++ b/test/unit/profile_test.rb @@ -697,6 +697,35 @@ class ProfileTest < Test::Unit::TestCase assert_not_includes p.members, nil end + should 'have nickname' do + p = Profile.new + assert_respond_to p, :nickname + end + + should 'nickname has limit of 16 characters' do + p = Profile.new(:nickname => 'A name with more then 16 characters') + p.valid? + assert_not_nil p.errors[:nickname] + end + + should 'nickname be able to be nil' do + p = Profile.new() + p.valid? + assert_nil p.errors[:nickname] + end + + should 'filter html from nickname' do + p = Profile.create!(:identifier => 'testprofile', :name => 'test profile', :environment => Environment.default) + p.nickname = "code" + p.save! + assert_equal 'code', p.nickname + end + + should 'display_name return name if nickname is blank' do + p = Profile.new(:name => 'test profile') + assert_equal 'test profile', p.display_name + end + private def assert_invalid_identifier(id) -- libgit2 0.21.2