Permalink
Browse files

software license -> license

  • Loading branch information...
1 parent 5ceccc4 commit e24f76378ae196c2c1680a8de9d5d0581a985e86 @blahed committed Nov 15, 2012
@@ -4,7 +4,7 @@ class FavoritesController < ApplicationController
def index
@web_accounts = current_user.favorites.where(:item_type => 'WebAccount').map(&:item)
@generic_accounts = current_user.favorites.where(:item_type => 'GenericAccount').map(&:item)
- @licenses = current_user.favorites.where(:item_type => 'SoftwareLicense').map(&:item)
+ @licenses = current_user.favorites.where(:item_type => 'License').map(&:item)
@notes = current_user.favorites.where(:item_type => 'Note').map(&:item)
end
@@ -1,29 +1,29 @@
-class SoftwareLicensesController < ApplicationController
+class LicensesController < ApplicationController
before_filter :authorize
before_filter :set_groups, :except => [ :create, :update, :show ]
def index
if current_user.admin?
- @licenses = SoftwareLicense.all
+ @licenses = License.all
else
- @licenses = SoftwareLicense.any_of({ :group_ids.in => current_user.group_ids }, { :group_ids => [] })
+ @licenses = License.any_of({ :group_ids.in => current_user.group_ids }, { :group_ids => [] })
end
end
def grouped
@group = allowed_groups.where(:name => params[:group]).first
not_found unless @group
- @licenses = SoftwareLicense.where(:group_ids.in => [@group.id])
- render :template => 'software_licenses/index'
+ @licenses = License.where(:group_ids.in => [@group.id])
+ render :template => 'licenses/index'
end
def new
- @license = SoftwareLicense.new
+ @license = License.new
@allowed_groups = allowed_groups
end
def create
- @license = SoftwareLicense.new(software_license_params)
+ @license = License.new(license_params)
@allowed_groups = allowed_groups
if @license.save
@@ -34,43 +34,43 @@ def create
end
def show
- @license = SoftwareLicense.find(params[:id])
+ @license = License.find(params[:id])
end
def edit
- @license = SoftwareLicense.find(params[:id])
+ @license = License.find(params[:id])
@allowed_groups = allowed_groups
end
def update
- @license = SoftwareLicense.find(params[:id])
+ @license = License.find(params[:id])
@allowed_groups = allowed_groups
- if @license.update_attributes(software_license_params)
+ if @license.update_attributes(license_params)
redirect_to @license, :notice => 'License updated'
else
render :edit
end
end
def destroy
- @license = SoftwareLicense.find(params[:id])
+ @license = License.find(params[:id])
@license.destroy
- redirect_to software_licenses_path, :notice => "License `#{@license.title}' removed"
+ redirect_to licenses_path, :notice => "License `#{@license.title}' removed"
end
private
def set_groups
if current_user.admin?
- @groups = Group.all.where(:_id.in => SoftwareLicense.group_ids)
+ @groups = Group.all.where(:_id.in => License.group_ids)
else
- @groups = current_user.groups.where(:_id.in => SoftwareLicense.group_ids)
+ @groups = current_user.groups.where(:_id.in => License.group_ids)
end
end
- def software_license_params
- params.require(:software_license).permit(
+ def license_params
+ params.require(:license).permit(
:title,
:license_key,
:licensed_to,
@@ -6,12 +6,12 @@ def index
if current_user.admin?
@web_accounts = WebAccount.where(:title => Regexp.new(@query))
@generic_accounts = GenericAccount.where(:title => Regexp.new(@query))
- @licenses = SoftwareLicense.where(:title => Regexp.new(@query))
+ @licenses = License.where(:title => Regexp.new(@query))
@notes = Note.where(:title => Regexp.new(@query))
else
@web_accounts = WebAccount.any_of({ :group_ids.in => current_user.group_ids }, { :group_ids => [] }).where(:title => Regexp.new(@query))
@generic_accounts = GenericAccount.any_of({ :group_ids.in => current_user.group_ids }, { :group_ids => [] }).where(:title => Regexp.new(@query))
- @licenses = SoftwareLicense.any_of({ :group_ids.in => current_user.group_ids }, { :group_ids => [] }).where(:title => Regexp.new(@query))
+ @licenses = License.any_of({ :group_ids.in => current_user.group_ids }, { :group_ids => [] }).where(:title => Regexp.new(@query))
@notes = Note.any_of({ :group_ids.in => current_user.group_ids }, { :group_ids => [] }).where(:title => Regexp.new(@query))
end
end
@@ -1,2 +0,0 @@
-module Accounts::GenericAccountsHelper
-end
@@ -1,2 +0,0 @@
-module Accounts::WebAccountsHelper
-end
@@ -1,2 +0,0 @@
-module Admin::GroupsHelper
-end
@@ -1,2 +0,0 @@
-module Admin::UsersHelper
-end
@@ -1,2 +0,0 @@
-module AdminHelper
-end
@@ -1,2 +0,0 @@
-module FavoritesHelper
-end
@@ -1,2 +0,0 @@
-module NotesHelper
-end
@@ -1,2 +0,0 @@
-module SessionsHelper
-end
@@ -1,2 +0,0 @@
-module SoftwareLicensesHelper
-end
@@ -1,2 +0,0 @@
-module UsersHelper
-end
@@ -1,4 +1,4 @@
-class SoftwareLicense < BaseItem
+class License < BaseItem
field :licensed_to, :type => String
field :comments, :type => String
@@ -34,7 +34,7 @@
<li><%= link_to 'Web', accounts_web_accounts_path %></li>
</ul>
</li>
- <li <%= active_class_if(software_licenses_path) %> ><%= link_to 'Licenses', software_licenses_path %></li>
+ <li <%= active_class_if(licenses_path) %> ><%= link_to 'Licenses', licenses_path %></li>
<li <%= active_class_if(notes_path) %> ><%= link_to 'Notes', notes_path %></li>
</ul>
<form class="navbar-search pull-right" action="<%= search_path %>">
@@ -18,10 +18,10 @@
<fieldset>
<legend>Groups</legend>
<br />
- <%= hidden_field_tag "software_license[group_ids][]", nil%>
+ <%= hidden_field_tag "license[group_ids][]", nil%>
<% @allowed_groups.each do |group| %>
<label class="checkbox inline">
- <%= check_box_tag 'software_license[group_ids][]', group.id, @license.groups.include?(group) %>
+ <%= check_box_tag 'license[group_ids][]', group.id, @license.groups.include?(group) %>
<%= group.name %>
</label>
<% end %>
@@ -5,7 +5,7 @@
<% else %>
Licenses
<% end %>
- <%= link_to 'New License', new_software_license_path, :class => 'btn btn-small pull-right' %>
+ <%= link_to 'New License', new_license_path, :class => 'btn btn-small pull-right' %>
</h3>
</div>
@@ -14,7 +14,7 @@
<ul class="well nav nav-list">
<li class="nav-header">Groups</li>
<% @groups.each do |group| %>
- <li <%= active_class_if(grouped_software_licenses_path(:group => group.name)) %> ><%= link_to "#{group.name}", grouped_software_licenses_path(:group => group.name) %></li>
+ <li <%= active_class_if(grouped_licenses_path(:group => group.name)) %> ><%= link_to "#{group.name}", grouped_licenses_path(:group => group.name) %></li>
<% end %>
</ul>
</div
@@ -31,7 +31,7 @@
<tbody>
<% @licenses.each do |license| %>
<tr>
- <td><%= link_to license.title, software_license_path(license) %></td>
+ <td><%= link_to license.title, license_path(license) %></td>
<td><%= fmt_datetime(license.updated_at) %></td>
</tr>
<% end %>
@@ -4,8 +4,8 @@
<%= @license.title %>
<% if @license.groups.present? %><small><%= @license.groups.map(&:name).join(', ') %></small><% end %>
- <%= link_to 'Delete', software_license_path, :class => 'btn btn-small btn-danger pull-right', :confirm => 'Are you sure you want to delete this license?', :method => :delete %>
- <%= link_to 'Edit', edit_software_license_path, :class=> 'btn btn-small pull-right' %>
+ <%= link_to 'Delete', license_path, :class => 'btn btn-small btn-danger pull-right', :confirm => 'Are you sure you want to delete this license?', :method => :delete %>
+ <%= link_to 'Edit', edit_license_path, :class=> 'btn btn-small pull-right' %>
</h3>
</div>
View
@@ -18,8 +18,8 @@
get 'web/group/:group', :to => 'web_accounts#grouped', :as => 'grouped_web'
end
- resources :software_licenses
- get 'software_licenses/group/:group', :to => 'software_licenses#grouped', :as => 'grouped_software_licenses'
+ resources :licenses
+ get 'licenses/group/:group', :to => 'licenses#grouped', :as => 'grouped_licenses'
resources :notes
get 'notes/group/:group', :to => 'notes#grouped', :as => 'grouped_notes'
View
@@ -29,7 +29,7 @@
:group_ids => (rand(5).zero? ? group_ids.sample(rand(group_ids.size)) : []),
:current_user => user
)
- SoftwareLicense.create!(
+ License.create!(
:title => Faker::Lorem.word,
:license_key => SecureRandom.hex,
:licensed_to => [ Faker::Name.name, Faker::Internet.email ].sample,
@@ -28,7 +28,7 @@
current_user { create(:user) }
end
- factory :software_license do
+ factory :license do
title
license_key 'foo'
current_user { create(:user) }
@@ -1,14 +1,14 @@
require 'minitest_helper'
-describe SoftwareLicense do
+describe License do
it "will be valid with all required fields" do
- license = FactoryGirl.build(:software_license)
+ license = FactoryGirl.build(:license)
license.must_be :valid?
license.errors.must_be :empty?
end
it "wont be valid without license_key" do
- license = FactoryGirl.build(:software_license, :license_key => nil)
+ license = FactoryGirl.build(:license, :license_key => nil)
license.wont_be :valid?
license.errors.has_key?(:license_key).must_equal true

0 comments on commit e24f763

Please sign in to comment.