Skip to content
This repository has been archived by the owner on Mar 15, 2018. It is now read-only.

Commit

Permalink
Merge branch 'master' of github.com:snap-cloud/snap-cloud
Browse files Browse the repository at this point in the history
  • Loading branch information
arjunbaokar committed Apr 22, 2015
2 parents d689781 + b9ac374 commit a5bba75
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 8 deletions.
1 change: 0 additions & 1 deletion app/controllers/api/v1/projects_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ def show
# returns all projects if user is looking at own projects
# returns public projects for users if otherwise
def index
# find_project
if @project
respond_with @project
return
Expand Down
10 changes: 5 additions & 5 deletions app/controllers/projects_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ def index
if @project
render :action => "show"
end

# TODO: Show interesting Public Projects
end

def show
# @project = find_project()
if @project != nil
@project = Project.find(params[:id])
# @project = Project.find(params[:id])
@owner = User.find_by_id @project.owner
render :action => "show"
end
Expand Down Expand Up @@ -57,11 +57,11 @@ def destroy
private

def find_project
@project = nil
if params[:username] && params[:projectname]
find_project_by_name(params[:username], params[:projectname])
elsif not Project.exists?(params[:id])
item_not_found
else
elsif params[:id]
# AR will automatically throw a not found exception
@project = Project.find(params[:id])
end
end
Expand Down
7 changes: 5 additions & 2 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,14 @@

# viewable project mappings
resources :projects #, :only => [:show] # , :new, :create
resources :users
resources :users do
resources :projects
end



get 'assignments/:course_id/new', to: 'assignments#new', as: 'assignment_new'
post 'assignments/:course_id/create', to: 'assignments#create', as: 'assignment_create'
post 'assignments/:course_id/create', to: 'assignments#create', as: 'assignment_create'
post 'assignments/:id/update', to: 'assignments#update', as: 'assignment_update'
post 'assignments/:id/delete', to: 'assignments#delete', as: 'assignment_delete'
get 'assignments/:id/edit', to: 'assignments#edit', as: 'assignment_edit'
Expand Down
1 change: 1 addition & 0 deletions spec/controllers/api/v1/projects_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@
proj4 = Project.create(title: "nonuser private", owner:not_users_id, is_public: 0)
get :index, {user_id: user.id}, format: :json
project_response = JSON.parse(response.body, symbolize_names: true)

expect(project_response.length).to eq(2)
expect(project_response[0][:title]).to eq("user public")
expect(project_response[1][:title]).to eq("user private")
Expand Down

0 comments on commit a5bba75

Please sign in to comment.