Grails 1.3.5
我编写了一些功能测试,当我的控制器和服务通过grailsApplication.config引用配置数据时,我遇到了问题.它总是返回null,所以它出错了.
我知道有一个用于单元测试的mockConfig.但是如何让配置连接到功能测试呢?
Grails 1.3.7
我有一些配置位于外部配置文件中.其中一个entires看起来像这样:
site.maintenance.mode = false
Run Code Online (Sandbox Code Playgroud)
我有一个过滤器,它检查特定URL的某些配置设置.当我执行run-app或将WAR部署到Tomcat时,执行以下操作:
boolean maintenanceMode = grailsApplication.config.site.maintenance.mode
Run Code Online (Sandbox Code Playgroud)
maintenanceMode正在回归真实.如果我在调试模式下查看配置对象,这就是我得到的:
site={maintenance={mode=false, message="<p>Our trail guides are working hard to get the system back on track.</p><p>We're sorry, the account system is down for maintenance at the moment. We'll get it back online as quickly as we can. Thanks for your patience.</p>"}}
Run Code Online (Sandbox Code Playgroud)
我有一个控制器,我用它来动态重新加载此配置文件,点击此控制器将解决问题.但我很好奇为什么它在第一次运行时是不正确的,以及为什么在维护模式变量中放入的内容与配置对象中的实际内容之间存在差异.
我意识到这可能不适合SO,所以如果是这样的话,请告诉我应该在哪里移动/发布.
我的想法是在用户登录系统后,以cookie的形式将用户首选项存储在客户端上.如果用户修改了所述首选项,请更新cookie.我需要这样做,因为一些偏好是与客户端相关的,需要通过JavaScript查看.
我意识到我也需要存储在服务器上的偏好.只是想知道是否将它们拉入饼干是一个好主意.我的应用程序主要是ajax驱动,因此我想将首选项拉下来并存储它们.我不想用每个服务器请求推送它们.
我想避免像本地存储这样的东西,这样我就不必担心浏览器了.Cookie似乎得到所有浏览器的大力支持.
有人同意或有更好的方法吗?
在分支机构工作时,我会有一些我正在改变的文件.我的一位同事告诉我,他推动了一项改变,我应该立即解决这个问题.如果我不做出改变,git就不会让我拉.即使我修改过的所有文件都没有更新.
我想知道为什么会这样,如果可能的话,有办法避免这种情况吗?
我一直在做相当多的搜索,我无法把所有的东西放在一起.我想在我们的一台服务器上创建一个常春藤存储库.我想将其锁定,因此它是私有的,然后能够从Gradle发布到此存储库.
我知道如何使用Gradle发布,并且我使用Gradle创建的本地常春藤文件系统:
repositories {
mavenCentral()
ivy {
name "localRepos"
url "${System.properties['user.home']}/repos"
}
}
uploadArchives {
repositories {
add project.repositories.localRepos
}
}
Run Code Online (Sandbox Code Playgroud)
所以我现在需要做的就是将其转化为发布到远程私人回购.但首先,显然,我需要创建该回购,而我似乎无法从常春藤文档或Google搜索中找到答案.有人能指出我正确的方向吗?
我宁愿不必采取Nexus等方法(没有Maven).
我一直在阅读文档和API,我很难找到以下解释:
export default Ember.Controller.extend({
collectionTotal: function() {
var games = this.get('model');
return games.length
}.property('@each')
});
Run Code Online (Sandbox Code Playgroud)
实际发生了.property('@each')什么?我知道我得到了计算属性,我不明白是什么@each.
我正在使用Angular 2.0.0-beta.16并尝试从我的RESTful API获取数据.我有以下服务:
import {Injectable} from 'angular2/core';
import {Jsonp, Response, Headers, RequestOptions} from 'angular2/http';
import {Store} from './store';
import {Observable} from 'rxjs/Observable';
import 'rxjs/Rx';
@Injectable()
export class StoreService {
constructor(private jsonp: Jsonp) {
}
getStores(): Observable<Store[]> {
console.log("getting stores");
// let headers = new Headers({ 'Content-Type': 'application/json' });
// let options = new RequestOptions({ headers: headers });
return this.jsonp.get("http://localhost:8080/stores")
.map(this.extractData)
.catch(this.handleError);
}
private extractData(res: Response) {
console.log(res.status);
if (res.status < 200 || res.status >= 300) {
throw new Error('Bad …Run Code Online (Sandbox Code Playgroud) 我有以下测试(可能是功能测试而不是集成,但是...):
@Integration(applicationClass = Application)
@Rollback
class ConventionControllerIntegrationSpec extends Specification {
RestBuilder rest = new RestBuilder()
String url
def setup() {
url = "http://localhost:${serverPort}/api/admin/organizations/${Organization.first().id}/conventions"
}
def cleanup() {
}
void "test update convention"() {
given:
Convention convention = Convention.first()
when:
RestResponse response = rest.put("${url}/${convention.id}") {
contentType "application/json"
json {
name = "New Name"
}
}
then:
response.status == HttpStatus.OK.value()
Convention.findByName("New Name").id == convention.id
Convention.findByName("New Name").name == "New Name"
}
}
Run Code Online (Sandbox Code Playgroud)
数据是通过BootStrap加载的(这可能是个问题),但是问题是当我在then块中时;它会Convention通过新名称和id匹配项找到,但是在测试该name字段时失败了,因为它仍然具有旧名称。
在阅读有关测试的文档时,我认为问题出在创建数据的会话中。由于的@Rollback …
我试图找出有关 redux 减速器的一些信息,但我认为术语可能会有所不同,因为这是 JavaScript。
假设有以下减速器:
import {
ONE,
TWO,
THREE
} from "../actions/types";
export default function reducer(state = { /* some init state here */ }, action) {
switch (action.type) {
case ONE: {
// this case takes 500ms to finish
return {...state }
}
case TWO: {
// this case takes 200ms to finish
return {...state }
}
case THREE: {
// this case takes 100ms to finish
return {...state }
}
default: {
return {...state }
}
}; …Run Code Online (Sandbox Code Playgroud) 我正在使用mat-tableAngular 并尝试使我的表成为可重用的组件。我有一些传递给模板的选项,例如:
const columns: TableColumn[] = [
{
title: 'Person',
colKey: 'person',
sort: {
sortable: false
}
},
{
title: 'Date',
colKey: 'date',
sort: {
sortable: true,
selected: true,
sortAsc: false
}
}
];
Run Code Online (Sandbox Code Playgroud)
我正在尝试添加mat-sort-header基于这些选项的内容。
<ng-container *ngFor="let head of options.columns" matColumnDef="{{head.colKey}}">
<mat-header-cell *matHeaderCellDef [attr.mat-sort-header]="head.sort.sortable">{{head.title}}</mat-header-cell>
<mat-cell *matCellDef="let item">{{item[head.colKey]}}</mat-cell>
</ng-container>
Run Code Online (Sandbox Code Playgroud)
因此,由于该date列是可排序的,我希望添加该mat-sort-header属性,但这似乎不起作用。
grails ×3
angular ×2
javascript ×2
ember.js ×1
git ×1
git-commit ×1
git-pull ×1
gradle ×1
grails3 ×1
ivy ×1
preferences ×1
react-redux ×1
reactjs ×1
redux ×1
redux-thunk ×1
repository ×1
rest ×1