Permalink
Browse files

continued working on file upload object; moved database fixtures to s…

…tandard rails location so they can be loaded with rake task
  • Loading branch information...
1 parent 16ee93b commit 599de3f268e6346d26a4472f98d1ff622e895887 @peetucket peetucket committed May 24, 2012
View
115 README.textile
@@ -7,3 +7,118 @@ This code has dependencies on non-public code:
<li>Stanford's dor-services gem</li>
<li>Stanford's sul-chrome gem </li>
</ul>
+
+h2. Getting your environment setup:
+
+ rvm install 1.9.3
+
+ git clone git@github.com:sul-dlss/hydrus.git
+ cd hydrus
+
+ bundle install
+
+ git submodule init
+ git submodule update
+
+ rake hydra:jetty:config
+
+ rake jetty:start
+
+ rake db:migrate
+ rake db:test:prepare
+ rake db:migrate RAILS_ENV=test
+
+ rake hydrus:loadfix
+ rake hydrus:loadfix RAILS_ENV=test
+
+h2. Starting the app
+
+ rake jetty:start
+ rails server
+
+Go to http://localhost:3000
+
+h2. Default user
+
+Note that you will need to be logged in to see any objects, since there is an authentication and permissions system preventing read access to the default fixtures. Login with the following default user:
+
+username: archivist1@example.com
+password: beatcal
+
+
+h2. Developing
+
+Recommended workflow:
+
+0. Create a local working branch
+
+ git branch working
+
+1. Go to your local working branch
+
+ git checkout working
+
+ -- make changes and local commits here --
+
+2. Once you are committed to your local working branch:
+
+ git checkout develop
+ git fetch
+
+3. If the git fetch pulled updates from the server, then:
+
+ git merge origin/develop
+ git checkout working
+ git rebase develop
+ git checkout develop
+ git merge working
+ git push origin develop
+
+4. If the git fetch didn't pull any updates from the server, then:
+
+ git merge working
+ git push origin develop
+
+You can use "gitx --all" at any time to see the history of each branch.
+
+5. When you're ready to develop more code, go back to step 1. You can use multiple working branches if you are developing multiple features at once that you don't want to mix together. Just create a different local branch and replace "working" above with your local branch name.
+
+h2. Useful commands
+
+h3. Using Rails console:
+
+ rails console
+
+h3. Dropping databases entirely:
+
+ rake db:drop:all
+
+Most of the rake commands are environment specific, so they can be run in test environment by adding 'RAILS_ENV=test' to the end.
+
+h3. Migrating databases to the latest version (which will also set them up if they don't exist, assuming you are using sqllite):
+
+ rake db:migrate
+
+h3. Fixtures:
+
+ rake hydrus:refreshfix # deletes and then reloads fixtures (most common)
+ rake hydrus:loadfix # loads fixtures (will fail if they exist)
+ rake hydrus:deletefix # deletes fixtures
+
+h3. Tests:
+
+ rake local_ci # run all tests (will shut down jetty, runs 'rake ci' task and then restart jetty)
+ rake rspec # just run rspec tests
+ open coverage/rcov/index.html # check your test coverage (won't exist until tests run at least once)
+
+h3. App URLs:
+
+ http://localhost:3000
+
+Local services provided by jetty, assuming it's running (most will have both a development and a test instance):
+
+ http://localhost:8983/ # lists all services
+ http://localhost:8983/fedora/admin/ # fedora admin (username and password are "fedoraAdmin")
+ http://localhost:8983/fedora/objects # find fedora objects
+ http://localhost:8983/solr/ # solr
+ http://localhost:8983/solr/development/select/ # show all solr index information
View
2 app/models/hydrus/item.rb
@@ -1,7 +1,7 @@
class Hydrus::Item < Hydrus::GenericItem
def files
- Hydrus::ObjectFile.find_all_by_pid(pid)
+ Hydrus::ObjectFile.find_all_by_pid(pid) # coming from the database
end
def submit_time
View
8 app/models/hydrus/object_file.rb
@@ -1,15 +1,17 @@
class Hydrus::ObjectFile < ActiveRecord::Base
- # attr_accessible :title, :body
- mount_uploader :file, FileUploader
+ attr_accessible :label,:published?
+
+ mount_uploader :file, FileUploader
+
def url
file.url
end
def current_path
file.current_path
end
-
+
def filename
file.file.identifier
end
View
14 db/migrate/20120522224050_create_default_user.rb
@@ -1,14 +0,0 @@
-class CreateDefaultUser < ActiveRecord::Migration
- def up
- unless Rails.env.production?
- User.find_all_by_email('archivist1@example.com').each { |u| u.destroy }
- User.create(:email=>'archivist1@example.com',:password=>'beatcal')
- end
- end
-
- def down
- unless Rails.env.production?
- User.find_all_by_email('archivist1@example.com').each { |u| u.destroy }
- end
- end
-end
View
9 db/migrate/20120523232755_create_hydrus_object_files.rb
@@ -1,15 +1,10 @@
class CreateHydrusObjectFiles < ActiveRecord::Migration
- def up
+ def change
create_table(:object_files) do |t|
t.string :pid, :null => false, :default => ""
t.string :file, :null => false, :default => ""
t.timestamps
end
- add_index :object_files, :pid
-
- end
-
- def down
- drop_table :object_files
+ add_index :object_files, :pid
end
end
View
5 db/migrate/20120524183252_add_label_to_file_object.rb
@@ -0,0 +1,5 @@
+class AddLabelToFileObject < ActiveRecord::Migration
+ def change
+ add_column :object_files, :label, :string, :default=>''
+ end
+end
View
1 lib/tasks/fixtures.rake
@@ -13,6 +13,7 @@ namespace :hydrus do
desc "load hydrus fixtures"
task :loadfix do
+ Rake::Task['db:fixtures:load'].invoke
FIXTURE_PIDS.each { |pid|
ENV["pid"] = pid
Rake::Task['repo:load'].reenable
View
2 spec/spec_helper.rb
@@ -23,7 +23,7 @@
# config.mock_with :rr
# Remove this line if you're not using ActiveRecord or ActiveRecord fixtures
- config.fixture_path = "#{::Rails.root}/spec/fixtures"
+ config.fixture_path = "#{::Rails.root}/test/fixtures"
# If you're not using ActiveRecord, or you'd prefer not to run each of your
# examples within a transaction, remove the following line or assign false
View
6 test/fixtures/object_files.yml
@@ -0,0 +1,6 @@
+file1:
+ id: 1
+ pid: druid:oo000oo0001
+ created_at: <%=Time.now%>
+ updated_at: <%=Time.now%>
+ file: test
View
0 spec/fixtures/users.yml → test/fixtures/users.yml
File renamed without changes.

0 comments on commit 599de3f

Please sign in to comment.