typus 3.1.0.rc4 → 3.1.0.rc5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (71) hide show
  1. data/Gemfile +2 -0
  2. data/app/assets/images/{typus/blank.gif → blank.gif} +0 -0
  3. data/app/assets/images/{typus/fancy_close.png → fancy_close.png} +0 -0
  4. data/app/assets/images/{typus/fancy_loading.png → fancy_loading.png} +0 -0
  5. data/app/assets/images/{typus/fancy_nav_left.png → fancy_nav_left.png} +0 -0
  6. data/app/assets/images/{typus/fancy_nav_right.png → fancy_nav_right.png} +0 -0
  7. data/app/assets/images/{typus/fancy_shadow_e.png → fancy_shadow_e.png} +0 -0
  8. data/app/assets/images/{typus/fancy_shadow_n.png → fancy_shadow_n.png} +0 -0
  9. data/app/assets/images/{typus/fancy_shadow_ne.png → fancy_shadow_ne.png} +0 -0
  10. data/app/assets/images/{typus/fancy_shadow_nw.png → fancy_shadow_nw.png} +0 -0
  11. data/app/assets/images/{typus/fancy_shadow_s.png → fancy_shadow_s.png} +0 -0
  12. data/app/assets/images/{typus/fancy_shadow_se.png → fancy_shadow_se.png} +0 -0
  13. data/app/assets/images/{typus/fancy_shadow_sw.png → fancy_shadow_sw.png} +0 -0
  14. data/app/assets/images/{typus/fancy_shadow_w.png → fancy_shadow_w.png} +0 -0
  15. data/app/assets/images/{typus/fancy_title_left.png → fancy_title_left.png} +0 -0
  16. data/app/assets/images/{typus/fancy_title_main.png → fancy_title_main.png} +0 -0
  17. data/app/assets/images/{typus/fancy_title_over.png → fancy_title_over.png} +0 -0
  18. data/app/assets/images/{typus/fancy_title_right.png → fancy_title_right.png} +0 -0
  19. data/app/assets/images/{typus/fancybox-x.png → fancybox-x.png} +0 -0
  20. data/app/assets/images/{typus/fancybox-y.png → fancybox-y.png} +0 -0
  21. data/app/assets/images/{typus/fancybox.png → fancybox.png} +0 -0
  22. data/app/assets/javascripts/typus.js +7 -0
  23. data/app/assets/javascripts/typus/application.js +3 -7
  24. data/app/assets/stylesheets/typus.css +7 -0
  25. data/app/assets/stylesheets/typus/application.css +11 -6
  26. data/app/controllers/admin/resources_controller.rb +6 -1
  27. data/app/helpers/admin/filters_helper.rb +1 -5
  28. data/app/helpers/admin/form_helper.rb +14 -12
  29. data/app/helpers/admin/relationships_helper.rb +15 -13
  30. data/app/helpers/admin/resources_helper.rb +2 -3
  31. data/app/helpers/admin/sidebar_helper.rb +2 -2
  32. data/app/helpers/admin/table_helper.rb +10 -14
  33. data/app/views/admin/base/user_guide.html.erb +1 -1
  34. data/app/views/admin/resources/index.html.erb +1 -1
  35. data/app/views/admin/resources/new.html.erb +1 -1
  36. data/app/views/admin/shared/_head.html.erb +2 -2
  37. data/app/views/admin/templates/_selector.html.erb +1 -7
  38. data/config/locales/typus.ca.models.yml +8 -8
  39. data/config/locales/typus.ca.yml +1 -2
  40. data/config/locales/typus.de.yml +1 -2
  41. data/config/locales/typus.el.yml +1 -2
  42. data/config/locales/typus.es.yml +1 -2
  43. data/config/locales/typus.fr.yml +1 -2
  44. data/config/locales/typus.hu.yml +1 -2
  45. data/config/locales/typus.it.yml +1 -2
  46. data/config/locales/typus.locale.yml.template +1 -2
  47. data/config/locales/typus.pt-BR.yml +1 -2
  48. data/config/locales/typus.ru.yml +1 -2
  49. data/config/locales/typus.zh-CN.yml +1 -2
  50. data/lib/generators/templates/config/initializers/typus_authentication.rb +2 -2
  51. data/lib/generators/typus/migration_generator.rb +1 -1
  52. data/lib/support/active_record.rb +1 -5
  53. data/lib/typus.rb +2 -2
  54. data/lib/typus/authentication/session.rb +5 -5
  55. data/lib/typus/controller/headless.rb +1 -1
  56. data/lib/typus/controller/trash.rb +2 -1
  57. data/lib/typus/orm/active_record/user/instance_methods.rb +1 -1
  58. data/lib/typus/orm/base.rb +1 -1
  59. data/lib/typus/version.rb +1 -1
  60. data/test/app/controllers/admin/posts_controller_test.rb +4 -4
  61. data/test/fixtures/rails_app/app/controllers/admin/assets_controller.rb +1 -1
  62. data/test/fixtures/rails_app/app/controllers/admin/entries_controller.rb +3 -0
  63. data/test/fixtures/rails_app/app/models/entry.rb +12 -0
  64. data/test/fixtures/rails_app/app/models/post.rb +20 -12
  65. data/test/fixtures/rails_app/db/schema.rb +1 -0
  66. data/test/lib/support/active_record_test.rb +46 -108
  67. data/test/lib/typus_test.rb +4 -4
  68. data/typus.gemspec +2 -1
  69. metadata +41 -30
  70. data/app/assets/javascripts/typus/custom.js +0 -2
  71. data/app/assets/stylesheets/typus/custom.css +0 -11
