Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
biophysicsguy opened this issue Mar 3, 2015 · 5 comments

Comments

@biophysicsguy
Copy link

No description provided.

@radar
Copy link
Contributor

radar commented Mar 3, 2015

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

@biophysicsguy
Copy link
Author

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
#23 (comment).

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
Copy link
Author

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
#23 (comment).

@radar
Copy link
Contributor

radar commented Mar 3, 2015

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

@sevenseacat
Copy link
Member

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants