| 98 | | assert v.send(:compile_template?, nil, @a, {}) |
|---|
| 99 | | assert v.send(:compile_template?, nil, @b, {}) |
|---|
| 100 | | assert v.send(:compile_template?, nil, @s, {}) unless windows |
|---|
| | 93 | # private methods template_changed_since? and compile_template? |
|---|
| | 94 | # should report true for all since they have not been compiled |
|---|
| | 95 | assert v.send(:template_changed_since?, @a, t) |
|---|
| | 96 | assert v.send(:template_changed_since?, @b, t) |
|---|
| | 97 | assert v.send(:template_changed_since?, @s, t) unless windows |
|---|
| 104 | | # All templates are rendered at t+2 |
|---|
| 105 | | Time.expects(:now).times(windows ? 2 : 3).returns(t + 2.seconds) |
|---|
| 106 | | v.send(:compile_and_render_template, @handler, '', @a) |
|---|
| 107 | | v.send(:compile_and_render_template, @handler, '', @b) |
|---|
| 108 | | v.send(:compile_and_render_template, @handler, '', @s) unless windows |
|---|
| 109 | | a_n = v.method_names[@a] |
|---|
| 110 | | b_n = v.method_names[@b] |
|---|
| 111 | | s_n = v.method_names[@s] unless windows |
|---|
| 112 | | # all of the files have changed since last compile |
|---|
| 113 | | assert v.compile_time[a_n] > t |
|---|
| 114 | | assert v.compile_time[b_n] > t |
|---|
| 115 | | assert v.compile_time[s_n] > t unless windows |
|---|
| | 103 | @handler_class = ActionView::Base.handler_class_for_extension(:rhtml) |
|---|
| | 104 | @handler = @handler_class.new(v) |
|---|
| | 105 | # All templates are rendered at t+2 |
|---|
| | 106 | Time.expects(:now).times(windows ? 2 : 3).returns(t + 2.seconds) |
|---|
| | 107 | v.send(:compile_and_render_template, @handler, '', @a) |
|---|
| | 108 | v.send(:compile_and_render_template, @handler, '', @b) |
|---|
| | 109 | v.send(:compile_and_render_template, @handler, '', @s) unless windows |
|---|
| | 110 | a_n = v.method_names[@a] |
|---|
| | 111 | b_n = v.method_names[@b] |
|---|
| | 112 | s_n = v.method_names[@s] unless windows |
|---|
| | 113 | # all of the files have changed since last compile |
|---|
| | 114 | assert v.compile_time[a_n] > t |
|---|
| | 115 | assert v.compile_time[b_n] > t |
|---|
| | 116 | assert v.compile_time[s_n] > t unless windows |
|---|
| 117 | | # private methods template_changed_since? and compile_template? |
|---|
| 118 | | # should report false for all since none have changed since compile |
|---|
| 119 | | File::Stat.any_instance.expects(:mtime).times(windows ? 6 : 12).returns(t + 1.second) |
|---|
| 120 | | assert !v.send(:template_changed_since?, @a, v.compile_time[a_n]) |
|---|
| 121 | | assert !v.send(:template_changed_since?, @b, v.compile_time[b_n]) |
|---|
| 122 | | assert !v.send(:template_changed_since?, @s, v.compile_time[s_n]) unless windows |
|---|
| 123 | | assert !v.send(:compile_template?, nil, @a, {}) |
|---|
| 124 | | assert !v.send(:compile_template?, nil, @b, {}) |
|---|
| 125 | | assert !v.send(:compile_template?, nil, @s, {}) unless windows |
|---|
| 126 | | v.send(:compile_and_render_template, @handler, '', @a) |
|---|
| 127 | | v.send(:compile_and_render_template, @handler, '', @b) |
|---|
| 128 | | v.send(:compile_and_render_template, @handler, '', @s) unless windows |
|---|
| 129 | | # none of the files have changed since last compile |
|---|
| 130 | | assert v.compile_time[a_n] < t + 3.seconds |
|---|
| 131 | | assert v.compile_time[b_n] < t + 3.seconds |
|---|
| 132 | | assert v.compile_time[s_n] < t + 3.seconds unless windows |
|---|
| | 118 | # private methods template_changed_since? and compile_template? |
|---|
| | 119 | # should report false for all since none have changed since compile |
|---|
| | 120 | File::Stat.any_instance.expects(:mtime).times(windows ? 6 : 12).returns(t + 1.second) |
|---|
| | 121 | assert !v.send(:template_changed_since?, @a, v.compile_time[a_n]) |
|---|
| | 122 | assert !v.send(:template_changed_since?, @b, v.compile_time[b_n]) |
|---|
| | 123 | assert !v.send(:template_changed_since?, @s, v.compile_time[s_n]) unless windows |
|---|
| | 124 | assert !v.send(:compile_template?, nil, @a, {}) |
|---|
| | 125 | assert !v.send(:compile_template?, nil, @b, {}) |
|---|
| | 126 | assert !v.send(:compile_template?, nil, @s, {}) unless windows |
|---|
| | 127 | v.send(:compile_and_render_template, @handler, '', @a) |
|---|
| | 128 | v.send(:compile_and_render_template, @handler, '', @b) |
|---|
| | 129 | v.send(:compile_and_render_template, @handler, '', @s) unless windows |
|---|
| | 130 | # none of the files have changed since last compile |
|---|
| | 131 | assert v.compile_time[a_n] < t + 3.seconds |
|---|
| | 132 | assert v.compile_time[b_n] < t + 3.seconds |
|---|
| | 133 | assert v.compile_time[s_n] < t + 3.seconds unless windows |
|---|
| 138 | | # t + 3.seconds is for the symlink |
|---|
| 139 | | File::Stat.any_instance.expects(:mtime).times(windows ? 6 : 9).returns( |
|---|
| 140 | | *(windows ? [ t + 1.second, t + 1.second ] : |
|---|
| 141 | | [ t + 1.second, t + 1.second, t + 3.second ]) * 3) |
|---|
| 142 | | assert !v.send(:template_changed_since?, @a, v.compile_time[a_n]) |
|---|
| 143 | | assert !v.send(:template_changed_since?, @b, v.compile_time[b_n]) |
|---|
| 144 | | assert v.send(:template_changed_since?, @s, v.compile_time[s_n]) unless windows |
|---|
| 145 | | assert !v.send(:compile_template?, nil, @a, {}) |
|---|
| 146 | | assert !v.send(:compile_template?, nil, @b, {}) |
|---|
| 147 | | assert v.send(:compile_template?, nil, @s, {}) unless windows |
|---|
| | 139 | # t + 3.seconds is for the symlink |
|---|
| | 140 | File::Stat.any_instance.expects(:mtime).times(windows ? 6 : 9).returns( |
|---|
| | 141 | *(windows ? [ t + 1.second, t + 1.second ] : |
|---|
| | 142 | [ t + 1.second, t + 1.second, t + 3.second ]) * 3) |
|---|
| | 143 | assert !v.send(:template_changed_since?, @a, v.compile_time[a_n]) |
|---|
| | 144 | assert !v.send(:template_changed_since?, @b, v.compile_time[b_n]) |
|---|
| | 145 | assert v.send(:template_changed_since?, @s, v.compile_time[s_n]) unless windows |
|---|
| | 146 | assert !v.send(:compile_template?, nil, @a, {}) |
|---|
| | 147 | assert !v.send(:compile_template?, nil, @b, {}) |
|---|
| | 148 | assert v.send(:compile_template?, nil, @s, {}) unless windows |
|---|
| 149 | | # Only the symlink template gets rendered at t+3 |
|---|
| 150 | | Time.stubs(:now).returns(t + 3.seconds) unless windows |
|---|
| 151 | | v.send(:compile_and_render_template, @handler, '', @a) |
|---|
| 152 | | v.send(:compile_and_render_template, @handler, '', @b) |
|---|
| 153 | | v.send(:compile_and_render_template, @handler, '', @s) unless windows |
|---|
| 154 | | # the symlink has changed since last compile |
|---|
| 155 | | assert v.compile_time[a_n] < t + 3.seconds |
|---|
| 156 | | assert v.compile_time[b_n] < t + 3.seconds |
|---|
| 157 | | assert_equal v.compile_time[s_n], t + 3.seconds unless windows |
|---|
| | 150 | # Only the symlink template gets rendered at t+3 |
|---|
| | 151 | Time.stubs(:now).returns(t + 3.seconds) unless windows |
|---|
| | 152 | v.send(:compile_and_render_template, @handler, '', @a) |
|---|
| | 153 | v.send(:compile_and_render_template, @handler, '', @b) |
|---|
| | 154 | v.send(:compile_and_render_template, @handler, '', @s) unless windows |
|---|
| | 155 | # the symlink has changed since last compile |
|---|
| | 156 | assert v.compile_time[a_n] < t + 3.seconds |
|---|
| | 157 | assert v.compile_time[b_n] < t + 3.seconds |
|---|
| | 158 | assert_equal v.compile_time[s_n], t + 3.seconds unless windows |
|---|
| 159 | | FileUtils.touch @b |
|---|
| 160 | | # private methods template_changed_since? and compile_template? |
|---|
| 161 | | # should report true for symlink and file at end of symlink |
|---|
| 162 | | # since it has changed since last compile |
|---|
| 163 | | # |
|---|
| 164 | | # t+4 is for @b and also for the file that @s points to, which is @b |
|---|
| 165 | | File::Stat.any_instance.expects(:mtime).times(windows ? 6 : 12).returns( |
|---|
| 166 | | *(windows ? [ t + 1.second, t + 4.seconds ] : |
|---|
| 167 | | [ t + 1.second, t + 4.seconds, t + 3.second, t + 4.seconds ]) * 3) |
|---|
| 168 | | assert !v.send(:template_changed_since?, @a, v.compile_time[a_n]) |
|---|
| 169 | | assert v.send(:template_changed_since?, @b, v.compile_time[b_n]) |
|---|
| 170 | | assert v.send(:template_changed_since?, @s, v.compile_time[s_n]) unless windows |
|---|
| 171 | | assert !v.send(:compile_template?, nil, @a, {}) |
|---|
| 172 | | assert v.send(:compile_template?, nil, @b, {}) |
|---|
| 173 | | assert v.send(:compile_template?, nil, @s, {}) unless windows |
|---|
| | 160 | FileUtils.touch @b |
|---|
| | 161 | # private methods template_changed_since? and compile_template? |
|---|
| | 162 | # should report true for symlink and file at end of symlink |
|---|
| | 163 | # since it has changed since last compile |
|---|
| | 164 | # |
|---|
| | 165 | # t+4 is for @b and also for the file that @s points to, which is @b |
|---|
| | 166 | File::Stat.any_instance.expects(:mtime).times(windows ? 6 : 12).returns( |
|---|
| | 167 | *(windows ? [ t + 1.second, t + 4.seconds ] : |
|---|
| | 168 | [ t + 1.second, t + 4.seconds, t + 3.second, t + 4.seconds ]) * 3) |
|---|
| | 169 | assert !v.send(:template_changed_since?, @a, v.compile_time[a_n]) |
|---|
| | 170 | assert v.send(:template_changed_since?, @b, v.compile_time[b_n]) |
|---|
| | 171 | assert v.send(:template_changed_since?, @s, v.compile_time[s_n]) unless windows |
|---|
| | 172 | assert !v.send(:compile_template?, nil, @a, {}) |
|---|
| | 173 | assert v.send(:compile_template?, nil, @b, {}) |
|---|
| | 174 | assert v.send(:compile_template?, nil, @s, {}) unless windows |
|---|
| 175 | | Time.expects(:now).times(windows ? 1 : 2).returns(t + 5.seconds) |
|---|
| 176 | | v.send(:compile_and_render_template, @handler, '', @a) |
|---|
| 177 | | v.send(:compile_and_render_template, @handler, '', @b) |
|---|
| 178 | | v.send(:compile_and_render_template, @handler, '', @s) unless windows |
|---|
| 179 | | # the file at the end of the symlink has changed since last compile |
|---|
| 180 | | # both the symlink and the file at the end of it should be recompiled |
|---|
| 181 | | assert v.compile_time[a_n] < t + 5.seconds |
|---|
| 182 | | assert_equal v.compile_time[b_n], t + 5.seconds |
|---|
| 183 | | assert_equal v.compile_time[s_n], t + 5.seconds unless windows |
|---|
| 184 | | end |
|---|
| | 176 | Time.expects(:now).times(windows ? 1 : 2).returns(t + 5.seconds) |
|---|
| | 177 | v.send(:compile_and_render_template, @handler, '', @a) |
|---|
| | 178 | v.send(:compile_and_render_template, @handler, '', @b) |
|---|
| | 179 | v.send(:compile_and_render_template, @handler, '', @s) unless windows |
|---|
| | 180 | # the file at the end of the symlink has changed since last compile |
|---|
| | 181 | # both the symlink and the file at the end of it should be recompiled |
|---|
| | 182 | assert v.compile_time[a_n] < t + 5.seconds |
|---|
| | 183 | assert_equal v.compile_time[b_n], t + 5.seconds |
|---|
| | 184 | assert_equal v.compile_time[s_n], t + 5.seconds unless windows |
|---|
| | 185 | end |
|---|