@@ -7,7 +7,7 @@ fr:
7
7
  "Actions": "Actions"
8
8
  "Active": "Actif"
9
9
  "Add": "Ajouter"
10
- "Add new": "Ajouter nouveau"
10
+ "Add New": "Ajouter nouveau"
11
11
  "Are you sure?": "Êtes-vous sûre ?"
12
12
  "Are you sure you want to sign out and end your session?": "Etes-vous sûre de vouloir vous déconnecter et mettre fin à votre session ?"
13
13
 
@@ -34,7 +34,6 @@ fr:
34
34
  "Last few days": "Ces derniers jours"
35
35
  "Last 30 days": "30 derniers jours"
36
36
  "Last 7 days": "7 derniers jours"
37
- "List": "Liste"
38
37
  "Logged as": "Identifié comme"
39
38
  "Login": "Identification"
40
39
 
@@ -6,7 +6,7 @@ hu:
6
6
  "Actions": "Akciók"
7
7
  "Active": "Aktív"
8
8
  "Add": "Hozzáad"
9
- "Add new": "Új hozzáadása"
9
+ "Add New": "Új hozzáadása"
10
10
  "Are you sure?": "Biztos vagy benne?"
11
11
  "Are you sure you want to sign out and end your session?": "Biztosan ki akarsz lépni?"
12
12
 
@@ -31,7 +31,6 @@ hu:
31
31
  "Last few days": "Utóbbi néhány nap"
32
32
  "Last 30 days": "Az elmúlt 30 nap"
33
33
  "Last 7 days": "Az elmúlt 7 nap"
34
- "List":
35
34
  "Logged as": "Bejelentkezve"
36
35
  "Login": "Belépés"
37
36
 
@@ -6,7 +6,7 @@ it:
6
6
  "Actions": "Azioni"
7
7
  "Active": "Attivo"
8
8
  "Add": "Inserisci"
9
- "Add new": "Inserisci nuovo"
9
+ "Add New": "Inserisci nuovo"
10
10
  "Are you sure?": "Sei sicuro?"
11
11
  "Are you sure you want to sign out and end your session?": "Sei sicuro che vuoi disconnetterti dal sistema?"
12
12
 
