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
<%= form_tag({action: 'storedata', controller: 'profileinfo'}, multipart: true) do %> | |
<%= file_field_tag :file %> | |
<%= submit_tag %> | |
<% end %> | |
<form accept-charset="UTF-8" action="/profileinfo/storedata" enctype="multipart/form-data" method="post"> | |
<div style="margin:0;padding:0;display:inline"> | |
<input name="utf8" type="hidden" value="✓" /> | |
<input name="authenticity_token" type="hidden" value="EMXCLkxw84pdO1+AWacyzti8ok8b5jDj5H6u2BmBBMc=" /> |
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
class SessionsController < Devise::SessionsController | |
def create | |
respond_to do |format| | |
format.html { super } | |
format.json { | |
warden.authenticate!(:scope => resource_name, :recall => "#{controller_path}#new", | |
email: params[:email], password: params[:password]) | |
render :status => 200, :json => { :error => "Success" } | |
} |
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
describe 'Update user profile' do | |
describe 'Update profile of admin' do | |
it "it updates first_name and password" do | |
request.accept = "application/json" | |
post 'create' , @userinfo.merge!(role_name: 'Project manager') | |
@userinfo = {first_name: 'Sabri', last_name: 'Abarkan', user_id: User.last.id } | |
put 'update', @userinfo | |
# @user.reload | |
result = JSON.parse(response.body) | |
expect(@userinfo['']).to eq earlier_password |
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
def generatereport | |
if !params[:id].blank? && Report.find(params[:id]) | |
respond_to do |format| | |
format.pdf do | |
render :pdf => "file_name", | |
:orientation => 'Portrait' | |
end | |
format.html | |
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
user ||= User.new # guest user (not logged in) | |
if user.has_role? 'Administrator' | |
can :manage, :all | |
elsif user.has_role? 'Project manager' | |
can :read, Project, :id => user.projects.pluck(:id) | |
can :manage, Budget | |
can :assignusertoproject, Project | |
can :updateuserprojectcontract, Project | |
can :destroyprojectcontract, Project, :id => user.projects.pluck(:id) | |
#can :read, Project, :id => Project.with_role('Project Manager', user).pluck(:id) |