rubysherpas / r4ia

A place to file issues for Rails 4 in Action
2 stars 0 forks source link

Make changes to creating_tickets_spec scenario for "persisting file uploads..." #23

Closed biophysicsguy closed 9 years ago

radar commented 9 years ago

I am not sure what you mean by this. Can you please explain?

biophysicsguy commented 9 years ago

In the text we make changes to the scenario "with multiple attachments" such as the line

changing attach_file "File", Rails.root.join("spec/fixtures/speed.txt") to attach_file "File #1", Rails.root.join("spec/fixtures/speed.txt")

and changing

 within("#ticket .asset") do

to

 within("#ticket .assets") do

I had to made the same changes to the scenario for "persisting file uploads across form displays" to get all the tests to pass

attached is the relevant file

On 3/2/2015 7:53 PM, Ryan Bigg wrote:

I am not sure what you mean by this. Can you please explain?

— Reply to this email directly or view it on GitHub https://github.com/railsbook/r4ia/issues/23#issuecomment-76871673.

require "rails_helper"

RSpec.feature "Creating Tickets" do

let(:user) { FactoryGirl.create(:user) }

before do login_as(user) FactoryGirl.create(:project, name: "Internet Explorer") project = FactoryGirl.create(:project, name: "Internet Explorer") assign_role!(user, :editor, project)

visit '/'
click_link "Internet Explorer"
click_link "New Ticket"

end

scenario "Creating a ticket" do fill_in "Title", with: "Non-standards compliance" fill_in "Description", with: "My pages are ugly!" click_button "Create Ticket"

expect(page).to have_content("Ticket has been created.")
within("#ticket #author") do
  expect(page).to have_content("Created by #{user.email}")
end

end

scenario "Creating a ticket without valid attributes fails" do click_button "Create Ticket"

expect(page).to have_content("Ticket has not been created.")
expect(page).to have_content("Title can't be blank")
expect(page).to have_content("Description can't be blank")

end

scenario "Description must be longer than 10 characters" do fill_in "Title", with: "Non-standards compliance" fill_in "Description", with: "it sucks" click_button "Create Ticket"

expect(page).to have_content("Ticket has not been created.")
expect(page).to have_content("Description is too short")

end

scenario "with an attachment" do fill_in "Title", with: "Add documentation for blink tag" fill_in "Description", with: "The blink tag has a speed attribute" attach_file "File #1", "spec/fixtures/speed.txt" click_button "Create Ticket"

expect(page).to have_content("Ticket has been created.")

within("#ticket .assets") do
  expect(page).to have_content("speed.txt")
end

end

scenario "persisting file uploads across form displays" do attach_file "File #1", "spec/fixtures/speed.txt" click_button "Create Ticket"

fill_in "Title", with: "Add documentation for blink tag"
fill_in "Description", with: "The blink tag has a speed attribute"
click_button "Create Ticket"

within("#ticket .assets") do
  expect(page).to have_content("speed.txt")
end

end

scenario "with multiple attachments", js: true do fill_in "Title", with: "Add documentation for blink tag" fill_in "Description", with: "Blink tag's speed attribute"

attach_file "File #1", Rails.root.join("spec/fixtures/speed.txt")
click_link "Add another file"

attach_file "File #2", Rails.root.join("spec/fixtures/spin.txt")
click_button "Create Ticket"

expect(page).to have_content("Ticket has been created.")

within("#ticket .assets") do
  expect(page).to have_content("speed.txt")
  expect(page).to have_content("spin.txt")
end

end

end

biophysicsguy commented 9 years ago

I just took a look at the creating_tickets_spec.rb in your ch9-review branch. The changes I had to make are in there already, it just isn't mentioned in the text is all.

On 3/2/2015 7:53 PM, Ryan Bigg wrote:

I am not sure what you mean by this. Can you please explain?

— Reply to this email directly or view it on GitHub https://github.com/railsbook/r4ia/issues/23#issuecomment-76871673.

radar commented 9 years ago

That branch should be merged into master already. I would be surprised if master was still incorrect in this way.

sevenseacat commented 9 years ago

We do address this already in the text, from this point:

https://github.com/railsbook/rails_4_in_action/blob/master/ch09/ch09.ad#L976