@@ -34,7 +34,6 @@ it:
34
34
  "Last few days": "Ultimi giorni"
35
35
  "Last 30 days": "Ultimi 30 giorni"
36
36
  "Last 7 days": "Ultimi 7 giorni"
37
- "List": "Lista"
38
37
  "Loading": "Caricamento"
39
38
  "Logged as": "Loggato come"
40
39
  "Login": "Login"
@@ -6,7 +6,7 @@
6
6
  "Actions":
7
7
  "Active":
8
8
  "Add":
9
- "Add new":
9
+ "Add New":
10
10
  "All":
11
11
  "Are you sure?":
12
12
  "Are you sure you want to sign out and end your session?":
@@ -31,7 +31,6 @@
31
31
  "Last few days":
32
32
  "Last 30 days":
33
33
  "Last 7 days":
34
- "List":
35
34
  "Logged as":
36
35
  "Login":
37
36
 
@@ -6,7 +6,7 @@ pt-BR:
6
6
  "Actions": "Ações"
7
7
  "Active":
8
8
  "Add": "Adicionar"
9
- "Add new": "Adicionar novo"
9
+ "Add New": "Adicionar novo"
10
10
  "Are you sure?":
11
11
  "Are you sure you want to sign out and end your session?": "Tem certeza que quer sair e encerrar sua sessão?"
12
12
 
@@ -31,7 +31,6 @@ pt-BR:
31
31
  "Last few days": "Últimos dias"
32
32
  "Last 30 days": "Últimos 30 dias"
33
33
  "Last 7 days": "Últimos 7 dias"
34
- "List":
35
34
  "Logged as": "Logado como"
36
35
  "Login": "Login"
37
36
 
@@ -6,7 +6,7 @@ ru:
6
6
  "Actions": "Действия"
7
7
  "Active":
8
8
  "Add": "Добавить"
9
- "Add new": "Добавить новый"
9
+ "Add New": "Добавить новый"
10
10
  "Are you sure?":
11
11
  "Are you sure you want to sign out and end your session?":
12
12
 
@@ -31,7 +31,6 @@ ru:
31
31
  "Last few days": "Последние дней"
32
32
  "Last 7 days": "Последние 7 дней"
33
33
  "Last 30 days": "Последние 30 дней"
34
- "List":
35
34
  "Logged as": "Вы вошли как"
36
35
  "Login": "Редактировать"
37
36
 
@@ -6,7 +6,7 @@ zh-CN:
6
6
  "Actions": "动作"
7
7
  "Active": "已激活"
8
8
  "Add": "新增"
9
- "Add new": "新增"
9
+ "Add New": "新增"
10
10
  "Are you sure?": "你是否确认?"
11
11
  "Are you sure you want to sign out and end your session?": "你是否确认登出并结束本次会话?"
12
12
 
@@ -30,7 +30,6 @@ zh-CN:
30
30
  "Last few days": "最近几天"
31
31
  "Last 30 days": "最近一个月"
32
32
  "Last 7 days": "最近一周"
33
- "List": "列表"
34
33
  "Logged as": "登录为"
35
34
  "Login": "登录"
36
35
 
@@ -12,7 +12,7 @@ Typus.setup do |config|
12
12
  # Define user_class_name.
13
13
  config.user_class_name = "<%= options[:user_class_name] %>"
14
14
 
15
- # Define user_fk.
16
- config.user_fk = "<%= options[:user_fk] %>"
15
+ # Define user_foreign_key.
16
+ config.user_foreign_key = "<%= options[:user_foreign_key] %>"
17
17
 
18
18
  end
@@ -10,7 +10,7 @@ module Typus
10
10
  source_root File.expand_path("../../templates", __FILE__)
11
11
 
12
12
  class_option :user_class_name, :default => "AdminUser", :aliases => "-u"
13
- class_option :user_fk, :default => "admin_user_id", :aliases => "-fk"
13
+ class_option :user_foreign_key, :default => "admin_user_id", :aliases => "-fk"
14
14
 
