ixtlan 0.4.0.pre5 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (38) hide show
  1. data/History.txt +49 -0
  2. data/MIT-LICENSE +20 -0
  3. data/README.txt +86 -0
  4. data/Rakefile +59 -0
  5. data/lib/dm-serializer/to_xml.rb +10 -4
  6. data/lib/ixtlan/controllers/audits_controller.rb +6 -1
  7. data/lib/ixtlan/controllers/authentications_controller.rb +5 -1
  8. data/lib/ixtlan/controllers/domains_controller.rb +11 -7
  9. data/lib/ixtlan/controllers/groups_controller.rb +28 -7
  10. data/lib/ixtlan/controllers/locales_controller.rb +11 -7
  11. data/lib/ixtlan/controllers/search_query.rb +28 -12
  12. data/lib/ixtlan/controllers/users_controller.rb +1 -1
  13. data/lib/ixtlan/controllers/word_bundles_controller.rb +9 -3
  14. data/lib/ixtlan/guard.rb +17 -4
  15. data/lib/ixtlan/models/authentication.rb +8 -2
  16. data/lib/ixtlan/models/configuration.rb +14 -1
  17. data/lib/ixtlan/models/group.rb +14 -1
  18. data/lib/ixtlan/models/i18n_text.rb +6 -2
  19. data/lib/ixtlan/models/phrase.rb +11 -6
  20. data/lib/ixtlan/models/translation.rb +6 -2
  21. data/lib/ixtlan/models/user.rb +29 -2
  22. data/lib/ixtlan/modified_by.rb +1 -2
  23. data/lib/ixtlan/rails/error_handling.rb +1 -1
  24. data/lib/ixtlan/version.rb +1 -1
  25. data/lib/ixtlan/version.rb.errors +0 -0
  26. data/spec/authentication_spec.rb +16 -9
  27. data/spec/guard_spec.rb +8 -7
  28. data/spec/modified_by_spec.rb +9 -8
  29. data/spec/optimistic_persistence_spec.rb +2 -2
  30. data/spec/phrase_spec.rb +45 -49
  31. data/spec/session_timeout_spec.rb +1 -1
  32. data/spec/spec_helper.rb +66 -24
  33. data/spec/text_collection_spec.rb +23 -25
  34. data/spec/text_spec.rb +8 -8
  35. data/spec/unrestful_authentication_spec.rb +2 -2
  36. data/spec/user_logger_spec.rb +1 -0
  37. data/spec/user_spec.rb +5 -8
  38. metadata +37 -19
@@ -52,7 +52,20 @@ module Ixtlan
52
52
  alias :to_x :to_xml_document
53
53
  def to_xml_document(opts, doc = nil)
54
54
  unless(opts[:methods] || opts[:exclude])
55
- opts.merge!({:methods => [:updated_by, :locales], :exclude => [:updated_by_id, :id]})
55
+ opts.merge!({
56
+ :skip_types => true,
57
+ :skip_empty_tags => true,
58
+ :methods => [:updated_by, :locales],
59
+ :updated_by => {
60
+ :methods => [],
61
+ :exclude => [:created_at, :updated_at, :hashed_password, :created_by_id, :updated_by_id, :language]
62
+ },
63
+ :locales => {
64
+ :methods => [],
65
+ :exclude => [:created_at]
66
+ },
67
+ :exclude => [:updated_by_id, :id]
68
+ })
56
69
  end
57
70
  to_x(opts, doc)
58
71
  end
@@ -27,7 +27,20 @@ module Ixtlan
27
27
 
28
28
  alias :to_x :to_xml_document
29
29
  def to_xml_document(opts, doc = nil)
30
- opts.merge!({:methods => [:locales, :domains], :exclude => [:created_by_id]})
30
+ unless(opts[:methods])
31
+ opts.merge!({
32
+ :skip_types => true,
33
+ :skip_empty_tags => true,
34
+ :methods => [:created_by],
35
+ :created_by => {
36
+ :methods => [],
37
+ :exclude => [:created_at, :updated_at, :hashed_password, :created_by_id, :updated_by_id, :language]
38
+ }
39
+ })
40
+ end
41
+ unless(opts[:exclude])
42
+ opts.merge!({:exclude => [:created_by_id]})
43
+ end
31
44
  to_x(opts, doc)
