-
Notifications
You must be signed in to change notification settings - Fork 9
Owner can view offer #13
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
Open
boamatule
wants to merge
19
commits into
CraftAcademy:development
Choose a base branch
from
boamatule:owner_can_view_offer
base: development
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
a9cd39c
creates features steps for owner can view offers.
boamatule 91e4215
adds scenario steps and background for offers already existing. Adds …
leiter007 3ef66eb
generates offer model.
boamatule 9861b73
generates reference to listing in Offer model. Adds nested routes, as…
leiter007 4817b46
adds unit test for Assosciations btw offers and listing
boamatule d410d23
adds Show listing to index view for listings. Adds background step fo…
leiter007 341392a
creates show view for listing to make listing path valid.
boamatule ce80e33
adds step definition to check for correct listing by name. 7/12 tests…
leiter007 a626344
adds offer info to be rendered in the listing show page.
boamatule 68c725a
adds accept button on show view for listing. 12/12 steps green
leiter007 199a724
adds date intervals in the show page for listings;
boamatule 9b10202
adds test for checking headline for Offers, and pet picture, in the s…
leiter007 b5b96fe
adds unit test for validating DB columns and presence of all attribu…
leiter007 4166a47
adds sad path test for when there are no offers on a listing it shoul…
leiter007 b8187a6
changes feature test to check for correct message if no offers exists…
leiter007 05d406d
adds steps def for viewing button
boamatule 8335382
removes assertion steps from background. 18/18 tests green
leiter007 d4ceb6a
changes should matcher do the new expected syntax for offer_spec.rb a…
leiter007 925b6e7
fixes smal error in offer_spec file to make all tests pass
leiter007 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,4 @@ | ||
| class Listing < ApplicationRecord | ||
| has_many :offers | ||
| validates_presence_of :pet_name, :pet_location, :pet_description, :start_date, :end_date, :pet_picture | ||
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| class Offer < ApplicationRecord | ||
| belongs_to :listing | ||
| validates_presence_of :name, :email, :location, :price | ||
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| %h1= @listing.pet_name | ||
| %p=@listing.pet_picture | ||
| %p Dates: #{@listing.start_date} to #{@listing.end_date} | ||
|
|
||
| %h2 Offers | ||
| - if @listing.offers.any? | ||
| - @listing.offers.each do |offer| | ||
| .offer{id: dom_id(offer)} | ||
| %p= offer.name | ||
| %p= offer.email | ||
| %p= offer.location | ||
| %p #{offer.price} kr | ||
| %p= link_to "Accept offer", "#" | ||
| - else | ||
| .message There are no offers on this listing | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,8 @@ | ||
| Rails.application.routes.draw do | ||
| root controller: :listings, action: :index | ||
| resources :listings, only: [:new, :create] | ||
|
|
||
| resources :listings, only: [:new, :show, :create] do | ||
| resources :offers | ||
| end | ||
|
|
||
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| class CreateOffers < ActiveRecord::Migration[5.2] | ||
| def change | ||
| create_table :offers do |t| | ||
| t.string :name | ||
| t.string :email | ||
| t.string :location | ||
| t.integer :price | ||
|
|
||
| t.timestamps | ||
| end | ||
| end | ||
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| class AddListingToOffers < ActiveRecord::Migration[5.2] | ||
| def change | ||
| add_reference :offers, :listing, foreign_key: true | ||
| end | ||
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| Feature: Owner can view offers on Listing page | ||
| As a cat owner, | ||
| In order to choose host for my cat | ||
| I need to be able to view the offers for my listing | ||
|
|
||
| Background: Offers exists on a listing | ||
| Given the following listings exist | ||
| | pet_name | pet_location | pet_description | start_date | end_date | pet_picture | | ||
| | Leif | Gothenburg | I'm nice | 2019-06-28 | 2019-06-29 | picture1 | | ||
| | Ace | Stockholm | I'm nice | 2019-06-28 | 2019-06-29 | picture2 | | ||
| And the following offers exists on a listing | ||
| | name | email | location | price | listing | | ||
| | Felix | felix@craft.se | Gothenburg | 100 | Leif | | ||
| And I visit the landing page | ||
|
|
||
| Scenario: Owner can click on listing and see correct offers in that listing | ||
| When I click "Show listing" within "Leif" section | ||
| Then I should be on the "Leif" listing page | ||
| And I should see "Leif" | ||
| And I should see "picture1" | ||
| And I should see "Dates: 2019-06-28 to 2019-06-29" | ||
| And I should see "Offers" | ||
| And I should see "Felix" | ||
| And I should see "felix@craft.se" | ||
| And I should see "Gothenburg" | ||
| And I should see "100 kr" | ||
| And I should see "Accept offer" | ||
| And I should not see "There are no offers on this listing" | ||
|
|
||
| Scenario: Owner can click on listing and see "There are no offers for this listing" if that is the case | ||
| When I click "Show listing" within "Ace" section | ||
| Then I should be on the "Ace" listing page | ||
| And I should see "There are no offers on this listing" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| FactoryBot.define do | ||
| factory :offer do | ||
| name { "MyString" } | ||
| email { "MyString" } | ||
| location { "MyString" } | ||
| price { 1 } | ||
| listing | ||
| end | ||
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| require 'rails_helper' | ||
|
|
||
| RSpec.describe Offer, type: :model do | ||
| describe 'DB table' do | ||
| it { is_expected.to have_db_column :id } | ||
| it { is_expected.to have_db_column :name } | ||
| it { is_expected.to have_db_column :email } | ||
| it { is_expected.to have_db_column :location } | ||
| it { is_expected.to have_db_column :price } | ||
| end | ||
|
|
||
| describe 'Validations' do | ||
| it { is_expected.to validate_presence_of :name } | ||
| it { is_expected.to validate_presence_of :email } | ||
| it { is_expected.to validate_presence_of :location } | ||
| it { is_expected.to validate_presence_of :price } | ||
| end | ||
|
|
||
| describe 'Associations' do | ||
| it { is_expected.to belong_to(:listing)} | ||
| end | ||
|
|
||
| describe 'Factory' do | ||
| it 'should have a valid Factory' do | ||
| expect(FactoryBot.create(:offer)).to be_valid | ||
| end | ||
| end | ||
| end |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are the elements below supposed to be within the `.offer? div? Check the indentation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, they are supposed to be nested - and with current indentation they are not.. Changing the indentation now.