15
15
  desc <<-DESC
16
16
  Description:
@@ -26,11 +26,7 @@ class ActiveRecord::Base
26
26
  #++
27
27
  def mapping(attribute)
28
28
  klass = self.class
29
- values = if klass.const_defined?(attribute.upcase)
30
- klass::const_get(attribute.upcase)
31
- else
32
- klass.send(attribute)
33
- end
29
+ values = klass.send(attribute)
34
30
 
35
31
  array = values.first.is_a?(Array) ? values : values.map { |i| [i, i] }
36
32
 
@@ -123,8 +123,8 @@ module Typus
123
123
  mattr_accessor :user_class_name
124
124
  @@user_class_name = "TypusUser"
125
125
 
126
- mattr_accessor :user_fk
127
- @@user_fk = "typus_user_id"
126
+ mattr_accessor :user_foreign_key
127
+ @@user_foreign_key = "typus_user_id"
128
128
 
129
129
  class << self
130
130
 
@@ -87,19 +87,19 @@ module Typus
87
87
  if admin_user.is_not_root?
88
88
 
89
89
  condition_typus_users = @item.respond_to?(Typus.relationship) && !@item.send(Typus.relationship).include?(admin_user)
90
- condition_typus_user_id = @item.respond_to?(Typus.user_fk) && !admin_user.owns?(@item)
90
+ condition_typus_user_id = @item.respond_to?(Typus.user_foreign_key) && !admin_user.owns?(@item)
91
91
 
92
92
  not_allowed if (condition_typus_users || condition_typus_user_id)
93
93
  end
94
94
  end
95
95
 
96
96
  #--
97
- # Show only related items it @resource has a foreign_key (Typus.user_fk)
97
+ # Show only related items it @resource has a foreign_key (Typus.user_foreign_key)
98
98
  # related to the logged user.
99
99
  #++
100
100
  def check_resources_ownership
101
101
  if admin_user.is_not_root? && @resource.typus_user_id?
102
- @resource = @resource.where(Typus.user_fk => admin_user)
102
+ @resource = @resource.where(Typus.user_foreign_key => admin_user)
103
103
  end
104
104
  end
105
105
 
@@ -107,7 +107,7 @@ module Typus
107
107
  # OPTIMIZE: This method should accept args.
108
108
  #
109
109
  def set_attributes_on_create
110
- @item.send("#{Typus.user_fk}=", admin_user.id) if @resource.typus_user_id?
110
+ @item.send("#{Typus.user_foreign_key}=", admin_user.id) if @resource.typus_user_id?
111
111
  end
112
112
 
113
113
  ##
@@ -116,7 +116,7 @@ module Typus
116
116
  #
117
117
  def set_attributes_on_update
118
118
  if @resource.typus_user_id? && admin_user.is_not_root?
119
- @item.update_attributes(Typus.user_fk => admin_user.id)
119
+ @item.update_attributes(Typus.user_foreign_key => admin_user.id)
120
120
  end
121
121
  end
122
122
 
@@ -9,7 +9,7 @@ module Typus
9
9
  end
10
10
 
11
11
  def set_resources_action_for_headless_on_index
12
- add_resources_action("Add new", {:action => "new"}, {})
12
+ add_resources_action("Add New", {:action => "new"}, {})
13
13
  end
14
14
  private :set_resources_action_for_headless_on_index
15
15
 
@@ -25,7 +25,8 @@ module Typus
25
25
  generate_html
26
26
  render 'index'
27
27
  end
28
- @resource.typus_export_formats.each { |f| format.send(f) { send("generate_#{f}") } }
28
+
29
+ %w(json xml csv).each { |f| format.send(f) { send("generate_#{f}") } }
29
30
  end
30
31
  end
31
32
 
@@ -54,7 +54,7 @@ module Typus
54
54
  end
55
55
 
56
56
  def owns?(resource)
