Avoin Ministeriö -verkkopalvelu.
https://www.avoinministerio.fi/
If you want more information about the project, drop us an email to main@avoinministerio.flowdock.com.
-
Clone the repository
git clone git@github.com:avoinministerio/avoinministerio.git
-
.rvmrc
It might be a good idea to use .rvmrc file to set ruby environment
w168:avoinministerio arttu$ cat .rvmrc rvm use 1.9.3-p125@avoinministerio --create w168:avoinministerio arttu$
This way you will always be running the same ruby version with a defined gemset under this directory.
-
Check that you have the right ruby version (1.9.X)
-
Install the required gems
cd avoinministerio bundle install --without production:linux_test
if you are developing on Linux replace
linux_test
withmac_test
-
Create database.yml in the config folder by copying database.yml.example and modifying it
cp config/database.yml.example config/database.yml
-
Create a pre-commit hook that runs automated tests before each commit and keeps you from committing if some tests fail. Create a file called
pre-commit
in the.git/hooks
directory, and copy this content to it:#!/usr/bin/env ruby require File.expand_path('../../../config/application', __FILE__) AvoinMinisterio::Application.load_tasks Rake.application["spec"].reenable Rake.application["spec"].invoke
Also make the file executable:
chmod +x .git/hooks/pre-commit
-
Setup the database (create DB, load schema, load seed data)
bundle exec rake db:setup
-
Start the app
bundle exec rails s
Run tests with:
bundle exec rake db:test:prepare
bundle exec rake spec
Run tests when RED-GREEN-REFACTOR:
bundle exec guard
-
Optionally read unofficial Ruby style guidelines before starting to write code
-
Fork the repository in Github
-
Clone your fork and setup the remote repository
git clone git@github.com:<username>/avoinministerio.git cd avoinministerio git remote add avoinministerio git@github.com:avoinministerio/avoinministerio.git
-
Create a feature branch
# The first two commands are not needed if you just cloned, but they don't hurt you either git checkout master git pull avoinministerio master git push # to push commits from avoinministerio/master to your fork's master git push origin origin:refs/heads/new-feature git fetch origin git checkout --track -b new-feature origin/new-feature git pull git rebase master
-
Hack, commit and push your feature
git add . git commit -m "Commit message" git push
If the commit fails due to failing tests but you need to commit your changes nevertheless, use the
--no-verify
switch.git commit -m "Commit message" --no-verify git push
-
Pull and rebase the upstream repository
git checkout master git pull avoinministerio master git push git checkout new-feature git rebase master # fix possible conflicts git push
Sometimes git says this when you try to push the rebased branch:
"To prevent you from losing history, non-fast-forward updates were rejected Merge the remote changes (e.g. 'git pull') before pushing again. See the 'Note about fast-forwards' section of 'git push --help' for details."
In that case, you need to run
git pull --rebase
git push
If you're lazy, you can configure git so that it always uses the --rebase switch when you run git pull.
git config pull.rebase true
-
Run tests to confirm your tests work with rebased master
bundle install bundle exec rake db:migrate db:test:prepare bundle exec rake spec
-
Create a pull request in Github
https://github.com/<username>/avoinministerio/pull/new/new-feature
-
Add new developer's repository to remote if needed
git remote add kalleya git@github.com:kalleya/avoinministerio.git
-
Bring his repository into yours. Please notice the output of the command, it says which branches the fetch brought.
git fetch kalleya
-
Check the branch if needed with
git branch -a # lists all local and remote branches # pick one remote branch that you'll test for merging # checkout remote branch as a local branch git checkout -b ui-fixes-incl-drafts kalleya/ui-fixes-incl-drafts
-
Setup for testing
bundle install bundle exec rake db:migrate db:test:prepare # if db:migrate also emptied your db you probably need to seed some data bundle exec rake db:seed bundle exec rake spec rails s # if everything works then you're ready for final step, jump to 6
-
If things fail, hack around, make needed commits, and push to avoinministerio/master
-
Merge either way: 6.1 If automerge is possible and no local commits were needed, Open github pull request, and click Merge pull request button, 6.2 Manual merging:
# merge to local master git checkout master git pull --rebase avoinministerio master # resolve possible conflicts git merge <feature-branch> # please notice this branch is now local, ie. not kalleay/feature-branch anymore # resolve possible conflicts again # finally git push # if cannot due non-fastforward, first git pull git push avoinministerio master
-
Deploy as needed, probably to staging for wider audience testing
To create your personal instance on Heroku:
-
Set up Heroku account
-
Create and configure your own instance
heroku create --stack cedar heroku config:add BUNDLE_WITHOUT="development:test:mac_test:linux_test" -r heroku
-
Initial deployment
git push heroku master
-
Initialize database with test data
heroku run rake db:setup
You can deploy whatever branch/commit by
git push heroku +<local_ref>:master
# e.g. the currently checked out branch
git push heroku +HEAD:master
The site can be protected with Basic Authentication by adding variables AM_AUTH_USERNAME
and AM_AUTH_PASSWORD
to Heroku.
For sending emails best method is Simple Mail Transfer Protocol(SMTP), gmail provides it easily.
Copy setup_mail.rb file
cp config/initializers/setup_mail.rb.example config/initializers/setup_mail.rb
Enable emailing in development environment. In your development.rb, change action_mailer.perform_deliveries to true
config.action_mailer.perform_deliveries = true
Go to config/initializers/setup_mail.rb file and just replace:
-
with username provided by the mailing.
-
with the password to the account whose username has been provided.
To keep track of the email sent you'll find the emails in the sent folder of the user provided in the configuration.
if Rails.env == 'development'
ActionMailer::Base.smtp_settings = {
:address => "smtp.gmail.com",
:port => "587",
:domain => 'localhost:3000',
:user_name => '<USERNAME>',
:password => '<PASSWORD>',
:authentication => 'plain',
:enable_starttls_auto => true
}
end
You can test the mail setup by clicking on link 'forget password'. It will send you instruction email when you will submit your email. Check your spam folder, if you are not getting emails.
####NOTE: Configure config.action_mailer.perform_deliveries = false in development.rb, if you want to STOP email deliveries in development mode.
JS Libraries
- jQuery
- Raphael (http://raphaeljs.com/)
- gRaphael (http://g.raphaeljs.com/)
Other
- Ruby 1.9.X
Run the tests using the following command(s):
rspec spec
or bundle exec rspec spec
or bundle exec guard
Everything is currently in the master branch. When building bigger features, use feature branches. When the feature is ready, delete the feature branch.
We will be expanding the developer community as it goes. At the moment the core devs are using a special product (thanks to Flowdock!), and hang out also at #Avoinministerio in Freenode IRC. Besides competely Finnish #Avoinministerio there's also friendly English channel #TheOpenMinistry. Feel free to pop in with any questions or suggestions!