32
45
  end
33
46
  end
@@ -3,6 +3,10 @@ module Ixtlan
3
3
  module Models
4
4
  module I18nText
5
5
 
6
+ unless const_defined? "TEXT_LOCALE"
7
+ TEXT_LOCALE = Object.full_const_get(Models::LOCALE)
8
+ end
9
+
6
10
  def invariant
7
11
  no_version = original_attributes[:version].nil? && attribute_get(:version).nil?
8
12
  if no_version
@@ -38,9 +42,9 @@ module Ixtlan
38
42
  size =
39
43
  case locale.code.size
40
44
  when 2
41
- self.model.latest_approved(:code => code, :locale => Locale.default).size
45
+ self.model.latest_approved(:code => code, :locale => TEXT_LOCALE.default).size
42
46
  when 5
43
- self.model.latest_approved(:code => code, :locale => Locale.first(:code => locale.code[0,1])).size
47
+ self.model.latest_approved(:code => code, :locale => TEXT_LOCALE.first(:code => locale.code[0,1])).size
44
48
  else
45
49
  1
46
50
  end
@@ -8,6 +8,11 @@ module Ixtlan
8
8
  "Phrase"
9
9
  end
10
10
 
11
+ unless const_defined? "LOCALE"
12
+ LOCALE = Object.full_const_get(Models::LOCALE)
13
+ TEXT = Object.full_const_get(Models::TEXT)
14
+ end
15
+
11
16
  property :id, Serial
12
17
 
13
18
  property :code, String, :required => true, :length => 64
@@ -22,9 +27,9 @@ module Ixtlan
22
27
 
23
28
  belongs_to :locale, :model => Models::LOCALE
24
29
 
25
- belongs_to :default_translation, :model => Models::TRANSLATION, :required => false
30
+ belongs_to :default_translation, :model => Translation, :required => false
26
31
 
27
- belongs_to :parent_translation, :model => Models::TRANSLATION, :required => false
32
+ belongs_to :parent_translation, :model => Translation, :required => false
28
33
 
29
34
  alias :to_x :to_xml_document
30
35
  def to_xml_document(opts = {}, doc = nil)
@@ -35,12 +40,12 @@ module Ixtlan
35
40
  def self.all(args = {})
36
41
  phrases = ::DataMapper::Collection.new(::DataMapper::Query.new(self.repository, Ixtlan::Models::Phrase), [])
37
42
  map = {}
38
- locale = (args[:locale] ||= Locale.default)
39
- I18nText.not_approved(args.dup).each do |text|
43
+ locale = args[:locale] || LOCALE.default
44
+ TEXT.not_approved(args.dup).each do |text|
40
45
  phrase = Phrase.new(:code => text.code, :text => text.text, :current_text => text.text, :locale => locale, :updated_at => text.updated_at, :updated_by => text.updated_by)
41
46
  map[phrase.code] = phrase
42
47
  end
43
- I18nText.latest_approved(args.dup).each do |text|
48
+ TEXT.latest_approved(args.dup).each do |text|
44
49
  if (phrase = map[text.code])
45
50
  phrase.current_text = text.text
46
51
  else
@@ -51,7 +56,7 @@ module Ixtlan
51
56
  case locale.code.size
52
57
  when 2
53
58
  params = args.dup
54
- params[:locale] = Locale.default
59
+ params[:locale] = LOCALE.default
55
60
  Translation.map_for(params).each do |code, trans|
56
61
  ph = map[code]
57
62
  if(ph.nil?)
@@ -18,12 +18,16 @@ module Ixtlan
18
18
 
19
19
  belongs_to :approved_by, :model => Models::USER
20
20
 
21
+ unless const_defined? "TEXT"
22
+ TEXT = Object.full_const_get(Models::TEXT)
23
+ end
24
+
21
25
  def self.map_for(args = {})
22
26
  map = {}
23
- I18nText.latest_approved(args.dup).each do |text|
27
+ TEXT.latest_approved(args.dup).each do |text|
24
28
  map[text.code] = Translation.create(:text => text.text, :approved_at => text.approved_at, :approved_by => text.approved_by)
