Skip to content

Commit

Permalink
Getting up to date - unknown changes
Browse files Browse the repository at this point in the history
  • Loading branch information
iarobinson committed Sep 14, 2023
1 parent 48d41b3 commit 34390c3
Show file tree
Hide file tree
Showing 7 changed files with 78 additions and 26 deletions.
2 changes: 1 addition & 1 deletion .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ IMAGE_HAWK_DATABASE_PASSWORD=
BUCKETEER_AWS_ACCESS_KEY_ID=
BUCKETEER_AWS_SECRET_ACCESS_KEY=
BUCKETEER_AWS_REGION=
BUCKETEER_BUCKET_NAME=
BUCKETEER_BUCKET_NAME=
16 changes: 16 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Base image
FROM ruby:2.7

# Set working directory
WORKDIR /app

# Install dependencies
RUN apt-get update && apt-get install -y nodejs
COPY Gemfile Gemfile.lock ./
RUN bundle install

# Copy application files
COPY . .

# Start Rails server
CMD ["rails", "server", "-b", "0.0.0.0"]
5 changes: 5 additions & 0 deletions app/models/user.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
class User < ApplicationRecord
#
scope :recently_created, -> {
where("created_at >= ?", Date.today - 2.days)
}
#
extend FriendlyId
friendly_id :name, use: :slugged
has_many :charges
Expand Down
2 changes: 1 addition & 1 deletion app/views/sessions/_form.html.erb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<%= form_with(model: session) do |form| %>
<%= form_with(model: session, id: "new_session") do |form| %>
<% if session.errors.any? %>
<div id="error_explanation">
<h2><%= pluralize(session.errors.count, "error") %> prohibited this session from being saved:</h2>
Expand Down
47 changes: 23 additions & 24 deletions features/sales.feature
Original file line number Diff line number Diff line change
@@ -1,24 +1,23 @@
#As an authenticated user
#I want to be able to access a file upload page
#So that I can upload my photographs
#
#AC: Upload form must be visible to photographer
#
#
#
#As a authenticated user
#I want to be able to upload photographs
#So that I can upload my photographs
#
#AC: The selected photographs should be uploaded to the server
#As a authenticated user
#I want to be able to see my uploaded photos
#So that I can verify that uploaded process was successfully completed
#
#AC: Server should list those photographs as part of the session
#As a authenticated user
#I want to be able to access a file upload page
#So that I can upload my photographs
#
#AC: Photographs should be served as public images available for purchase
#
Feature: User properly uploads photos and records sales
As a visitor to the website I want to see sessions created by photographer users and I want to be able to purchase photographs

Background: User is Logged In
Given Coco exists as a user
And Coco signs in with valid credentials

Scenario: Coco should be able to view their own photos
When Coco creates a new session with photos
And Coco visits that session page
Then Coco should see the photos

Scenario: Strangers should be able to view user photos
When Coco creates a new session with photos
And Stranger visits that session page
Then Stranger should see the photos

Scenario: The session should be associated with the photos
When Coco creates a new session with photos
And Sally visits that session page
And Sally clicks on the image intending to buy
And Sally clicks the buy button
Then Sally should be redirected to the stripe payment gateway
32 changes: 32 additions & 0 deletions features/step_definitions/session_steps.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
Given '{word} creates a new session with photos' do |username|
visit new_session_path
within '#new_session' do
fill_in 'session_title', with: 'The title of this test session'
fill_in 'session_description', with: 'some test description'
fill_in 'session_default_price', with: '2.22'
attach_file("session_images", Rails.root + "test/fixtures/images/surf-photo-1.jpeg")
end
click_on "Save"
@session = Session.last
end

When '{word} visits that session page' do |username|
visit session_path @session
end

Then '{word} should see the photos' do |username|
expect(@session.id.to_s).to eq(page.current_url.split('/')[-1])
# page.html.should have_content 'charges/new'
end

When('{word} clicks on the image intending to buy') do |username|
pending # Write code here that turns the phrase above into concrete actions
end

When('{word} clicks the buy button') do |username|
pending # Write code here that turns the phrase above into concrete actions
end

Then('{word} should be redirected to the stripe payment gateway') do |username|
pending # Write code here that turns the phrase above into concrete actions
end
Binary file added test/fixtures/images/surf-photo-1.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 34390c3

Please sign in to comment.