57
- id == resource.send(Typus.user_fk)
57
+ id == resource.send(Typus.user_foreign_key)
58
58
  end
59
59
 
60
60
  end
@@ -144,7 +144,7 @@ module Typus
144
144
  end
145
145
 
146
146
  def typus_user_id?
147
- columns.map { |u| u.name }.include?(Typus.user_fk)
147
+ columns.map { |u| u.name }.include?(Typus.user_foreign_key)
148
148
  end
149
149
 
150
150
  def read_model_config
@@ -1,3 +1,3 @@
1
1
  module Typus
2
- VERSION = "3.1.0.rc4"
2
+ VERSION = "3.1.0.rc5"
3
3
  end
@@ -542,7 +542,7 @@ title;status
542
542
 
543
543
  should "render index_and_show_add_entry_link" do
544
544
  assert_select "#sidebar ul" do
545
- assert_select "li", "Add new"
545
+ assert_select "li", "Add New"
546
546
  end
547
547
  end
548
548
 
@@ -559,7 +559,7 @@ title;status
559
559
  end
560
560
 
561
561
  should "render new and verify page title" do
562
- assert_select "title", "Typus &mdash; New Post"
562
+ assert_select "title", "Typus &mdash; Add New Post"
563
563
  end
564
564
 
565
565
  end
@@ -677,7 +677,7 @@ title;status
677
677
  context "when creating an item" do
678
678
 
679
679
  ##
680
- # We click on the "Add new" link and we are redirected to:
680
+ # We click on the "Add New" link and we are redirected to:
681
681
  #
682
682
  # /admin/posts/new
683
683
  #
@@ -707,7 +707,7 @@ title;status
707
707
  context "when editing an item" do
708
708
 
709
709
  ##
710
- # We click on the "Add new" link and we are redirected to:
710
+ # We click on the "Add New" link and we are redirected to:
711
711
  #
712
712
  # /admin/posts/new
713
713
  #
@@ -4,7 +4,7 @@ class Admin::AssetsController < Admin::ResourcesController
4
4
 
5
5
  def index
6
6
  if params[:layout]
7
- add_resources_action("Add new", {:action => "new"}, {})
7
+ add_resources_action("Add New", {:action => "new"}, {})
8
8
  end
9
9
 
10
10
  super
@@ -1,2 +1,5 @@
1
1
  class Admin::EntriesController < Admin::ResourcesController
2
+
3
+ include Typus::Controller::Trash
4
+
2
5
  end
@@ -8,6 +8,12 @@
8
8
 
9
9
  class Entry < ActiveRecord::Base
10
10
 
11
+ ##
12
+ # Macros
13
+ #
14
+
15
+ has_trash
16
+
11
17
  ##
12
18
  # Validations
13
19
  #
@@ -20,4 +26,10 @@ class Entry < ActiveRecord::Base
20
26
 
21
27
  has_and_belongs_to_many :categories
22
28
 
29
+ ##
30
+ # Scopes
31
+ #
32
+
33
+ default_scope where(:deleted_at => nil)
34
+
23
35
  end
@@ -1,17 +1,5 @@
1
1
  class Post < ActiveRecord::Base
2
2
 
3
- ##
4
- # Constants
5
- #
6
-
7
- STATUS = { "Draft" => "draft",
8
- "Published" => "published",
9
- "Unpublished" => "unpublished",
10
- "<div class=''>Something special</div>".html_safe => "special" }
11
-
12
- ARRAY_SELECTOR = %w(item1 item2)
13
- ARRAY_HASH_SELECTOR = [["Draft", "draft"], ["Custom Status", "custom"]]
14
-
15
3
  ##
16
4
  # Validations
17
5
  #
@@ -29,4 +17,24 @@ class Post < ActiveRecord::Base
29
17
  has_many :comments
30
18
  has_many :views
31
19
 
20
+ ##
21
+ # Class Methods
22
+ #
23
+
24
+ def self.status
25
+ { "Draft" => "draft",
26
+ "Published" => "published",
27
+ "Unpublished" => "unpublished",
28
+ "<div class=''>Something special</div>".html_safe => "special" }
29
+ end
30
+
31
+ def self.array_selector
32
+ %w(item1 item2)
33
+ end
34
+
35
+ def self.array_hash_selector
36
+ [["Draft", "draft"],
37
+ ["Custom Status", "custom"]]
38
+ end
39
+
32
40
  end
@@ -62,6 +62,7 @@ ActiveRecord::Schema.define do
62
62
  t.text :content
63
63
  t.string :type
64
64
  t.boolean :published, :null => false, :default => false
65
+ t.datetime :deleted_at
65
66
  end
66
67
 
67
68
  create_table :categories_entries, :force => true, :id => false do |t|
@@ -2,133 +2,71 @@ require "test_helper"
2
2
 
3
3
  class ActiveRecordTest < ActiveSupport::TestCase
4
4
 
5
- test "relationship between Post and Comment" do
6
- assert Post.relationship_with(Comment).eql?(:has_many)
7
- end
8
-
9
- test "relationship between Comment and Post" do
10
- assert Comment.relationship_with(Post).eql?(:belongs_to)
11
- end
12
-
13
- test "relationship between Post and Category" do
14
- assert Post.relationship_with(Category).eql?(:has_and_belongs_to_many)
15
- end
16
-
17
- test "relationship between Category and Post" do
5
+ test "relationship between models" do
18
6
  assert Category.relationship_with(Post).eql?(:has_and_belongs_to_many)
19
- end
20
-
21
- test "relationship between Order and Invoice" do
22
- assert Order.relationship_with(Invoice).eql?(:has_one)
23
- end
24
-
25
- test "relationship between Invoice and Order" do
7
+ assert Comment.relationship_with(Post).eql?(:belongs_to)
26
8
  assert Invoice.relationship_with(Order).eql?(:belongs_to)
27
- end
28
-
29
- test "relationship between Invoice and TypusUser" do
30
9
  assert Invoice.relationship_with(TypusUser).eql?(:belongs_to)
31
- end
32
-
33
- test "relationship between TypusUser and Invoice" do
10
+ assert Order.relationship_with(Invoice).eql?(:has_one)
11
+ assert Post.relationship_with(Category).eql?(:has_and_belongs_to_many)
12
+ assert Post.relationship_with(Comment).eql?(:has_many)
34
13
  assert TypusUser.relationship_with(Invoice).eql?(:has_many)
35
14
  end
36
15
 
37
- context "mapping" do
38
-
39
- teardown do
40
- Post.send(:remove_const, :STATUS)
41
- Post::STATUS = { "Draft" => "draft",
42
- "Published" => "published",
43
- "Unpublished" => "unpublished",
44
- "<div class=''>Something special</div>".html_safe => "special" }
45
- end
46
-
47
- context "with an array" do
48
-
49
- setup do
50
- Post.send(:remove_const, :STATUS)
51
- Post::STATUS = %w(pending published unpublished)
52
- end
53
-
54
- should "work for symbols" do
55
- post = Factory.build(:post)
56
- assert_equal "published", post.mapping(:status)
57
- end
58
-
59
- should "work for strings" do
60
- post = Factory.build(:post, :status => "unpublished")
61
- assert_equal "unpublished", post.mapping('status')
62
- end
63
-
64
- should "for unexisting keys returning the current key" do
65
- post = Factory.build(:post, :status => "unexisting")
66
- assert_equal "unexisting", post.mapping(:status)
67
- end
16
+ test "mapping with an array" do
17
+ expected = %w(pending published unpublished)
18
+ Post.stubs(:status).returns(expected)
68
19
 
69
- end
20
+ post = Factory.build(:post)
21
+ assert_equal "published", post.mapping(:status)
70
22
 
