Skip to content

Host can make offer on listing#15

Open
stefankarlberg wants to merge 21 commits into
CraftAcademy:developmentfrom
stefankarlberg:host_can_make_offer_on_listing
Open

Host can make offer on listing#15
stefankarlberg wants to merge 21 commits into
CraftAcademy:developmentfrom
stefankarlberg:host_can_make_offer_on_listing

Conversation

@stefankarlberg

Copy link
Copy Markdown
Contributor

PT Story

Changes proposed in this pull request:

  • Feature tests for happy and sad paths for the scenario
  • Creates a Offer model, columns in db: name, email, location, price with foreign key - listing_id.
  • Creates Offer controller with 'index', 'new' and 'create' methods
  • Defines Offer in the routes as a nested route in listings
  • Creates listing show view, adds form for offer

What we have learned working on this feature:

  • Learned more about debugging with binding.pry
  • Refreshes HAML syntax
  • Nesting routes

Screenshots

Screenshot 2019-05-10 at 15 05 02

Carrosen and others added 17 commits May 9, 2019 12:14
…e of columns in Offer model, adds show method to offers controller
…curate ones, removes empty lines. First test in scenario going green, 1/10
…essage saying you need to fill in all fields correctly
Comment thread features/host_can_make_offer_on_listing.feature Outdated
Comment thread features/host_can_make_offer_on_listing.feature Outdated
Comment thread features/step_definitions/assertion_steps.rb Outdated
Comment thread spec/models/offer_spec.rb
Comment thread app/models/offer.rb
Comment thread app/controllers/offers_controller.rb Outdated
end

def new
@offer = Offer.new(offer_params)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do you need to use an instance variable here?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no

end

def create
@listing = Listing.find(params[:listing_id])

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do you need to use an instance variable here?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

didnt work without

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What did you try?


def create
@listing = Listing.find(params[:listing_id])
@offer = @listing.offers.create(offer_params)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do you need to use an instance variable here?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

didnt work without

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please explain what is the other option you tried @Carrosen

Comment thread features/step_definitions/basic_steps.rb Outdated
When I visit the landing page

Scenario: Host can successfully create an offer
Then I should see "Zane"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unnecessary to test for this

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yup

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Then I should see "Zane"
When I click "Make an offer" within "Zane" section
Then I should be on the "Zane" listing page
Then I should see "Create your offer"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

When I click "Make an offer" within "Zane" section
Then I should be on the "Zane" listing page
Then I should see "Create your offer"
And I fill in "Name" with "Steffe"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Then I should be on landing page

Scenario: Host can not create an offer when not all the fields are filled in.
When I click "Make an offer" within "Zane" section

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same comments as above

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

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

Successfully merging this pull request may close these issues.

4 participants