Permalink
Browse files

Fix the file attachment peding issue

  • Loading branch information...
1 parent 77c0f7c commit 4f6b206c783a1e59e429c5287b41bf5886cd032b @kyungbae kyungbae committed Aug 16, 2013
Showing with 9 additions and 15 deletions.
  1. +6 −9 spec/features/create_contribution_spec.rb
  2. +3 −6 spec/features/create_post_spec.rb
@@ -58,14 +58,11 @@ def create_and_check_contribution(type, selected_item, test_upload=false)
fill_in "#{type.downcase}_details", with: "Contribution test"
if test_upload
- pending('Fila attachment issue')
- # proecedures for the upload document test. To make this test work,
- # the file field must have a label name. Otherwise, the test won't
- # find the field correctly and will be failed. To test it properly, please update the
- # file field label to 'Additional Doucments'.
- click_on 'Add Upload' if test_upload
- page.execute_script("$('.file.optional.upload').toggle();") if test_upload
- attach_file('Additional Documents', "#{Rails.root}/spec/support/Montmarte.jpg") if test_upload
+ # Since the file field doesn't have a label, attach_file can't not
+ # be used. Instead, the file path is stored manually.
+ click_on 'Add Upload'
+ page.execute_script("$('.file.optional.upload').toggle();")
+ find(".input.file.optional.#{type.downcase}_uploads_content").find('input').set("#{Rails.root}/spec/support/Montmarte.jpg")
end
click_on "Submit #{type.titleize}"
@@ -78,7 +75,7 @@ def create_and_check_contribution(type, selected_item, test_upload=false)
expect(page).to have_selector("img[src$='#{selected_item.thumbnail}']")
expect(page).to have_content("Contribution test")
if test_upload
- expect(page).to have_content('Uploaded Documents') if test_upload
+ expect(page).to have_content('Attached Documents') if test_upload
expect(page).to have_content('Montmarte.jpg') if test_upload
end
@@ -64,18 +64,15 @@
context "with javascript" do
describe "question creation with uploads" do
let(:user) { create(:user) }
-
before { sign_in(user) }
- after { sign_out }
it "creates new uploads", js: true do
- pending('file attachment issues')
visit new_post_path
-
fill_in 'post_title', with: 'a title'
page.execute_script("editor.setValue('additional details')")
click_on 'Add Upload'
- attach_file('filename' ,'spec/support/files/cow.jpg')
+ page.execute_script("$('.file.optional.upload').toggle();")
+ find(".input.file.optional.post_uploads_content").find('input').set("#{Rails.root}/spec/support/Montmarte.jpg")
click_on 'Submit'
Question.count.should == 1
@@ -84,7 +81,7 @@
page.should have_content('a title')
page.should have_content('additional details')
- page.should have_content('cow.jpg')
+ page.should have_content('Montmarte.jpg')
end
end
end

0 comments on commit 4f6b206

Please sign in to comment.