71
- context "with a two dimension array" do
23
+ post = Factory.build(:post, :status => "unpublished")
24
+ assert_equal "unpublished", post.mapping('status')
72
25
 
73
- setup do
74
- Post.send(:remove_const, :STATUS)
75
- Post::STATUS = [["Publicado", "published"],
76
- ["Pendiente", "pending"],
77
- ["No publicado", "unpublished"]]
78
- end
79
-
80
- should "verify" do
81
- post = Factory.build(:post)
82
- assert_equal "Publicado", post.mapping(:status)
83
- post = Factory.build(:post, :status => "unpublished")
84
- assert_equal "No publicado", post.mapping(:status)
85
- end
86
-
87
- end
88
-
89
- context "with a hash" do
90
-
91
- setup do
92
- Post.send(:remove_const, :STATUS)
93
- Post::STATUS = { "Pending - Hash" => "pending",
94
- "Published - Hash" => "published",
95
- "Not Published - Hash" => "unpublished" }
96
- end
26
+ post = Factory.build(:post, :status => "unexisting")
27
+ assert_equal "unexisting", post.mapping(:status)
28
+ end
97
29
 
98
- should "verify" do
99
- page = Factory.build(:post)
100
- assert_equal "Published - Hash", page.mapping(:status)
101
- page = Factory.build(:post, :status => "unpublished")
102
- assert_equal "Not Published - Hash", page.mapping(:status)
103
- end
30
+ test "mapping with a two dimension array" do
31
+ expected = [["Publicado", "published"], ["Pendiente", "pending"], ["No publicado", "unpublished"]]
32
+ Post.stubs(:status).returns(expected)
104
33
 
105
- end
34
+ post = Factory.build(:post)
35
+ assert_equal "Publicado", post.mapping(:status)
106
36
 
37
+ post = Factory.build(:post, :status => "unpublished")
38
+ assert_equal "No publicado", post.mapping(:status)
107
39
  end
108
40
 
109
- context "to_label" do
41
+ test "mapping with a hash" do
42
+ expected = { "Pending - Hash" => "pending", "Published - Hash" => "published", "Not Published - Hash" => "unpublished" }
43
+ Post.stubs(:status).returns(expected)
110
44
 
111
- should "return email for TypusUser" do
112
- typus_user = Factory.build(:typus_user)
113
- assert_equal typus_user.email, typus_user.to_label
114
- end
45
+ page = Factory.build(:post)
46
+ assert_equal "Published - Hash", page.mapping(:status)
47
+ page = Factory.build(:post, :status => "unpublished")
48
+ assert_equal "Not Published - Hash", page.mapping(:status)
49
+ end
115
50
 
116
- should "return name for Category" do
117
- category = Factory.build(:category, :name => "Chunky Bacon")
118
- assert_match "Chunky Bacon", category.to_label
119
- end
51
+ test "to_label returns email for TypusUser" do
52
+ typus_user = Factory.build(:typus_user)
53
+ assert_equal typus_user.email, typus_user.to_label
54
+ end
120
55
 
121
- should "return Model#id because Category#name is empty" do
122
- category = Factory(:category)
123
- category.name = nil
124
- category.save(:validate => false)
125
- assert_equal "Category##{category.id}", category.to_label
126
- end
56
+ test "to_label returns name for Category" do
57
+ category = Factory.build(:category, :name => "Chunky Bacon")
58
+ assert_match "Chunky Bacon", category.to_label
59
+ end
127
60
 
128
- should "return default Model#id" do
129
- assert_match /Post#/, Factory(:post).to_label
130
- end
61
+ test "to_label returns Model#id because Category#name is empty" do
62
+ category = Factory(:category)
63
+ category.name = nil
64
+ category.save(:validate => false)
65
+ assert_equal "Category##{category.id}", category.to_label
66
+ end
131
67
 
68
+ test "to_label returns default Model#id" do
69
+ assert_match /Post#/, Factory(:post).to_label
132
70
  end
133
71
 
134
72
  test "to_resource" do