-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
144 additions
and
25 deletions.
There are no files selected for viewing
This file contains 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 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 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,8 +1,11 @@ | ||
# Read about factories at https://github.com/thoughtbot/factory_girl | ||
# | ||
|
||
CITIES = %w.Split Zagreb Bjelovar Osijek Samobor Sisak Kutina. | ||
|
||
FactoryGirl.define do | ||
factory :city do | ||
name "MyString" | ||
name { CITIES.sample } | ||
region | ||
end | ||
end |
This file contains 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 |
---|---|---|
|
@@ -2,7 +2,7 @@ | |
|
||
FactoryGirl.define do | ||
factory :favorite, :class => 'Favorites' do | ||
ad nil | ||
user nil | ||
ad | ||
user | ||
end | ||
end |
This file contains 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,7 +1,9 @@ | ||
# Read about factories at https://github.com/thoughtbot/factory_girl | ||
# | ||
REGIONS = %w.Bjelovarsko-Bilogorska Krapinsko-Zagorska Primorsko-Goranska. | ||
|
||
FactoryGirl.define do | ||
factory :region do | ||
name "MyString" | ||
name { REGIONS.sample } | ||
end | ||
end |
This file contains 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,7 +1,44 @@ | ||
# encoding: utf-8 | ||
|
||
include AdHelper | ||
include SessionHelper | ||
|
||
def debug | ||
save_and_open_page | ||
end | ||
|
||
feature "Ads" do | ||
scenario "Ad creation for guests" do | ||
visit new_ad_path | ||
page.should have_content("moraš se prijaviti") | ||
expect_to_see("moraš se prijaviti") | ||
end | ||
|
||
scenario "Ad creation for users", :sunspot_matchers => true do | ||
["Clothing", "Food"].each {|name| create(:category, :name => name) } | ||
["Zagreb", "Split"].each {|name| create(:city, :name => name) } | ||
|
||
sign_in | ||
visit new_ad_path | ||
|
||
fill_in_ad_details | ||
|
||
submit_ad | ||
|
||
expect_to_see_details_for Ad.last | ||
end | ||
|
||
scenario "Ad validations", :sunspot_matchers => true do | ||
["Clothing", "Food"].each {|name| create(:category, :name => name) } | ||
["Zagreb", "Split"].each {|name| create(:city, :name => name) } | ||
|
||
sign_in | ||
visit new_ad_path | ||
|
||
should_be_required :ad_type | ||
should_be_required :title | ||
should_be_required :description | ||
should_be_required :phone | ||
|
||
should_not_be_required :email | ||
end | ||
end |
This file contains 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 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 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,25 @@ | ||
module SessionHelper | ||
def sign_up_with(email, password) | ||
visit sign_up_path | ||
fill_in 'email', with: email | ||
fill_in 'password', with: password | ||
click_button 'Sign up' | ||
end | ||
|
||
def sign_in(user = create(:user)) | ||
visit sign_in_path | ||
fill_in 'E-mail', with: user.email | ||
fill_in 'Lozinka', with: user.password | ||
click_button 'Prijavi se' | ||
end | ||
|
||
private | ||
|
||
def sign_in_path | ||
new_user_session_path | ||
end | ||
|
||
def sign_up_path | ||
new_user_registration_path | ||
end | ||
end |