##// END OF EJS Templates
Fixed: editing a message may cause sticky attribute to be NULL (#3356)....
Jean-Philippe Lang -
r2687:7642b5a9ab18
parent child
Show More
@@ -0,0 +1,9
1 class FixMessagesStickyNull < ActiveRecord::Migration
2 def self.up
3 Message.update_all('sticky = 0', 'sticky IS NULL')
4 end
5
6 def self.down
7 # nothing to do
8 end
9 end
@@ -66,6 +66,10 class Message < ActiveRecord::Base
66 board.reset_counters!
66 board.reset_counters!
67 end
67 end
68
68
69 def sticky=(arg)
70 write_attribute :sticky, (arg == true || arg.to_s == '1' ? 1 : 0)
71 end
72
69 def sticky?
73 def sticky?
70 sticky == 1
74 sticky == 1
71 end
75 end
@@ -128,4 +128,19 class MessageTest < Test::Unit::TestCase
128 author.roles_for_project(message.project).first.remove_permission!(:delete_own_messages)
128 author.roles_for_project(message.project).first.remove_permission!(:delete_own_messages)
129 assert !message.reload.destroyable_by?(author.reload)
129 assert !message.reload.destroyable_by?(author.reload)
130 end
130 end
131
132 def test_set_sticky
133 message = Message.new
134 assert_equal 0, message.sticky
135 message.sticky = nil
136 assert_equal 0, message.sticky
137 message.sticky = false
138 assert_equal 0, message.sticky
139 message.sticky = true
140 assert_equal 1, message.sticky
141 message.sticky = '0'
142 assert_equal 0, message.sticky
143 message.sticky = '1'
144 assert_equal 1, message.sticky
145 end
131 end
146 end
General Comments 0
You need to be logged in to leave comments. Login now