Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 62 lines (48 sloc) 1.597 kb
8105853 Jason Garber Use nested attributes to save, reorder attachments. Test with cucumber ...
jgarber authored
1 require File.expand_path(File.join(File.dirname(__FILE__), "..", "support", "paths"))
2
3 Given /^I am logged in as (.*)(?: user)?$/ do |username|
4 visit login_path
5 fill_in "Username", :with => username
6 fill_in "Password", :with => "password"
7 click_button "Login"
8 end
9
10 Given /^I have a page$/ do
11 @page = pages(:home)
12 end
13
14 Given /^I have a page with (\d+) attachments$/ do |number|
15 Given "I have a page"
16 @page.attachments.length.should == number.to_i
17 end
18
19 Given /^I have a page with no attachments$/ do
20 @page = pages(:first)
21 @page.attachments.should be_empty
22 end
23
24 When /^I edit the page$/ do
25 visit edit_admin_page_path(@page)
26 end
27
28 When /^I click the plus icon$/ do
29 selenium.click "xpath=id('attachments')//img[@alt='Add']"
30 end
31
32 When /^I attach the Rails logo$/ do
33 attach_file "file_input", "#{PageAttachmentsExtension.root}/spec/fixtures/rails.png"
34 end
35
36 When /^I delete the first attachment$/ do
37 selenium.click "xpath=id('attachment_list')/li[1]//img[@alt='Delete']"
38 end
39
40 When /^I drag attachment 2 above attachment 1$/ do
41 @attachment = @page.attachments[1]
42 @attachment.position.should == 2
43 selenium.dragdrop("id=attachment_#{@attachment.id}", "0, -200")
44 end
45
46 When /^I save$/ do
47 click_button "Save"
48 response.should_not contain("errors")
49 end
50
51 Then /^the page should have a new attachment$/ do
52 @page.reload.attachments.should_not be_empty
53 end
54
55 Then /^the page should have (\d+) attachment(?:s)?$/ do |number|
56 @page.reload.attachments.length.should == number.to_i
57 end
58
59 Then /^attachment 2 should be in position 1$/ do
60 @attachment.reload.position.should == 1
61 end
Something went wrong with that request. Please try again.