25
29
  end
26
- I18nText.second_latest_approved(args.dup).each do |text|
30
+ TEXT.second_latest_approved(args.dup).each do |text|
27
31
  translation = map[text.code]
28
32
  translation.previous_text = text.text
29
33
  end
@@ -194,8 +194,35 @@ module Ixtlan
194
194
  protected
195
195
 
196
196
  def to_xml_document(opts={}, doc = nil)
197
- unless(opts[:methods] || opts[:exclude])
198
- opts.merge!({:exclude => [:hashed_password], :methods => [:groups]})
197
+ unless(opts[:methods])
198
+ opts.merge!({
199
+ :skip_types => true,
200
+ :skip_empty_tags => true,
201
+ :methods => [:groups, :created_by, :updated_by],
202
+ :groups => {
203
+ :exclude => [:created_at, :created_by_id],
204
+ :methods => [:locales, :domains],
205
+ :locales => {
206
+ :methods => [],
207
+ :exclude => [:created_at]
208
+ },
209
+ :domains => {
210
+ :methods => [],
211
+ :exclude => [:created_at]
212
+ }
213
+ },
214
+ :created_by => {
215
+ :methods => [],
216
+ :exclude => [:created_at, :updated_at, :hashed_password, :created_by_id, :updated_by_id, :language]
217
+ },
218
+ :updated_by => {
219
+ :methods => [],
220
+ :exclude => [:created_at, :updated_at, :hashed_password, :created_by_id, :updated_by_id, :language]
221
+ }
222
+ })
223
+ end
224
+ unless(opts[:exclude])
225
+ opts.merge!({:exclude => [:hashed_password, :created_by_id, :updated_by_id]})
199
226
  end
200
227
  to_x(opts, doc)
201
228
  end
@@ -6,8 +6,7 @@ module Ixtlan
6
6
 
7
7
  MODIFIED_BY_PROPERTIES = {
8
8
  :updated_by => lambda {|r, u| r.updated_by = u},
9
- :created_by => lambda {|r, u| r.created_by = u #if r.new?
10
- }
9
+ :created_by => lambda {|r, u| r.created_by = u if r.new? }
11
10
  }.freeze
12
11
 
13
12
  def self.included(model)
@@ -37,7 +37,7 @@ module Ixtlan
37
37
  end
38
38
 
39
39
  def render_error_page(status)
40
- render :template => "sessions/error", :status => status
40
+ render :template => "errors/error", :status => status
41
41
  end
42
42
 
43
43
  def page_not_found(exception)
@@ -1,3 +1,3 @@
1
1
  module Ixtlan
2
- VERSION = '0.4.0.pre5'.freeze
2
+ VERSION = '0.4.0'.freeze
3
3
  end
File without changes
@@ -3,28 +3,35 @@ require 'pathname'
3
3
  require Pathname(__FILE__).dirname + 'spec_helper.rb'
4
4
 
5
5
 
6
- require 'ixtlan' / 'models' / 'authentication'
6
+ require 'ixtlan/models/authentication'
7
+
8
+ class Authentication
9
+ include Ixtlan::Models::Authentication
10
+ end
7
11
 
8
12
  describe Ixtlan::Models::Authentication do
9
13
 
10
14
  before :each do
11
15
  #Ixtlan::Models::Group.all.destroy!
12
16
  #Ixtlan::Models::User.all.destroy!
13
- user = Ixtlan::Models::User.new(:login => "marvin2", :name => 'marvin the robot', :email=> "marvin@universe.example.com", :language => "xx", :id => 1356, :created_at => DateTime.now, :updated_at => DateTime.now)
14
- user.created_by_id = 1356
15
- user.updated_by_id = 1356
17
+ user = User.new(:login => "marvin2", :name => 'marvin the robot', :email=> "marvin@universe.example.com", :language => "xx", :id => 1356, :created_at => DateTime.now, :updated_at => DateTime.now)
18
+ user.created_by = user #_id = 1356
19
+ user.updated_by = user #_id = 1356
16
20
  user.save!
17
- group = Ixtlan::Models::Group.create(:id => 1356, :name => 'marvin2_root', :current_user => user)
21
+ group = Group.create(:id => 1356, :name => 'marvin2_root', :current_user => user)
18
22
  user.groups << group
