# Testing rjs redirects

**URL:** <https://www.ruby-forum.com/t/testing-rjs-redirects/154236>\
**Category:** Rails\
**Created:** [November 26, 2008, 5:21pm UTC](https://www.ruby-forum.com/t/testing-rjs-redirects/154236 "2008-11-26T17:21:39Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![mabi3b](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/3bc359/32.png) [@mabi3b](https://www.ruby-forum.com/u/mabi3b)\
**Post date:** [November 26, 2008, 5:21pm UTC](https://www.ruby-forum.com/t/testing-rjs-redirects/154236/1 "2008-11-26T17:21:39Z")

</div>

I’m trying to test the following code:

```
render :update do |page|
  @story.destroy
  flash[:status] = "Story \"#{@story.title}\" has been deleted."
  page.redirect_to request.referer
end

```

I know that assert\_redirected doesn’t work.

I found this blog post from 2006 ([http://www.caboo.se/articles/](http://www.caboo.se/articles/)  
2006/2/20/assert-yourself-man-redirecting-with-rjs) and I was  
wondering if there’s a better/different way of achieving the same

Thanks in advance,

Mauro

---

<div class="post-metadata">

**Author:** ![mabi3b](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/3bc359/32.png) [@mabi3b](https://www.ruby-forum.com/u/mabi3b)\
**Post date:** [November 26, 2008, 7:25pm UTC](https://www.ruby-forum.com/t/testing-rjs-redirects/154236/2 "2008-11-26T19:25:19Z")

</div>

On Nov 26, 3:20 pm, Mauro B. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> I’m trying to test the following code:
> 
> ```
> render :update do |page|
> @story.destroy
> flash[:status] = "Story \"#removed_email_address@domain.invalid}\" has been deleted."
> page.redirect_to request.referer
> end
> 
> ```
> 
> I know that assert\_redirected doesn’t work.

In the past i’ve used the arts plugin ([http://glu.ttono.us/articles/](http://glu.ttono.us/articles/)  
2006/05/29/guide-test-driven-rjs-with-arts) in the past.

Fred

---

<div class="post-metadata">

**Author:** ![mabi3b](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/3bc359/32.png) [@mabi3b](https://www.ruby-forum.com/u/mabi3b)\
**Post date:** [November 26, 2008, 8:25pm UTC](https://www.ruby-forum.com/t/testing-rjs-redirects/154236/3 "2008-11-26T20:25:08Z")

</div>

On 26 Nov 2008, at 18:56, Mauro B. wrote:

> The arts plug in has been incorporated into rails and I couldn’t find  
> it anywhere anymore. And as far as I know it didn’t have this  
> functionality either.

Not quite, and yes it did. The assert\_select\_rjs isn’t quite the same  
as ARTS was. better in someways, different in others.  
It could/can do assert\_rjs :redirect\_to, :action =\> ‘foo’

At the end of the day all that’s doing though is asserting that the  
output contains window.location="…"

Fred

---

<div class="post-metadata">

**Author:** ![mabi3b](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/3bc359/32.png) [@mabi3b](https://www.ruby-forum.com/u/mabi3b)\
**Post date:** [November 26, 2008, 7:57pm UTC](https://www.ruby-forum.com/t/testing-rjs-redirects/154236/4 "2008-11-26T19:57:36Z")

</div>

The arts plug in has been incorporated into rails and I couldn’t find  
it anywhere anymore. And as far as I know it didn’t have this  
functionality either.

Mauro

On Nov 26, 1:23 pm, Frederick C. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![mabi3b](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/3bc359/32.png) [@mabi3b](https://www.ruby-forum.com/u/mabi3b)\
**Post date:** [November 26, 2008, 9:13pm UTC](https://www.ruby-forum.com/t/testing-rjs-redirects/154236/5 "2008-11-26T21:13:18Z")

</div>

Thanks a lot for your response!

Where could I find arts? I see that it indeed has the capability of  
testing for :redirect\_to…

The last known location [http://thar.be/svn/projects/plugins/arts](http://thar.be/svn/projects/plugins/arts) is  
not responding anymore…

Mauro

On Nov 26, 2:24 pm, Frederick C. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![mabi3b](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/3bc359/32.png) [@mabi3b](https://www.ruby-forum.com/u/mabi3b)\
**Post date:** [November 26, 2008, 10:53pm UTC](https://www.ruby-forum.com/t/testing-rjs-redirects/154236/6 "2008-11-26T22:53:42Z")

</div>

That worked!!! Thanks a lot!

Mauro

On Nov 26, 3:56 pm, Frederick C. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![mabi3b](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/3bc359/32.png) [@mabi3b](https://www.ruby-forum.com/u/mabi3b)\
**Post date:** [November 26, 2008, 9:56pm UTC](https://www.ruby-forum.com/t/testing-rjs-redirects/154236/7 "2008-11-26T21:56:46Z")

</div>

On Nov 26, 8:12 pm, Mauro B. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Thanks a lot for your response!
> 
> Where could I find arts? I see that it indeed has the capability of  
> testing for :redirect\_to…

seems to be a copy on github:

> **[GitHub - richpoirier/arts: Mirror of the ARTS Rails plugin.](https://github.com/richpoirier/arts/tree/master)**
>
> master

Fred