19
23
  group.save
20
- group.locales << Ixtlan::Models::Locale.default
21
- group.locales << Ixtlan::Models::Locale.first_or_create(:code => "en")
22
- @authentication = Ixtlan::Models::Authentication.create(:login => user.login, :user => user)
24
+
25
+ group.locales << Locale.default
26
+ group.locales << (Locale.first(:code => "en") || Locale.create(:code => "en", :current_user => User.first))
27
+ @authentication = Authentication.create(:login => user.login, :user => user)
28
+
29
+ Ixtlan::Guard.load( Slf4r::LoggerFacade.new(:root), :root, (Pathname(__FILE__).dirname + 'guards').expand_path )
23
30
  end
24
31
 
25
32
  it "should" do
26
33
  xml = @authentication.to_xml
27
- xml.gsub!(/[0-9-]{10}T[0-9+-:]{14}/, "").gsub!(/ type='[^']+'/, '').gsub!(/<created_at><\/created_at>/, "<created_at/>").gsub!(/<locale><id>[0-9]*<\/id>/, "<locale>").should == "<authentication><id>1</id><login>marvin2</login><user><id>1356</id><login>marvin2</login><name>marvin the robot</name><email>marvin@universe.example.com</email><language>xx</language><created_at/><updated_at></updated_at><created_by_id>1356</created_by_id><updated_by_id>1356</updated_by_id><groups><group><id>1356</id><name>marvin2_root</name><created_at/><created_by_id>1356</created_by_id><updated_by_id>1356</updated_by_id><locales><locale><code>DEFAULT</code><created_at/></locale><locale><code>en</code><created_at/></locale></locales></group></groups></user></authentication>"
34
+ xml.gsub!(/[0-9-]{10}T[0-9+-:]{14}/, "").gsub!(/<created_at><\/created_at>/, "<created_at/>").gsub!(/<locale><id>[0-9]*<\/id>/, "<locale>").gsub!(/<permission>.*<\/permission>/, '').gsub(/id>[0-9]+<\//,'id></').should == "<authentication><login>marvin2</login><user><id></id><login>marvin2</login><name>marvin the robot</name><email>marvin@universe.example.com</email><language>xx</language><created_at/><updated_at></updated_at><groups><group><id></id><name>marvin2_root</name><locales><locale><code>DEFAULT</code><created_by_id></created_by_id></locale><locale><code>en</code><created_by_id></created_by_id></locale></locales></group></groups><created_by><id></id><login>marvin2</login><name>marvin the robot</name><email>marvin@universe.example.com</email></created_by><updated_by><id></id><login>marvin2</login><name>marvin the robot</name><email>marvin@universe.example.com</email></updated_by></user><permissions></permissions></authentication>"
28
35
  end
29
36
 
30
37
  end
data/spec/guard_spec.rb CHANGED
@@ -50,6 +50,7 @@ describe Ixtlan::Guard do
50
50
  @controller = Controller.new
51
51
  @widget = Erector::Widget.new
52
52
  @widget.controller = @controller
53
+ Locale.first(:code => "en") || Locale.create(:code => "en", :current_user => User.first)
53
54
  end
54
55
 
55
56
  it 'should export permissions' do
@@ -65,11 +66,11 @@ describe Ixtlan::Guard do
65
66
  end
66
67
 
67
68
  it 'should allow with locale' do
68
- Ixtlan::Guard.check(@controller, :permissions, :update, Ixtlan::Models::Locale.first_or_create(:code => "en")).should be_true
69
+ Ixtlan::Guard.check(@controller, :permissions, :update, Locale.first_or_create(:code => "en")).should be_true
69
70
  end
70
71
 
71
72
  it 'should disallow with locale' do
72
- Ixtlan::Guard.check(@controller, :configurations, :update, Ixtlan::Models::Locale.first_or_create(:code => "en")).should be_false
73
+ Ixtlan::Guard.check(@controller, :configurations, :update, Locale.first_or_create(:code => "en")).should be_false
73
74
  end
74
75
 
75
76
  it 'should raise GuardException on unknown controller' do
@@ -98,28 +99,28 @@ describe Ixtlan::Guard do
98
99
  @controller.params[:action] = :update
99
100
  @controller.params[:controller] = :permissions
100
101
 
101
- @controller.send(:guard, Ixtlan::Models::Locale.first_or_create(:code => "en")).should be_true
102
+ @controller.send(:guard, Locale.first_or_create(:code => "en")).should be_true
102
103
  end
103
104
 
104
105
  it 'should deny permission with right locale' do
105
106
  @controller.params[:action] = :update
106
107
  @controller.params[:controller] = :configurations
107
108
 
108
- lambda {@controller.send(:guard, Ixtlan::Models::Locale.first_or_create(:code => "en"))}.should raise_error( Ixtlan::PermissionDenied)
109
+ lambda {@controller.send(:guard, Locale.first_or_create(:code => "en"))}.should raise_error( Ixtlan::PermissionDenied)
109
110
  end
110
111
 
111
112
  it 'should deny permission with wrong locale' do
112
113
  @controller.params[:action] = :update
113
114
  @controller.params[:controller] = :permissions
114
115
 
115
- lambda {@controller.send(:guard, Ixtlan::Models::Locale.first_or_create(:code => "de"))}.should raise_error( Ixtlan::PermissionDenied)
116
+ lambda {@controller.send(:guard, Locale.first(:code => "de")||Locale.create(:code => "de", :current_user => User.first))}.should raise_error( Ixtlan::PermissionDenied)
116
117
  end
117
118
 
118
119
  it 'should allow with locale' do
119
- @widget.send(:allowed, :permissions, :update, Ixtlan::Models::Locale.first_or_create(:code => "en")).should be_true
120
+ @widget.send(:allowed, :permissions, :update, Locale.first_or_create(:code => "en")).should be_true
120
121
  end
121
122
 
122
123
  it 'should deny permission with locale' do
123
- @widget.send(:allowed, :configurations, :update, Ixtlan::Models::Locale.first_or_create(:code => "en")).should be_false
124
+ @widget.send(:allowed, :configurations, :update, Locale.first_or_create(:code => "en")).should be_false
124
125
  end
125
126
  end
@@ -1,8 +1,8 @@
1
1
  require 'pathname'
2
2
  require Pathname(__FILE__).dirname + 'spec_helper.rb'
3
- require 'ixtlan' / 'modified_by'
3
+ require 'ixtlan/modified_by'
4
4
 
5
- class User
5
+ class Crew
6
6
  include DataMapper::Resource
7
7
 
8
8
  property :login, String, :key => true
@@ -15,14 +15,14 @@ class AuditedName
15
15
  property :id, Serial
16
16
  property :name, String, :length => 2..255#, :key => true
17
17
 
18
- modified_by User
18
+ modified_by Crew
19
19
  end
20
20
 
21
21
  describe Ixtlan::ModifiedBy do
22
22
 
23
23
  before :each do
24
- @user = User.create(:login => 'spock')
25
- @second = User.create(:login => 'dr pill')
24
+ @user = Crew.create(:login => 'spock')
25
+ @second = Crew.create(:login => 'dr pille')
26
26
  @name = AuditedName.create(:name => 'kirk', :current_user => @user)
27
27
  end
28
28
 
@@ -42,10 +42,11 @@ describe Ixtlan::ModifiedBy do
42
42
  end
43
43
 
44
44
  it 'should modify updated_by on change' do
45
+ created_by = @name.created_by
45
46
  @name.current_user = @second
46
47
  @name.name = "scotty"
47
48
  @name.save.should be_true
48
- @name.created_by.should == @user
49
+ @name.created_by.should == created_by
49
50
  @name.updated_by.should == @second
50
51
  end
51
52
 
@@ -56,8 +57,8 @@ describe Ixtlan::ModifiedBy do
56
57
  end
57
58
 
58
59
  it 'should not modify updated_by on update without change' do
59
- @name.update(:name => "kirk", :current_user => @second)
60
- @name.updated_by.should == @user
60
+ @name.update(:name => "kirk updated", :current_user => @second)
61
+ @name.updated_by.should == @second
61
62
  @name.instance_variable_get(:@current_user).should be_nil
62
63
  end
63
64
 
@@ -38,7 +38,7 @@ describe "Ixtlan::OptimisticPersistence" do
38
38
  sleep 1
39
39
  @name.save.should be_true
40
40
  @second.name = "saroman"
41
- lambda { @second.save }.should raise_error(DataMapper::StaleResourceError)
41
+ lambda { @second.save }.should raise_error(Ixtlan::StaleResourceError)
42
42
  end
43
43
 
44
44
  it 'should fail on key change' do
@@ -46,7 +46,7 @@ describe "Ixtlan::OptimisticPersistence" do
46
46
  @name.id = 11
47
47
  @name.save.should be_true
48
48
  @second.id = 111
49
- lambda { @second.save }.should raise_error(DataMapper::StaleResourceError)
49
+ lambda { @second.save }.should raise_error(Ixtlan::StaleResourceError)
50
50
  end
51
51
 
52
52
  it 'should treat non optimistic resources as usual' do
data/spec/phrase_spec.rb CHANGED
@@ -3,9 +3,6 @@ require Pathname(__FILE__).dirname + 'spec_helper.rb'
3
3
 
4
4
  require Pathname(__FILE__).dirname + '../lib/dm-serializer/to_xml'
5
5
 
6
-
7
- require 'ixtlan/controllers/texts_controller'
8
-
9
6
  require 'ixtlan/models/i18n_text'
10
7
  require 'ixtlan/models/word'
11
8
  require 'ixtlan/models/translation'
@@ -13,23 +10,22 @@ require 'ixtlan/models/phrase'
13
10
 
14
11
  def setup(code)
15
12
  len = 6
16
- Controller.send(:include, Ixtlan::Controllers::TextsController)
17
- Ixtlan::Models::I18nText.all.destroy!
18
- Ixtlan::Models::Locale.all.destroy!
19
- Ixtlan::Models::Locale.first_or_create(:id => 1, :code => "DEFAULT")
20
- @controller2 = Controller.new
21
- @en = Ixtlan::Models::Locale.first_or_create(:id => 1000, :code => "en")
22
- @en_in = Ixtlan::Models::Locale.first_or_create(:id => 2000, :code => "en_IN")
13
+ @current_user = User.first
14
+ I18nText.all.destroy!
15
+ Locale.all.destroy!
16
+ Locale.create(:id => 1, :code => "DEFAULT", :current_user => @current_user)
17
+ @en = Locale.create(:id => 1000, :code => "en", :current_user => @current_user)
18
+ @en_in = Locale.create(:id => 2000, :code => "en_IN", :current_user => @current_user)
23
19
  (1..len).each do |j|
24
- text = Ixtlan::Models::I18nText.create(:id => j,
25
- :code => code,
26
- :text => "text_#{j}",
27
- :current_user => @controller2.current_user,
28
- :locale => Ixtlan::Models::Locale.default,
29
- :updated_at => DateTime.now,
30
- :updated_by => @controller2.current_user)
31
-
32
- text.approve(:current_user => @controller2.current_user)
20
+ text = I18nText.create(:id => j,
21
+ :code => code,
22
+ :text => "text_#{j}",
23
+ :current_user => @current_user,
24
+ :locale => Locale.default,
25
+ :updated_at => DateTime.now,
26
+ :updated_by => @current_user)
27
+
28
+ text.approve(:current_user => @current_user)
33
29
  end
34
30
  end
35
31
 
@@ -42,7 +38,7 @@ describe "with default locale" do
42
38
  end
43
39
  it "should xml-serialize" do
44
40
  #Ixtlan::Models::I18nText.all.each {|t| p t}
45
- Ixtlan::Models::Phrase.all(:code => "cccc_1").to_xml.cleanup.should == "<phrases><phrase><code>cccc_1</code><text>text_6</text><current_text>text_6</current_text><updated_at>date</updated_at><updated_by_id>1</updated_by_id><locale><id>1</id><code>DEFAULT</code><created_at>date</created_at></locale></phrase></phrases>"
41
+ Ixtlan::Models::Phrase.all(:code => "cccc_1").to_xml.cleanup.should == "<phrases><phrase><code>cccc_1</code><text>text_6</text><current_text>text_6</current_text><updated_at>date</updated_at><updated_by_id>1</updated_by_id><locale><id>1</id><code>DEFAULT</code><created_at>date</created_at><created_by_id>1</created_by_id></locale></phrase></phrases>"
46
42
  end
47
43
  end
48
44
 
@@ -51,32 +47,32 @@ describe "with default locale" do
51
47
  setup("cccc_2")
52
48
  end
53
49
  it "should xml-serialize with edited text" do
54
- Ixtlan::Models::I18nText.create(:code => "cccc_2",
55
- :text => "text_edited",
56
- :current_user => @controller2.current_user,
57
- :locale => Ixtlan::Models::Locale.default,
58
- :updated_at => DateTime.now,
59
- :updated_by => @controller2.current_user)
50
+ I18nText.create(:code => "cccc_2",
51
+ :text => "text_edited",
52
+ :current_user => @current_user,
53
+ :locale => Locale.default,
54
+ :updated_at => DateTime.now,
55
+ :updated_by => @current_user)
60
56
  # Ixtlan::Models::I18nText.all.each {|t| p t}
61
- Ixtlan::Models::Phrase.all(:code => "cccc_2").to_xml.cleanup.should == "<phrases><phrase><code>cccc_2</code><text>text_edited</text><current_text>text_6</current_text><updated_at>date</updated_at><updated_by_id>1</updated_by_id><locale><id>1</id><code>DEFAULT</code><created_at>date</created_at></locale></phrase></phrases>"
57
+ Ixtlan::Models::Phrase.all(:code => "cccc_2").to_xml.cleanup.should == "<phrases><phrase><code>cccc_2</code><text>text_edited</text><current_text>text_6</current_text><updated_at>date</updated_at><updated_by_id>1</updated_by_id><locale><id>1</id><code>DEFAULT</code><created_at>date</created_at><created_by_id>1</created_by_id></locale></phrase></phrases>"
62
58
  end
63
59
 
64
60
  end
65
61
  describe "with default locale" do
66
62
  before(:each) do
67
63
  setup("cccc_3")
68
- Ixtlan::Models::I18nText.all.destroy!
64
+ I18nText.all.destroy!
69
65
  end
70
66
 
71
67
  it "should xml-serialize with edited text and not approved" do
72
- Ixtlan::Models::I18nText.create(:code => "cccc_3",
73
- :text => "text_edited",
74
- :current_user => @controller2.current_user,
75
- :locale => Ixtlan::Models::Locale.default,
76
- :updated_at => DateTime.now,
77
- :updated_by => @controller2.current_user)
68
+ I18nText.create(:code => "cccc_3",
69
+ :text => "text_edited",
70
+ :current_user => @current_user,
71
+ :locale => Locale.default,
72
+ :updated_at => DateTime.now,
73
+ :updated_by => @current_user)
78
74
  #Ixtlan::Models::I18nText.all.each {|t| p t}
79
- Ixtlan::Models::Phrase.all(:code => "cccc_3").to_xml.cleanup.should == "<phrases><phrase><code>cccc_3</code><text>text_edited</text><current_text>text_edited</current_text><updated_at>date</updated_at><updated_by_id>1</updated_by_id><locale><id>1</id><code>DEFAULT</code><created_at>date</created_at></locale></phrase></phrases>"
75
+ Ixtlan::Models::Phrase.all(:code => "cccc_3").to_xml.cleanup.should == "<phrases><phrase><code>cccc_3</code><text>text_edited</text><current_text>text_edited</current_text><updated_at>date</updated_at><updated_by_id>1</updated_by_id><locale><id>1</id><code>DEFAULT</code><created_at>date</created_at><created_by_id>1</created_by_id></locale></phrase></phrases>"
80
76
  end
81
77
  end
82
78
 
@@ -86,7 +82,7 @@ describe "with 'de' locale" do
86
82
  end
87
83
  it "should xml-serialize" do
88
84
  #Ixtlan::Models::I18nText.all.each {|t| p t}
89
- Ixtlan::Models::Phrase.all(:code => "de_code", :locale => Ixtlan::Models::Locale.first_or_create(:id => 3000, :code => 'de')).to_xml.cleanup.should == "<phrases><phrase><code>de_code</code><text>text_6</text><current_text>text_6</current_text><updated_at>date</updated_at><updated_by_id>1</updated_by_id><default_translation><text>text_6</text><previous_text>text_5</previous_text><approved_at>date</approved_at><approved_by_id>1</approved_by_id></default_translation><locale><id>3000</id><code>de</code><created_at>date</created_at></locale></phrase></phrases>"
85
+ Ixtlan::Models::Phrase.all(:code => "de_code", :locale => Locale.first(:id => 3000, :code => 'de') || Locale.create(:id => 3000, :code => 'de', :current_user => @current_user)).to_xml.cleanup.should == "<phrases><phrase><code>de_code</code><text>text_6</text><current_text>text_6</current_text><updated_at>date</updated_at><updated_by_id>1</updated_by_id><default_translation><text>text_6</text><previous_text>text_5</previous_text><approved_at>date</approved_at><approved_by_id>1</approved_by_id></default_translation><locale><id>3000</id><code>de</code><created_at>date</created_at><created_by_id>1</created_by_id></locale></phrase></phrases>"
90
86
  end
91
87
  end
92
88
 
@@ -94,23 +90,23 @@ describe "with 'en' locale" do
94
90
  before(:each) do
95
91
  setup("en_code")
96
92
 
97
- Ixtlan::Models::I18nText.create(:code => "en_code",
98
- :text => "en_text_edited",
99
- :current_user => @controller2.current_user,
100
- :locale => @en,
101
- :updated_at => DateTime.now,
102
- :updated_by => @controller2.current_user)
103
- Ixtlan::Models::I18nText.create(:code => "en_code",
104
- :text => "en_in_text_edited",
105
- :current_user => @controller2.current_user,
106
- :locale => @en_in,
107
- :updated_at => DateTime.now,
108
- :updated_by => @controller2.current_user)
93
+ I18nText.create(:code => "en_code",
94
+ :text => "en_text_edited",
95
+ :current_user => @current_user,
96
+ :locale => @en,
97
+ :updated_at => DateTime.now,
98
+ :updated_by => @current_user)
99
+ I18nText.create(:code => "en_code",
100
+ :text => "en_in_text_edited",
101
+ :current_user => @current_user,
102
+ :locale => @en_in,
103
+ :updated_at => DateTime.now,
104
+ :updated_by => @current_user)
109
105
  end
110
106
 
111
107
  it "should xml-serialize with edited text" do
112
108
  #Ixtlan::Models::I18nText.all(:code => "en_code").each {|t| puts "code=#{t.code} locale=#{t.locale.code} version=#{t.version} current=#{t.current} previous=#{t.previous}"}
113
- Ixtlan::Models::Phrase.all(:code => "en_code", :locale => @en).to_xml.cleanup.should == "<phrases><phrase><code>en_code</code><text>en_text_edited</text><current_text>en_text_edited</current_text><updated_at>date</updated_at><updated_by_id>1</updated_by_id><default_translation><text>text_6</text><previous_text>text_5</previous_text><approved_at>date</approved_at><approved_by_id>1</approved_by_id></default_translation><locale><id>1000</id><code>en</code><created_at>date</created_at></locale></phrase></phrases>"
109
+ Ixtlan::Models::Phrase.all(:code => "en_code", :locale => @en).to_xml.cleanup.should == "<phrases><phrase><code>en_code</code><text>en_text_edited</text><current_text>en_text_edited</current_text><updated_at>date</updated_at><updated_by_id>1</updated_by_id><default_translation><text>text_6</text><previous_text>text_5</previous_text><approved_at>date</approved_at><approved_by_id>1</approved_by_id></default_translation><locale><id>1000</id><code>en</code><created_at>date</created_at><created_by_id>1</created_by_id></locale></phrase></phrases>"
114
110
  end
115
111
 
116
112
  end
@@ -10,7 +10,7 @@ end
10
10
  describe Ixtlan::Rails::SessionTimeout do
11
11
 
12
12
  before :each do
13
- Ixtlan::Models::User.all.destroy!
13
+ User.all.destroy!
14
14
  @controller = Controller.new
15
15
  @log = StringIO.new
16
16
  Slf4r::LoggerFacade4RubyLogger.file = @log